Platform
Resources
Pricing
Sign in
Contact us
spencer kelly
freelance javascripter
Workspace
Fork
Public
nlp-compromise
By
spencer kelly
Edited
Nov 9, 2023
2 stars
Insert cell
2
Insert cell
Insert cell
nlp
(
input
)
.
ngrams
(
{
min
:
2
}
)
//sequences with at least 2 terms
Insert cell
2
Insert cell
Insert cell
{
const
r
=
nlp
(
'one two three. One two. Three four.'
)
return
r
.
ngrams
(
)
}
Insert cell
Insert cell
{
const
r
=
nlp
(
'one two three. One two. Three four.'
)
return
r
.
unigrams
(
)
}
Insert cell
Insert cell
{
const
r
=
nlp
(
'one two three. One two. Three four.'
)
return
r
.
bigrams
(
)
}
Insert cell
Insert cell
{
const
r
=
nlp
(
'one two three. One two. Three four.'
)
return
r
.
trigrams
(
)
}
Insert cell
Insert cell
{
const
r
=
nlp
(
'one two three. One two. Three four.'
)
return
r
.
startgrams
(
)
}
Insert cell
Insert cell
{
const
r
=
nlp
(
'one two three. One two. Three four.'
)
return
r
.
endgrams
(
)
}
Insert cell
Insert cell
{
const
r
=
nlp
(
'one two three. One two. Three four.'
)
return
r
.
edgegrams
(
)
}
Insert cell
Insert cell
{
let
doc
=
nlp
(
`Bubba, the owner of bubba's shrip.`
)
doc
.
normalize
(
{
possessives
:
true
,
}
)
return
doc
.
ngrams
(
)
}
Insert cell
Insert cell
{
let
doc
=
nlp
(
'He played (briefly) one year in Toronto, then suddenly played 1 year in Los Angeles.'
)
doc
.
remove
(
'#Adverb'
)
// remove 'suddenly'
doc
.
parentheses
(
)
.
remove
(
)
// remove '(briefly)'
// once compromise-numbers is installed...
//doc.numbers().toNumber() // 'one' -> '1'
doc
.
splitAfter
(
'@hasComma'
)
// avoid 'Toronto then' gram
return
doc
.
ngrams
(
{
size
:
2
}
)
}
Insert cell
Insert cell
Insert cell
nlp
=
{
let
nlp
=
await
require
(
'compromise'
)
let
plugin
=
await
require
(
'compromise-stats/builds/compromise-stats.min.js'
)
nlp
.
extend
(
plugin
)
return
nlp
}
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
Show 2 comments
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
input
Edit
Pin
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Show 2 comments
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
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
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
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
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
style
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
nlp
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