readDoc()
readDoc(text) → { winkNLP doc }
This is the core API in winkNLP that transforms the input text string into a winkNLP doc, which is made of tokens along with sentences and entities. It is the centerpiece of your code. Make sure you have an instantiated winkNLP before running readDoc
.
readDoc()
accepts any text or variable in a JavaScript string format as its parameter.
There are many ways to read the input text:
- Reading a text file from local disk or drive
- Store text in a separate variable and use the variable as a parameter to
readDoc()
- Directly add text as a parameter to
readDoc()
API
The input text could be a word, a phrase, a sentence or more than one sentence.
Example:
// Read text from variable
const text = 'I work for AI Inc.';
const doc = nlp.readDoc(text);
// Read text as string
const doc = nlp.readDoc('I work for AI Inc.');
// Read text from file
const fs = require('fs');
text = fs.readFileSync('../sampleText.txt', 'utf8');
const doc = nlp.readDoc(text);