Skip to content

Commit 90f978a

Browse files
chore: update example in runkit and readme
1 parent a074952 commit 90f978a

File tree

2 files changed

+36
-27
lines changed

2 files changed

+36
-27
lines changed

README.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -69,33 +69,33 @@ If you’re using winkNLP in the browser use the [wink-eng-lite-web-model](https
6969
The "Hello World!" in winkNLP is given below:
7070

7171
```javascript
72-
// Load wink-nlp package & helpers.
72+
// Load wink-nlp package.
7373
const winkNLP = require( 'wink-nlp' );
74-
// Load "its" helper to extract item properties.
75-
const its = require( 'wink-nlp/src/its.js' );
76-
// Load "as" reducer helper to reduce a collection.
77-
const as = require( 'wink-nlp/src/as.js' );
78-
// Load english language model — light version.
79-
const model = require( 'wink-eng-lite-model' );
74+
// Load english language model.
75+
const model = require( 'wink-eng-lite-web-model' );
8076
// Instantiate winkNLP.
8177
const nlp = winkNLP( model );
82-
78+
// Obtain "its" helper to extract item properties.
79+
const its = nlp.its;
80+
// Obtain "as" reducer helper to reduce a collection.
81+
const as = nlp.as;
82+
8383
// NLP Code.
8484
const text = 'Hello World🌎! How are you?';
8585
const doc = nlp.readDoc( text );
86-
86+
8787
console.log( doc.out() );
8888
// -> Hello World🌎! How are you?
89-
89+
9090
console.log( doc.sentences().out() );
9191
// -> [ 'Hello World🌎!', 'How are you?' ]
92-
92+
9393
console.log( doc.entities().out( its.detail ) );
9494
// -> [ { value: '🌎', type: 'EMOJI' } ]
95-
95+
9696
console.log( doc.tokens().out() );
9797
// -> [ 'Hello', 'World', '🌎', '!', 'How', 'are', 'you', '?' ]
98-
98+
9999
console.log( doc.tokens().out( its.type, as.freqTable ) );
100100
// -> [ [ 'word', 5 ], [ 'punctuation', 2 ], [ 'emoji', 1 ] ]
101101
```

runkit-example.js

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,29 @@
1+
// Load wink-nlp package.
12
const winkNLP = require( 'wink-nlp' );
2-
const its = require( 'wink-nlp/src/its.js' );
3-
// Use web model for RunKit.
3+
// Load english language model — light version.
44
const model = require( 'wink-eng-lite-web-model' );
5+
// Instantiate winkNLP.
56
const nlp = winkNLP( model );
7+
// Obtain "its" helper to extract item properties.
8+
const its = nlp.its;
9+
// Obtain "as" reducer helper to reduce a collection.
10+
const as = nlp.as;
611

7-
const text = 'Its quarterly profits jumped 76% to $1.13 billion for the three months to December, from $639million of previous year.';
12+
// NLP Code.
13+
const text = 'Hello World🌎! How are you?';
814
const doc = nlp.readDoc( text );
9-
// Print tokens.
10-
console.log( doc.tokens().out() );
11-
// Print each token's type.
12-
console.log( doc.tokens().out( its.type ) );
13-
// Print details of each entity.
15+
16+
console.log( doc.out() );
17+
// -> Hello World🌎! How are you?
18+
19+
console.log( doc.sentences().out() );
20+
// -> [ 'Hello World🌎!', 'How are you?' ]
21+
1422
console.log( doc.entities().out( its.detail ) );
15-
// Markup entities along with their type for highlighting them in the text.
16-
doc.entities().each( ( e ) => {
17-
e.markup( '<mark>', `<sub style="font-weight:900"> ${e.out(its.type)}</sub></mark>` );
18-
} );
19-
// Render them as HTML via RunKit
20-
doc.out( its.markedUpText );
23+
// -> [ { value: '🌎', type: 'EMOJI' } ]
24+
25+
console.log( doc.tokens().out() );
26+
// -> [ 'Hello', 'World', '🌎', '!', 'How', 'are', 'you', '?' ]
27+
28+
console.log( doc.tokens().out( its.type, as.freqTable ) );
29+
// -> [ [ 'word', 5 ], [ 'punctuation', 2 ], [ 'emoji', 1 ] ]

0 commit comments

Comments
 (0)