Last active
December 23, 2018 14:41
-
-
Save noahlange/779ae753b87bc3fffdc2c5c3b58e34d0 to your computer and use it in GitHub Desktop.
wink-pos-tagger: support for comparative adjectives
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (!pos) { | |
// may need to match either two or three characters (repeating consonants) | |
for (let c = 2; c <= 3; c++) { | |
// attempt to match | |
const match = (lexicon[word.slice(0, -c)] || [])[0]; | |
if (match) { | |
pos = | |
// adjectives: taller, shorter | |
match === 'JJ' | |
? 'JJR' | |
: // agent nouns: reader, miner; occupations: trumpeter, cricketer; demonyms: Londoner | |
match === 'VB' || match === 'NN' || match === 'NNP' | |
? 'NN' | |
: // no idea, probably a noun | |
pos; | |
} | |
if (pos) { | |
// bail early | |
break; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment