Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
harthur opened this issue Mar 12, 2014 · 3 comments
Closed

Comments

@harthur
Copy link

harthur commented Mar 12, 2014

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.

@dariusk
Copy link
Owner

dariusk commented Mar 12, 2014

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.

@dariusk
Copy link
Owner

dariusk commented Mar 12, 2014

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.

dariusk added a commit that referenced this issue Mar 12, 2014
Fixes issue #1, where tagging of a string with the word "constructor" in
it causes an error. We now check to see if the word is `undefined` *or*
if it's a function from up the prototype chain.
@dariusk
Copy link
Owner

dariusk commented Mar 12, 2014

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants