Code Monkey home page Code Monkey logo

wordpos's Issues

Numbers recognized as adjectives

wordpos.isAdjective("17", function(bool) {
    console.log(bool); // true
});
wordpos.isAdjective("two", function(bool) {
    console.log(bool); // true
});

Why are numbers recognized as adjectives?

A lot of verbs are also classified as adjectives.

yarn install issue

I have noticed the following behaviour trying to install wordpos with yarn.

During the first install

  • the post install script is triggered, populating wordnet-db fast index

During a consecutive, yarn thing get messy

  • yarn see that the wordnet-db folder changed and reset it to his original state. However, as wordpos is still the same, his postinstall script isn't call.
  • At that point, wordpos can't no longer be used as missing the fast index.

Local package.json exists, but node_modules missing, did you mean to install?

I can't install wordpos, I tried to install again npm, doesn't help, also i can install every other npm module, just not wordpos. I have node modules, everything other is working.

npm install -g wordpos

[email protected] postinstall C:\Users\stulejka\Desktop\programowanie\testApp\node_modules\wordpos
npm run postinstall-web && npm run postinstall-node

[email protected] postinstall-web C:\Users\stulejka\Desktop\programowanie\testApp\node_modules\wordpos
node scripts/makeJsonDict.js index data

internal/modules/cjs/loader.js:584
throw err;
^

Error: Cannot find module 'C:\Users\stulejka\Desktop\programowanie\testApp\node_modules\wordpos\scripts\makeJsonDict.js'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:582:15)
at Function.Module._load (internal/modules/cjs/loader.js:508:25)
at Function.Module.runMain (internal/modules/cjs/loader.js:754:12)
at startup (internal/bootstrap/node.js:283:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] postinstall-web: node scripts/makeJsonDict.js index data
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] postinstall-web script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm WARN Local package.json exists, but node_modules missing, did you mean to install?

npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\stulejka\AppData\Roaming\npm-cache_logs\2019-05-29T16_05_21_877Z-debug.log
npm WARN [email protected] No description

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] postinstall: npm run postinstall-web && npm run postinstall-node
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\stulejka\AppData\Roaming\npm-cache_logs\2019-05-29T16_05_22_853Z-debug.log

French version?

Hi,
Is there a version able to parse french or a way to inject an equivalent of wordnet-db such as WoNeF ?
Thanks :)

how to get proper noun

I want to get POS where there are name of person etc..NNP.
They fall into the proper nouns category.

Deno support?

Will there be a Deno version of this coming soon?

fastIndex causes getPOS to not call the callback sometimes

Compare:

var
    WordPOS       = require('wordpos'),
    wordpos       = new WordPOS({fastIndex: true});

  getAllPOS('se', function(res) {
    getAllPOS('sea', function(res) {
      getAllPOS('sear', function(res) {
        console.log('all done');
      });
    });
  });

RESULT: last callback is never called!

With:

var
    WordPOS       = require('wordpos'),
    wordpos       = new WordPOS({fastIndex: false});

  getAllPOS('se', function(res) {
    getAllPOS('sea', function(res) {
      getAllPOS('sear', function(res) {
        console.log('all done');
      });
    });
  });

RESULT: works as expected, but is very slow.

retrieving nouns etc. from nondelimited text

I'd like to detect nouns and verbs etc. from domain names. For example:

americanexpress.com should return nouns such as "american", "express", "america", "can", and "press".

Is this possible?

Moreover, the obvious two main words in the above domain are "american" and "express", and not "america", "can", or "press". Do you think that it is possible to distinguish which words are the most important words?

DeprecationWarning: Calling an asynchronous function without callback is deprecated.

Using Node 7.2.1
The followoing results in the warning:
DeprecationWarning: Calling an asynchronous function without callback is deprecated.

const WordPOS = require('wordpos');
const wordpos = new WordPOS();
wordpos.getNouns(text).then((nouns) => {
    console.log(nouns)
})

Still works but it's annoying going through the logs and seeing this.

Postinstall fails

Didn't dig into details, here is the log:

`DB folder: /usr/local/lib/node_modules/wordpos/node_modules/wordnet-db/dict
index.adv buckets 1172, max 125 at in_, sum 4475, avg 3.82, median 2
fs.js:646
return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode);
^

Error: EACCES: permission denied, open '/usr/local/lib/node_modules/wordpos/node_modules/wordnet-db/dict/fast-index.adv.json'
at Object.fs.openSync (fs.js:646:18)
at Object.fs.writeFileSync (fs.js:1299:33)
at BufferedReader. (/usr/local/lib/node_modules/wordpos/tools/stat.js:151:10)
at emitNone (events.js:106:13)
at BufferedReader.emit (events.js:208:7)
at ReadStream. (/usr/local/lib/node_modules/wordpos/tools/buffered-reader.js:150:8)
at emitNone (events.js:111:20)
at ReadStream.emit (events.js:208:7)
at endReadableNT (_stream_readable.js:1064:12)
at _combinedTickCallback (internal/process/next_tick.js:138:11)
`

ReferenceError: Promise is not defined

On an Ubuntu VM running on Azure, I am getting this error:

ReferenceError: Promise is not defined at null.getNouns (/home/azureuser/node/XMLParser/node_modules/wordpos/src/wordpos.js:131:12)

When I debug with the node debugger, I can see that wordPOS and getNouns() are clearly there when instantiating like this:

var WordPOS = require('wordpos'); var wordpos = new WordPOS();

I have tried this code form:

`wordpos.getNouns(_content, function(result, err){
if(err){
console.log(err.message);
return;
}

  _item.tags = result;
});`

and this code form:
wordpos.getNouns(_content) .then(function(result){ _item.tags = result; }) .catch(function(err){ console.log('Error in backdoorsurvival: ' + err.message); });

with identical results.

This seems like its broken but I could be missing some key info - in which case I would appreciate your feedback.

Confusion on Output -- 'is' isn't a verb?

I know you don't have a ton of control over how the results are generated (i.e. comes from Natural and/or WordNet db), so don't know if this is the right place to talk about this. Basicall, using a very simple input sentence "the ball is red", I get the following output:

{ nouns: [ 'ball', 'red' ],
  verbs: [ 'ball' ],
  adjectives: [ 'red' ],
  adverbs: [],
  rest: [ 'is', 'the' ] }

I did a search on WordNet's site, and it does show "is" as a verb (after a few other entries that seem to be based on acronymns or whatever). Again, not sure if this is on wordpos or Natural or whatever, but figured I'd throw it out for you.

Words like "get" or "take" are throwing errors

Hello! I am trying to use this library to build a text adventure. Verbs like "get" and "take" are very integral to the game, but when I run them in a sentence through getPOS, they don't show up in any of the returned arrays. If I try to send them alone as a string:
wordpos.getPOS("take")
I get the following error:
TypeError: Cannot read property 'toLowerCase' of undefined at normalize (/Users/joshuadowns/Code/Personal/mern-text-adventure/node_modules/wordpos/src/util.js:32:15)

I've also tried running them through getVerbs() with the same errors. When I visit wordnet and run searches for the words, they come up as expected. Any ideas?

postinstall script fails with npm 5

> [email protected] postinstall /Users/user/devel/project/node_modules/wordpos
> node tools/stat.js --no-stats index.adv index.adj index.verb index.noun

fs.js:896
  return binding.readdir(pathModule._makeLong(path), options.encoding);
                 ^

Error: ENOENT: no such file or directory, scandir '/Users/user/devel/project/node_modules/wordpos/node_modules/wordnet-db/dict'
    at Object.fs.readdirSync (fs.js:896:18)
    at Object.<anonymous> (/Users/user/devel/project/node_modules/wordpos/node_modules/wordnet-db/index.js:4:31)
    at Module._compile (module.js:569:30)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:503:32)
    at tryModuleLoad (module.js:466:12)
    at Function.Module._load (module.js:458:3)
    at Module.require (module.js:513:17)
    at require (internal/module.js:11:18)

Unable to open c:\...\data.verb

Unable to open c:\dev\...\node_modules\WNdb\dict\data.verb
Unable to open c:\dev\...\node_modules\WNdb\dict\data.verb
Unable to open c:\dev\....\node_modules\WNdb\dict\data.noun
Unable to open c:\dev\....\node_modules\WNdb\dict\data.noun
Unable to open c:\dev\....\node_modules\WNdb\dict\data.noun
Unable to open c:\dev\....\node_modules\WNdb\dict\data.noun
Unable to open c:\dev\....\node_modules\WNdb\dict\data.noun
Unable to open c:\dev\....\node_modules\WNdb\dict\data.noun
Unable to open c:\dev\....\node_modules\WNdb\dict\data.verb
Unable to open c:\dev\...\node_modules\WNdb\dict\data.verb

Any suggestions on how to wait before doing the next word in the array?

incorrect results

I am running wordpos (v2.0.0) in a Node.js (v12.16.1 LTS) environment.

It seems like this library is returning unexpected results. The code below ...

const WordPOS = require('wordpos')
const wordpos = new WordPOS()

const text = 'The quick brown fox jumped over the lazy dog.'
const results = await wordpos.getPOS(text)
console.log(results)

returns the following (incorrect) result.

{
  nouns: [ 'quick', 'brown', 'fox', 'dog' ],
  verbs: [ 'brown', 'fox', 'dog' ],
  adjectives: [ 'quick', 'brown', 'lazy' ],
  adverbs: [ 'quick' ],
  rest: [ 'The', 'jumped', '' ]
}

I mean, obviously 'quick' and 'brown' are adjectives - not nouns. The verbs array [ 'brown', 'fox', 'dog' ] is filled with one adjective and two nouns and is missing the only verb 'jumped' in the sentence.

Am I missing something, or is there a big problem here?

EDIT: Do i need to tokenize and lemmatize the sentence first?

Getting synset details

Is it possible to get all the details for the word in one function call ?
What I mean with details is that when we look up a word in wordnet portal we can see synset details as antonym, torponym, hypernym, sister term etc. (even frequency counts)

One way to do it, if I am not wrong iterate over ptrs node and get details for the synset by Id.
In this case @ symbol is direct hypernym I guess. (and others +, ~, $ ...)

http://wordnetweb.princeton.edu/perl/webwn?o2=1&o0=1&o8=1&o1=1&o7=1&o5=1&o9=&o6=1&o3=1&o4=1&r=2&s=accept&i=15&h=00011010001101011223022220000000#c

yarn v2 found a bug: line.substring is not a function

TypeError: line.substring is not a function
at BufferedReader. (/home/vic/Documents/GitHub/mbCLIx/src/.yarn/unplugged/wordpos-npm-1.2.0-031b04010c/node_modules/wordpos/tools/stat.js:92:22)
at BufferedReader.emit (events.js:219:5)
at PassThrough. (/home/vic/Documents/GitHub/mbCLIx/src/.yarn/unplugged/wordpos-npm-1.2.0-031b04010c/node_modules/wordpos/tools/buffered-reader.js:148:10)
at PassThrough.emit (events.js:219:5)
at endReadableNT (_stream_readable.js:1206:12)
at processTicksAndRejections (internal/process/task_queues.js:84:21)
at runNextTicks (internal/process/task_queues.js:66:3)
at processImmediate (internal/timers.js:417:9)

This file contains the result of Yarn building a package (wordpos@npm:1.2.0)

Script name: postinstall

DB folder: /home/vic/Documents/GitHub/mbCLIx/src/.yarn/cache/wordnet-db-npm-3.1.14-62a7238db5-1.zip/node_modules/wordnet-db/dict
/home/vic/Documents/GitHub/mbCLIx/src/.yarn/unplugged/wordpos-npm-1.2.0-031b04010c/node_modules/wordpos/tools/stat.js:92
var key = line.substring(0, Math.min(line.indexOf(' '), KEY_LENGTH));
^

add lexical domain to result

as detailed here [https://github.com/Planeshifter/node-wordnet-magic#lexdomain],

The lexical domain of the synset. Each domain category is composed of the word type followed by a dot and then the category name. WordNet has implemented the following domain categories:

For example 'dance' gives lexdomain 'noun.act'

Cannot find module 'lapack' when bundling with Browserify

When including wordpos in my project and bundling via browserify, running the browserify command, I'm receiving this error:

Error: Cannot find module 'lapack' from '[PROJECT_ROOT]/node_modules/wordpos/node_modules/
natural/node_modules/sylvester/lib/node-sylvester'

and here's the browserify command I'm running from the command line:

browserify [PROJECT_ROOT]/js/main.js -o src/content/content.js`

My main.js file is probably as simple as you can get; all I have in there right now is literally this:

var WordPOS = require('wordpos');

I'm assuming that I'm setting my paths correctly, since the error message is resolving to one of the node_modules directories down the dependency chain. I'd be happy to provide more code samples if needed; I'm pretty new to the whole browserify/node-packages-in-the-browser thing, so it's entirely possible that I'm just missing a step.

getNouns() is not accurate

Thanks for this useful library! I noticed the getNouns() function is not accurate.

For example:

Please give this note to the man in the blue hat.

Returns the following nouns:

["give","note","man","blue","hat"]

It's true the word 'give' can sometimes be a noun, such as when a material has 'some give', but in this sentence, and 99% of the time, it's a verb.

Here's another simple example:

Can you ask her what time it is?

WordPos returns the following as nouns:

["Can","time"]

But of course a sentence starting with 'Can' does not refer to a metal container. And it skips the pronoun.

Would it be possible to improve the accuracy of getNouns()? I realize the answer might be no, as NLP like this is very hard.

Thanks!

random word methods appear to be inaccurate

Just discovered this module today, was playing with the random word methods and found that running randNoun() would often give me words that were not nouns. such as objectification or featheriness. No issues opened regarding it so I figured I should bring it up.

Mixing promises and callback code in wordpos

Firstly, thanks for the great library. The ~5x speed improvement of v1 is really helping us out a lot!

I wondered if I could get your advice on using straightforward callbacks in wordpos. I would like to just be able to do something like this:

const myFunction = (callback) => {
  wordpos.lookup(..., (results) => {
    callback(results);
  });
};

But sometimes my callback will throw an error, causing a Promise within wordpos to be rejected, and my callback is called again from wordpos, throwing another error, and then finally node hangs with a UnhandledPromiseRejectionWarning, which breaks our test suite as it was expecting a normal throw, but got nothing.

I would like the throw somewhere down the callback chain to bubble up and throw at the top-level. Is this just not possible with this library, given the use of Promises in it? I won't be able to convert all our code to use Promises as it is a monumental effort.

At the moment, I'm getting around this by doing something like:

let lookupDone = false;
let lookupResults = [];

wordpos.lookup(word).then((results) => {
  lookupDone = true;
  lookupResults = results;
});

const wait = function wait() {
  if (!lookupDone) {
    setTimeout(wait, 10);
  } else {
    // do stuff with results
  }
}
wait();

But obviously this is highly not ideal. I may simply be not understanding Promises right. Thanks in advance!

throw error when rand

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/[email protected]@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/[email protected]@wordpos/lib/natural/trie/trie.js:62:31)
    at Trie.addStrings (/Users/pro/github/wordbot/node_modules/[email protected]@wordpos/lib/natural/trie/trie.js:70:8)
    at collector (/Users/pro/github/wordbot/node_modules/[email protected]@wordpos/src/rand.js:145:14)
    at piper.wrapper (/Users/pro/github/wordbot/node_modules/[email protected]@wordpos/src/piper.js:67:14)
    at executeBound (/Users/pro/github/wordbot/node_modules/[email protected]@underscore/underscore.js:701:67)
    at bound (/Users/pro/github/wordbot/node_modules/[email protected]@underscore/underscore.js:733:14)
    at /Users/pro/github/wordbot/node_modules/[email protected]@wordpos/src/indexFile.js:88:6
    at FSReqWrap.wrapper [as oncomplete] (fs.js:629:17)

Random word with length N

First of all, thank you for the fantastic effort in developing and maintaining this library ๐Ÿ‘
I was wondering how I can query a random word of length 5. Is that possible?
I would like to query 4 number of random words of length a,b,c,d each? Any suggestions

Error thrown when `rand().then(console.log)`

In the process of writing the types (for Typescript, so people don't need to read a readme to use this) for this awesome library, I had to test every function and their combinations.

Node version:
8.9.4 (latest stable)

When running the following code:

wordpos.rand().then(console.log);

I get..

(node:99162) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): TypeError: Cannot set property 'count' of undefined
(node:99162) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

It does work when I run it with:
rand(console.log) or rand({}).then(console.log).

Broken npm install in nodejs v4.4.0

On node v4.4.0 on Ubuntu 14.04, if a project specifies wordpos as dependency, on running npm install it will wrongfully not install wordnet-db first, causing the error below. This does not happen on node v5.x. Tested the issue on both travis and server Ubuntu VMs.

The travis log is here. The VM log (same error) is below.

root@raw-test:~/aiva# npm i

> [email protected] postinstall /root/aiva/node_modules/wordpos
> node tools/stat.js --no-stats index.adv index.adj index.verb index.noun

fs.js:808
  return binding.readdir(pathModule._makeLong(path));
                 ^

Error: ENOENT: no such file or directory, scandir '/root/aiva/node_modules/wordnet-db/dict'
    at Error (native)
    at Object.fs.readdirSync (fs.js:808:18)
    at Object.<anonymous> (/root/aiva/node_modules/wordnet-db/index.js:4:31)
    at Module._compile (module.js:409:26)
    at Object.Module._extensions..js (module.js:416:10)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)
    at Module.require (module.js:353:17)
    at require (internal/module.js:12:17)
    at Object.<anonymous> (/root/aiva/node_modules/wordpos/src/wordpos.js:16:10) 

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.