Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

68 Commits

Repository files navigation

en-pos

A better English POS tagger written in JavaScript

Installation and usage

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 Specification

AnnotationNameExample
NNNoundogman
NNSPlural noundogsmen
NNPProper nounLondonAlex
NNPSPlural proper nounSmiths
VBBase form verbbe
VBPPresent form verbthrow
VBZPresent form (3rd person)throws
VBGGerund form verbthrowing
VBDPast tense verbthrew
VBNPast participle verbthrown
MDModal verbcanshallwillmaymustought
JJAdjectivebigfast
JJRComparative adjectivebigger
JJSSuperlative adjectivebiggest
RBAdverbnotquicklyclosely
RBRComparative adverbless-closelyfaster
RBSSuperlative adverbfastest
DTDeterminertheasomeboth
PDTPredeterminerallquite
PRPPersonal PronounIyouheshe
PRP$Possessive PronounIyouheshe
POSPossessive ending's
INPrepositionofbyin
PRParticleupoff
TOtoto
WDTWh-determinerwhichthatwhateverwhichever
WPWh-pronounwhowhoeverwhomwhat
WP$Wh-possessivewhose
WRBWh-adverbhowwhere
EXExpletive therethere
CCCoordinating conjugation&andnoror
CDCardinal Numbers1777one
LSList item marker1BCOne
UHInterjectionahohoops
FWForeign Wordsvivamontoujours
,Comma,
:Mid-sent punct:;...
.Sent-final punct..!?
(Left parenthesis)}]
)Right parenthesis({[
#Pound sign#
$Currency symbols$£¥
SYMOther symbols+*/<>
EMEmojis & emoticons:)

Accuracy and performance

TL:DR;

  • 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%).

Building from source and testing

  • Build: tsc (requires typescript)
  • Test: node test/test.ts

Credits

About

⚙️ [Processor] A better English POS tagger written in JavaScript

Topics

Resources

Stars

56 stars

Watchers

4 watching

Forks

Releases

Packages

Used by

Contributors

Languages