Query editor
withwords as (withcleaning as (SELECTcase when COALESCE(purl.channel_id,try(split(COALESCE(c.root_parent_url,c.parent_url),'/')[6]),COALESCE(c.root_parent_url,c.parent_url)) = 'onchain-summer' then 'base'else COALESCE(purl.channel_id,try(split(COALESCE(c.root_parent_url,c.parent_url),'/')[6]),COALESCE(c.root_parent_url,c.parent_url))end as parent_url, case when c.created_at >= now() - interval '7' day then 1 else 0 end as this_week, fid-- , split(regexp_extract(text, 'https://\S*'),'/')[3] as link_domains --do popular domains separately later, split(regexp_replace(regexp_replace(regexp_replace(regexp_replace(text, 'https://\S*',''),'[[:punct:]]', ''),'0x[a-fA-F0-9]{40}',''),'<[^>]+>',''),' ') as text_cleaned, textFROM dune.neynar.dataset_farcaster_casts cLEFT JOIN dune.dune.dataset_farcaster_early_channels purl ON purl.parent_url =COALESCE(c.root_parent_url,c.parent_url)WHERE COALESCE(c.parent_url, c.root_parent_url) is not nulland deleted_at is nulland c.created_at >= now() - interval '14' dayand c.fid IN (SELECT fid FROM query_3418402 WHERE fid_active_tier >=1))SELECT-- parent_url,this_week,fid,lower(trim(c.word)) as word-- , textFROM cleaningLEFT JOIN unnest(text_cleaned) as c(word) on trueLEFT JOIN dune.dune.dataset_stopwords st ON lower(trim(c.word)) = regexp_replace(st.stopwords,'[[:punct:]]', '')WHERE 1=1and ('{{words channel filter}}' = 'all channels' OR lower(parent_url) LIKE '%' || lower('{{words channel filter}}') || '%')and st.stopwords is nulland lower(trim(c.word)) not in ('today','like','follow','recast','get','good','join','lets','new','left','back','great','know','nice','done','need','think','guys','people','thank','hello','bro','lol','much','really','right','thats','hot','cool','use','yes','no','also','everyone','something','post','whats','come','many','sure','ill','take','keep','every','well','ive','even','anyone','always','big','made','could','using','feel','never','find','ready','thing','followers','better','let','already','looking','look','say','try','yet','miss','give','coming','getting','last','yeah','fam','happy','hope','days','start','things','gonna','another','please','lot','wait','amazing','users','user','around','week','worth','share','joined','man','following','trying','guy','might','though','since','waiting','actually','less','anything','seems','haha','makes','may','stuff','ago','finally','definitely','everything','end','shit','fuck','damn','lmao','bad','one','first','comment','time','see','got','make','still','want','day','way','cant','going','would','next','real','cast','reply','click','help','hey','nothing','free','love','similar','seem','worked','basically','directly','especially','likely','probably','exactly','totally','fully','currently','usually','absolutely','truly','recently','simply','literally','via','sir','heres','idk','either','omg','thanks')and try(cast(lower(trim(c.word)) as int)) is nulland length(lower(trim(c.word))) > 2 --get rid of emojis and small words)--tf-idf calculation, term_frequency AS (SELECTthis_week,fid,word,