Published
Edited
Mar 5, 2020
Fork of Hello, NLP!
2 stars
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
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
peopleList = toShortList(printList(doc.people().out('topk')))
Insert cell
Insert cell
placeList = toShortList(printList(doc.places().out('topk')))
Insert cell
Insert cell
numberList = toShortList(printList(doc.values().out('topk')))
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

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