[Question] Can winkjs expand contractions and abbreviations ? #58
Answered
by
sanjayaksaxena
searleser97
asked this question in
Help on coding
-
I see from the documentation that we can detect whether a token is a contraction or an abbreviation, but, Is there a way to expand either of them? |
Beta Was this translation helpful? Give feedback.
Answered by
sanjayaksaxena
Sep 30, 2021
Replies: 1 comment
-
Contractions are automatically expanded, when you access the const winkNLP = require( 'wink-nlp' );
const its = require( 'wink-nlp/src/its.js' );
// Use web model for RunKit.
const model = require( 'wink-eng-lite-web-model' );
const nlp = winkNLP( model );
const text = `I couldn't eat.`;
const doc = nlp.readDoc( text );
// Print tokens.
console.log( doc.tokens().out() );
// -> ["I", "could", "n't", "eat", "."]
console.log( doc.tokens().out( its.contractionFlag ) );
// -> [false, true, true, false, false]
console.log( doc.tokens().out( its.normal ) );
// -> ["i", "could", "not", "eat", "."]
// Notice the expanded form. Abbreviations are only detected and are not expanded. You may like to use JS Object to maintain a table of expanded forms. |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
sanjayaksaxena
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Contractions are automatically expanded, when you access the
normal
:Abbreviations are only detected and are not expanded. You may…