A better English POS tagger written in JavaScript
Install via NPM:
npm i --save en-pos
How to use
constTag=require("en-pos").Tag;vartags=newTag(["this","is","my","sentence"]).initial()// initial dictionary and pattern based tagging.smooth()// further context based smoothing.tags;console.log(tags);// ["DT","VBZ","PRP$","NN"]| Annotation | Name | Example |
|---|---|---|
NN | Noun | dogman |
NNS | Plural noun | dogsmen |
NNP | Proper noun | LondonAlex |
NNPS | Plural proper noun | Smiths |
VB | Base form verb | be |
VBP | Present form verb | throw |
VBZ | Present form (3rd person) | throws |
VBG | Gerund form verb | throwing |
VBD | Past tense verb | threw |
VBN | Past participle verb | thrown |
MD | Modal verb | canshallwillmaymustought |
JJ | Adjective | bigfast |
JJR | Comparative adjective | bigger |
JJS | Superlative adjective | biggest |
RB | Adverb | notquicklyclosely |
RBR | Comparative adverb | less-closelyfaster |
RBS | Superlative adverb | fastest |
DT | Determiner | theasomeboth |
PDT | Predeterminer | allquite |
PRP | Personal Pronoun | Iyouheshe |
PRP$ | Possessive Pronoun | Iyouheshe |
POS | Possessive ending | 's |
IN | Preposition | ofbyin |
PR | Particle | upoff |
TO | to | to |
WDT | Wh-determiner | whichthatwhateverwhichever |
WP | Wh-pronoun | whowhoeverwhomwhat |
WP$ | Wh-possessive | whose |
WRB | Wh-adverb | howwhere |
EX | Expletive there | there |
CC | Coordinating conjugation | &andnoror |
CD | Cardinal Numbers | 1777one |
LS | List item marker | 1BCOne |
UH | Interjection | ahohoops |
FW | Foreign Words | vivamontoujours |
, | Comma | , |
: | Mid-sent punct | :;... |
. | Sent-final punct. | .!? |
( | Left parenthesis | )}] |
) | Right parenthesis | ({[ |
# | Pound sign | # |
$ | Currency symbols | $€£¥ |
SYM | Other symbols | +*/<> |
EM | Emojis & emoticons | :)❤ |
- When smoothing is enabled: 96.43% accuracy (processing 132K tokens in 38 seconds)
- When smoothing is disabled: 94.4% accuracy (processing 132K tokens in 3 seconds)
As of 25 Jan 2017, this library scored 96.43% at the Penn Treebank test (0.3% away from being a state of the art tagger).
Being written in JavaScript, I think it's safe to say that this is the most accurate JavaScript POS tagger, since the only JS library I know of is pos-js which when I tested on the same treebank scored 87.8%, though it was faster than my implementation when smoothing is enabled.
However, if performance is what's you're after rather than accuracy, then you have the option to disable smoothing in this library and this will marginally increase performance making this library even faster than pos-js but with far better accuracy (94.4%).
- Build:
tsc(requires typescript) - Test:
node test/test.ts
- This project is an optimization and (almost complete) re-writing of Compendium's POS tagger.
- Compendium's tagger itself was based on fasttag.
- Fasttag is based on Eric Brill's POS tagger.