Public
Edited
Nov 9, 2022
1 fork
4 stars
Insert cell
Insert cell
Insert cell
Insert cell
nlp('John eats glue!').match('john').text()
Insert cell
Insert cell
nlp('John eats glue').match('john eats #Noun').text()
Insert cell
Insert cell
nlp('John eats glue').match('john . glue').text()
Insert cell
Insert cell
nlp('John always ravenously eats his glue').match('john * eats').text()
Insert cell
Insert cell
nlp('he is really, really good').match('#Adverb+ good').terms().text()
Insert cell
Insert cell
nlp('John eats glue').match('john always? eats glue').text()
Insert cell
Insert cell
nlp('John eats glue').match('john (eats|sniffs|wears) .').text()
Insert cell
Insert cell
nlp('it is raining and had rained').match('#Verb /rain[ing|ed]/').text()
Insert cell
Insert cell
Insert cell
nlp('five maids a-milking.').match('[<num>#Value] maids a milking').text()
Insert cell
nlp('i saw ralf eat the glue, Mrs Hoover.').match('[<act>#Verb the #Noun]').groups()
Insert cell
Insert cell
{
let doc = nlp(`If you can't find metal stucco lath... Use carbon-fiber stucco lath!`)
let m = doc.match('#Verb [.{1,2}] stucco lath')
return m.groups(0).out('array')
}
Insert cell
Insert cell
{
let doc = nlp('that leaves 5 in the bank, and 80 hundred we need')
let m = doc.match('[<have>#Value+] in the bank and [<need>#Value+] we need')
return m.groups()
}
Insert cell
md`
if you want to quickly return the group, and ignore the rest, throw the name in the 2nd param:
`
Insert cell
nlp('turn left and slay the dragon').match('turn [.]',0).text()
Insert cell
Insert cell
nlp('John eats glue').match('^john #Verb').out('text')
Insert cell
nlp('John eats glue').match('eats glue$').terms().out('array')
Insert cell
Insert cell
nlp('Homer Simpson and Homer Adkins').match('homer !simpson').text()
Insert cell
Insert cell
nlp('one two three').match('one !foo? two').text()
Insert cell
nlp('this is tricky.').match('this is !not? #Adjective').text()
Insert cell
Insert cell
nlp('homer j j j j simpson').match('homer #Acronym{2,6} simpson').text()
Insert cell
Insert cell
nlp(`funny story`).match('/nny$/').out() //suffix lookup
Insert cell
nlp('Why all the pearls? Why all the hair?').match('/ear/').text() //'infix' lookup
Insert cell
Insert cell
nlp(`Homer J. Simpson`).match('#Person').match('#Acronym').text()
Insert cell
Insert cell
nlp(`Homer J. Simpson`).match('(#Person && #Acronym)').text()
Insert cell
Insert cell
Insert cell
nlp(`we're not gonna take it. No! We're not gonna take it.`).match('@hasExclamation').text()
Insert cell
Insert cell
nlp(`we're not gonna take it. No!`).match('(@hasContraction|@isTitleCase)+').out('array')
Insert cell
Insert cell
{
let doc = nlp("I'm looking for Amanda Hugginkiss")
// cache the root form of each word
doc.compute('root')
// use a 'soft' lookup:
let m = doc.match('{look} for')
// print our result:
return m.text()
}
Insert cell
Insert cell
nlp('Albuquerque Holiday Inn').match('~albequerque~').text()
Insert cell
Insert cell
{
let doc = nlp('my son is also named bort')
return doc.match('~bart~', null, {fuzzy:0.7}).text()
}
Insert cell
Insert cell
{
let json=[
{choices:[{word:'bort'}, {tag:'MaleName'}]},
{word:'license'},
{word:'plates', optional:true}
]
return nlp(`Repeat, we are sold out of Bort license plates.`).match(json).text()
}
Insert cell
Insert cell
nlp.parseMatch('we (walked|talked) in? #Month')
Insert cell
Insert cell
Insert cell
Insert cell
nlp.version
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