Public
Edited
May 1, 2024
Fork of Hello, NLP!
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
words = toWords(nounsInfo)
.concat(toWords(verbsInfo))
.concat(toWords(adverbsInfo))
.concat(toWords(adjectivesInfo))
.sort((a,b) => b.freq - a.freq)
Insert cell
Insert cell
doc = nlp(lyrics)
Insert cell
normalizedDoc = nlp(lyrics).normalize({
whitespace: true, // remove hyphens, newlines, and force one space between words
punctuation: true, // remove commas, semicolons - but keep sentence-ending punctuation
case: true, // keep only first-word, and 'entity' titlecasing
numbers: true, // 'one' → '1'
plurals: true, // 'eyes' → 'eye'
verbs: true, // 'swtiched' → 'switch'
})
Insert cell
sentences = doc.sentences().data()
Insert cell
terms = doc.terms().data()
Insert cell
ngrams = doc.ngrams().data()
Insert cell
contractions = doc.contractions().data()
Insert cell
Insert cell
Insert cell
Insert cell
tags = doc.out('tags')
Insert cell
uniqueTags = getUniqueTags(tags)
Insert cell
tagTree = createTagTree(uniqueTags)
Insert cell
Insert cell
adjectives = doc.adjectives().data()
Insert cell
adjectivesInfo = doc.adjectives().out('topk') // sort by frequency
Insert cell
adjectiveList = toShortList(printList(adjectivesInfo))
Insert cell
Insert cell
adverbs = doc.adverbs().data()
Insert cell
adverbsInfo = doc.adverbs().out('topk')
Insert cell
adverbList = toShortList(printList(adverbsInfo))
Insert cell
Insert cell
nouns = doc.nouns().out('array')
Insert cell
nounsInfo = normalizedDoc.nouns().out('topk') // sort by frequency
Insert cell
nounList = toShortList(printList(nounsInfo))
Insert cell
Insert cell
verbs = doc.verbs().out('array')
Insert cell
verbsInfo = normalizedDoc.verbs().out('topk') // sort by frequency
Insert cell
verbList = toShortList(printList(verbsInfo))
Insert cell
Insert cell
Insert cell
nlp = require('compromise@11.14.3')
Insert cell
import {printList, printHtml} from '@spencermountain/nlp-compromise'
Insert cell
Insert cell
d3cloud = require('d3-cloud')
Insert cell
import {createWordCloudSvg, downloadWordCloudSvg, toWords} from '@randomfractals/nlp-word-cloud'
Insert cell
import {tagLegends, tagTypes, tagColors} from '@randomfractals/nlp-text-tags'
Insert cell
import {createTagTreeSvg, downloadTagTreeSvg, getUniqueTags, createTagTree} from '@randomfractals/nlp-tag-tree'
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more