Published
Edited
Jan 13, 2020
1 star
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
corpus = new tfidf.Corpus(
ids,
descriptions,
false, // use stopwords
[], // custom stopwords
//2, // default K1 parameter
//0.75, // default b parameter
)
Insert cell
theme_corpus = new tfidf.Corpus(
theme_ids,
theme_descriptions,
false, // use stopwords
[], // custom stopwords
//2, // default K1 parameter
//0.75, // default b parameter
)
Insert cell
selected_document = theme_ids[my_slider]
Insert cell
theme_corpus.getTopTermsForDocument(selected_document, 10000)
Insert cell
my_words = {
// R0151 R0658
let document = selected_document
//console.log(corpus.getDocument(document)._text)
//console.log(corpus.getDocument(document)._words)
let my_words = theme_corpus.getDocument(document).getUniqueTerms()
//console.log('my words',my_words)
my_words = my_words.map(w=>{
let corpusFreqWeight = corpus.getCollectionFrequencyWeight(w)
let themeFreqWeight = theme_corpus.getCollectionFrequencyWeight(w)
//let rankDocTheme = theme_corpus.getTopTermsForDocument(selected_document, 10000).find(d=>w===d[0])[1]
//let rankDocCorpus = corpus.getTopTermsForDocument(selected_document, 10000).find(d=>w===d[0])[1]
let obj = {
word: w,
themeFreqWeight: themeFreqWeight,
corpusFreqWeight: corpusFreqWeight
}
//console.log(obj)
return obj
})
return my_words//.sort((a,b)=>{return a.corpusFreq - b.corpusFreq })
}
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