moos / wordpos

Part-of-speech utilities for node.js based on the WordNet database.
478 stars 41 forks source link

throw error when rand #24

Closed futurist closed 6 years ago

futurist commented 6 years ago

Throw error when run below code (v1.1.5)

wordpos.rand({count: 3}, console.log)

The error is below:

/Users/pro/github/wordbot/node_modules/_wordpos@1.1.5@wordpos/lib/natural/trie/trie.js:62
    return next.addString(string.substring(1));
                                 ^

TypeError: string.substring is not a function
    at Trie.addString (/Users/pro/github/wordbot/node_modules/_wordpos@1.1.5@wordpos/lib/natural/trie/trie.js:62:31)
    at Trie.addStrings (/Users/pro/github/wordbot/node_modules/_wordpos@1.1.5@wordpos/lib/natural/trie/trie.js:70:8)
    at collector (/Users/pro/github/wordbot/node_modules/_wordpos@1.1.5@wordpos/src/rand.js:145:14)
    at piper.wrapper (/Users/pro/github/wordbot/node_modules/_wordpos@1.1.5@wordpos/src/piper.js:67:14)
    at executeBound (/Users/pro/github/wordbot/node_modules/_underscore@1.8.3@underscore/underscore.js:701:67)
    at bound (/Users/pro/github/wordbot/node_modules/_underscore@1.8.3@underscore/underscore.js:733:14)
    at /Users/pro/github/wordbot/node_modules/_wordpos@1.1.5@wordpos/src/indexFile.js:88:6
    at FSReqWrap.wrapper [as oncomplete] (fs.js:629:17)
moos commented 6 years ago

@futurist I'm not able to reproduce. Are you able to reproduce consistently? If so, you might try putting a console.log at that location to see what string is.

What version of node/npm are you running?