Published
Edited
Dec 9, 2021
Insert cell
Insert cell
Insert cell
Insert cell
data = FileAttachment("atw_posts.csv").csv()
Insert cell
Insert cell
viewof table = Inputs.table(data, {})
Insert cell
Insert cell
words = [];
Insert cell
data.forEach((entry) => {
words.push(entry.POST_BODY)
});
Insert cell
words
Insert cell
word_string = words.join(" ")
Insert cell
word_array = word_string
.split(/[\s.]+/g)
.map((w) => w.replace(/^[“‘"\-—()\[\]{}]+/g, ""))
.map((w) => w.replace(/[;:.!?()\[\]{},"'’”\-—]+$/g, ""))
.map((w) =>
w.replace(
/https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)/g,
""
)
)
.map((w) => w.replace(/(.*)[\/-_?=](.*)/g, ""))
.map((w) => w.replace(/([0-9 ]*)/g, ""))
.map((w) => w.replace(/^[0-9]{1,45}$/g, ""))
.map((w) => w.replace(/ \d+ /g, ""))
.map((w) => w.replace(/['’]s$/g, ""))
.map((w) => w.replace(/(.*)-(.*)/g, ""))
.map((w) => w.replace(/[^\x00-\x7F]/g, ""))
.map((w) => w.substring(0, 30))
.map((w) => w.toLowerCase())
.filter((w) => w && !stopwords.has(w))
Insert cell
word_filtered = word_array.filter(w => /\W/.test(w))
Insert cell
WordCloud(word_filtered, {
width: 1000,
height: 600,
size: () => .9 + Math.random(),
rotate: 0
})
Insert cell
stopwords = new Set("i,me,my,myself,we,us,our,ours,ourselves,you,your,yours,yourself,yourselves,he,him,his,himself,she,her,hers,herself,it,its,itself,they,them,their,theirs,themselves,what,which,who,whom,whose,this,that,these,those,am,is,are,was,were,be,been,being,have,has,had,having,do,does,did,doing,will,would,should,can,could,ought,i'm,you're,he's,she's,it's,we're,they're,i've,you've,we've,they've,i'd,you'd,he'd,she'd,we'd,they'd,i'll,you'll,he'll,she'll,we'll,they'll,isn't,aren't,wasn't,weren't,hasn't,haven't,hadn't,doesn't,don't,didn't,won't,wouldn't,shan't,shouldn't,can't,cannot,couldn't,mustn't,let's,that's,who's,what's,here's,there's,when's,where's,why's,how's,a,an,the,and,but,if,or,because,as,until,while,of,at,by,for,with,about,against,between,into,through,during,before,after,above,below,to,from,up,upon,down,in,out,on,off,over,under,again,further,then,once,here,there,when,where,why,how,all,any,both,each,few,more,most,other,some,such,no,nor,not,only,own,same,so,than,too,very,say,says,said,shall".split(","))
Insert cell
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more