moos / wordpos Goto Github PK
View Code? Open in Web Editor NEWPart-of-speech utilities for node.js based on the WordNet database.
Part-of-speech utilities for node.js based on the WordNet database.
Is there any way to get some random word ?
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.
I have noticed the following behaviour trying to install wordpos with yarn.
During the first install
wordnet-db
fast indexDuring a consecutive, yarn
thing get messy
wordnet-db
folder changed and reset it to his original state. However, as wordpos
is still the same, his postinstall script isn't call.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
Hi,
Is there a version able to parse french or a way to inject an equivalent of wordnet-db such as WoNeF ?
Thanks :)
I want to get POS where there are name of person etc..NNP.
They fall into the proper nouns category.
Have received the above message in console when I try to run it in a server side environment.
Any assistance is much appreciated!
Will there be a Deno version of this coming soon?
Hi there, i'm trying to import wordpos in a react project and I'm not sure that I'm doing it the right and and getting this error. ReferenceError: ES6_IMPORT is not defined
,
link to file in your repo
Please can you tell me the exact way to use it with ES6
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.
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?
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.
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)
`
I can't import this in my Angular project, the import fails.
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.
For stable I mean, is it still working with the latest WordNet updates?
Does the npm install downloads the most recent version of WordNet?
Thanks in advance.
Not sure if you've had to work on this @moos but curious if you or others have figured out support for multiple locales/langs.
If only there were types ๐
I get this error when using cli with following command:
wordpos get over
Not sure if it's an issue progmatically aswell
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.
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?
> [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:\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?
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?
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 +, ~, $ ...)
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)
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));
^
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'
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.
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!
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.
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!
Hi,
Is it possible to add support for noun phrases ?
Thanks!
doesnt work? could you add that to the docs please
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)
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
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)
.
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)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.