Skip to content

[Question] Can winkjs expand contractions and abbreviations ? #58

Discussion options

You must be logged in to vote

Contractions are automatically expanded, when you access the normal:

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…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by sanjayaksaxena
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #57 on September 30, 2021 17:19.