Skip to content

Commit ec221a2

Browse files
docs(README): update getting started example
1 parent d0c5b12 commit ec221a2

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

README.md

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,27 +43,35 @@ node -e "require( 'wink-nlp/models/install' )" wink-eng-lite-model
4343
The "Hello World!" in winkNLP is given below. As the next step, we recommend a dive into [winkNLP's concepts](https://winkjs.org/wink-nlp/getting-started.html).
4444

4545
```javascript
46-
// Boilerplate Code.
47-
// Load wink-nlp package.
48-
var winkNLP = require( 'wink-nlp' );
46+
// Load wink-nlp package & helpers.
47+
const winkNLP = require( 'wink-nlp' );
4948
// Load "its" helper to extract item properties.
5049
const its = require( 'wink-nlp/src/its.js' );
50+
// Load "as" reducer helper to reduce a collection.
51+
const as = require( 'wink-nlp/src/as.js' );
5152
// Load english language model — light version.
52-
var model = require( 'wink-eng-lite-model' );
53+
const model = require( 'wink-eng-lite-model' );
5354
// Instantiate winkNLP.
54-
var nlp = winkNLP( model );
55+
const nlp = winkNLP( model );
5556

5657
// NLP Code.
57-
var text = 'Hello World🌎! How are you?';
58-
var doc = nlp.readDoc( text );
58+
const text = 'Hello World🌎! How are you?';
59+
const doc = nlp.readDoc( text );
60+
5961
console.log( doc.out() );
6062
// -> Hello World🌎! How are you?
63+
6164
console.log( doc.sentences().out() );
6265
// -> [ 'Hello World🌎!', 'How are you?' ]
66+
6367
console.log( doc.entities().out( its.detail ) );
6468
// -> [ { value: '🌎', type: 'EMOJI' } ]
69+
6570
console.log( doc.tokens().out() );
6671
// -> [ 'Hello', 'World', '🌎', '!', 'How', 'are', 'you', '?' ]
72+
73+
console.log( doc.tokens().out( its.type, as.freqTable ) );
74+
// -> [ [ 'word', 5 ], [ 'punctuation', 2 ], [ 'emoji', 1 ] ]
6775
```
6876

6977

0 commit comments

Comments
 (0)