Skip to content

Commit 710c66d

Browse files
chore(*): add runkit example
closes #18
1 parent f5aaa66 commit 710c66d

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,5 +48,6 @@
4848
"nyc": "^15.1.0",
4949
"mocha": "^8.2.1"
5050
},
51+
"runkitExampleFilename": "./runkit-example.js",
5152
"dependencies": {}
5253
}

runkit-example.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
const winkNLP = require( 'wink-nlp' );
2+
const its = require( 'wink-nlp/src/its.js' );
3+
// Use web model for RunKit.
4+
const model = require( 'wink-eng-lite-web-model' );
5+
const nlp = winkNLP( model );
6+
7+
const text = 'Its quarterly profits jumped 76% to $1.13 billion for the three months to December, from $639million of previous year.';
8+
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.
14+
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 );

0 commit comments

Comments
 (0)