dariusk/pos-js

Error: "Cannot call method IndexOf of undefined" in tag() with a dash.

harthur opened this issue · 3 comments

I'm lexing and tagging a sentence like "Android - constructor". It's failing with an error:

TypeError: Cannot call method 'indexOf' of undefined
    at startsWith (/Users/harth/repos/glossary/node_modules/pos/POSTagger.js:21:18)
    at POSTagger.tag (/Users/harth/repos/glossary/node_modules/pos/POSTagger.js:75:13)

It would be awesome if it would just skip over it.

Weirdly it seems like it's the word "constructor" that's the problem! I can insert dashes into other phrases and it works fine, and the word "constructor" on its own causes that error. Anyway, looking into it, thanks for the bug report.

Oh. At one point in the code it does a word lookup:

this.lexicon[word];

But if the word is "constructor" it grabs Object.prototype.constructor. Whoops. Fixing now.

Okay, I've pushed a fix and updated the npm package to 0.1.5. Thanks again, @harthur.