Platform
Resources
Pricing
Sign in
Contact us
spencer kelly
freelance javascripter
Workspace
Fork
Public
nlp-compromise
By
spencer kelly
Edited
May 26, 2022
4 stars
Insert cell
Insert cell
5
Insert cell
{
var
doc
=
nlp
(
"Björk, the singer-songwriter, plays at seven..."
)
doc
.
normalize
(
)
return
doc
.
out
(
'text'
)
}
Insert cell
Insert cell
{
// default params:
return
{
// remove hyphens, newlines, and force one space between words
whitespace
:
true
,
// keep only first-word, and 'entity' titlecasing
case
:
true
,
// remove commas, semicolons - but keep sentence-ending punctuation
punctuation
:
true
,
// visually romanize/anglicize 'Björk' into 'Bjork'.
unicode
:
true
,
// turn "isn't" to "is not"
contractions
:
true
,
//remove periods from acronyms, like 'F.B.I.'
acronyms
:
true
,
//---these ones don't run unless you want them to---
//remove words inside brackets (like these)
parentheses
:
false
,
// turn "Google's tax return" to "Google tax return"
possessives
:
false
,
// turn "batmobiles" into "batmobile"
plurals
:
false
,
// turn all verbs into Infinitive form - "I walked" → "I walk"
verbs
:
false
,
//turn 'Vice Admiral John Smith' to 'John Smith'
honorifics
:
false
,
}
}
Insert cell
Insert cell
Insert cell
nlp
(
'so... you like DONUTS? have all the donuts in the WORLD!!!'
)
.
normalize
(
{
nouns
:
true
}
)
.
out
(
)
Insert cell
nlp
(
'the so-called group of seven'
)
.
normalize
(
{
numbers
:
true
}
)
.
out
(
)
Insert cell
Insert cell
Insert cell
{
//get the wikipedia plaintext with wtf_wikipedia
let
text
=
await
wtf
.
fetch
(
article
)
.
then
(
doc
=>
doc
.
plaintext
(
)
)
//get all the nouns from the text
let
nouns
=
nlp
(
text
)
.
normalize
(
{
plurals
:
true
,
parentheses
:
true
,
possessives
:
true
,
honorifics
:
true
}
)
.
nouns
(
)
//sort them by frequency
return
JSON
.
stringify
(
nouns
.
out
(
'topk'
)
,
null
,
2
)
}
Insert cell
Insert cell
Insert cell
2
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.
Try it for free
Learn more
Fork
View
Export
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Show 5 comments
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
article
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
wtf
Edit
Show 2 comments
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
nlp
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
style
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML