#new v7 API proposal! :heart::heart::heart:
nlp('', {}).to(myTransform).render(myOutput)
nlp('This is experimental.', {}).to('Exclamation').render('Text')
nlp('washing machine', {}).to('Noun').to('Plural').render('Html')
nlp("It's really good ", {}).to('PastTense').to('StripAdverbs').render('Normalized')
nlp("two tbsp of sugar", {}).info('Values')[0].unit
###Reasoning:
- clears-up immutable/mutable ambiguity
- requires less working knowledge of internals
- supports no-install 'first-class' scripting/plugins
- less-surprising return values
- avoids re-parsing problems in pos-specific methods like
nlp.value()
###no more nlp.person(), nlp.value()...
every input will now be pos-tagged, and automatically supplied the appropriate methods of each term.
- if you don't trust this, you can co-erce the POS:
nlp('john is cool').to('Noun').to('plural').render('text')
- some conditional logic for applying appropriate transformation, like
nlp('doctor').to('plural').render('text')
nlp('we went to the doctor to visit.').to('plural').render('text')
#API
##Change/Transform .render()
nlp('john is cool').render('PastTense');
nlp('john is cool').render('Question');
nlp('john is cool').render(myTransform);
They alone should transform/mutate the state. These methods all return this
.
##Query .info()
nlp('john is cool').info(ngramsFn);
nlp('john is cool').info('verbs');
nlp('john is cool').info('people');
##Yes/No info .is()
nlp('john is cool').is('Question');
nlp('kick').is('Verb');
nlp('oh, great new api.').is(mySarcasmDetector);
##Match/subset-lookup .match()
nlp('john is cool and jane is nice').match('[Person] is');
not sure how to handle, and represent these subsets of sentences
##Conditional transforms? .if()
like .is()
. but somehow disables subsequent transformations
nlp('john is cool').if('Statement').to('Negative');
nlp('john is cool').if('Copula').to('PastTense');
##rendering, return, output .render()
nlp('John is cool').render('normal');
nlp('John is cool').render('text');
nlp('John is cool').render('html');
nlp('John is cool').render('json');
nlp('John is cool').render(myFunction);