Compare commits
1 Commits
master
...
dependabot
Author | SHA1 | Date |
---|---|---|
dependabot[bot] | 965bd3c473 |
|
@ -1,10 +1,5 @@
|
||||||
|
|
||||||
|
**2.0.0**
|
||||||
2.1.0
|
|
||||||
- Fix CLI script when used without specific POS (#41)
|
|
||||||
- :boom: Stopwords are now case-insensitive, i.e., "The", "And", "Him", etc. are all filtered out.
|
|
||||||
|
|
||||||
2.0.0
|
|
||||||
- Support for running wordpos in the **browser** (no breaking change for node environment)
|
- Support for running wordpos in the **browser** (no breaking change for node environment)
|
||||||
- Dropped support for node 4.x.
|
- Dropped support for node 4.x.
|
||||||
|
|
||||||
|
|
|
@ -269,3 +269,4 @@ function sprint(results) {
|
||||||
},'');
|
},'');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "wordpos",
|
"name": "wordpos",
|
||||||
"version": "2.0.0-beta.11",
|
"version": "2.0.0",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
@ -7866,9 +7866,9 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"yargs-parser": {
|
"yargs-parser": {
|
||||||
"version": "15.0.0",
|
"version": "15.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-15.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-15.0.1.tgz",
|
||||||
"integrity": "sha512-xLTUnCMc4JhxrPEPUYD5IBR1mWCK/aT6+RJ/K29JY2y1vD+FhtgKK0AXRWvI262q3QSffAQuTouFIKUuHX89wQ==",
|
"integrity": "sha512-0OAMV2mAZQrs3FkNpDQcBk1x5HXb8X4twADss4S0Iuk+2dGnLOE/fRHrsYm542GduMveyA77OF4wrNJuanRCWw==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"camelcase": "^5.0.0",
|
"camelcase": "^5.0.0",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "wordpos",
|
"name": "wordpos",
|
||||||
"version": "2.1.0",
|
"version": "2.0.0",
|
||||||
"description": "wordpos is a set of part-of-speech utilities for Node.js & browser using the WordNet database.",
|
"description": "wordpos is a set of part-of-speech utilities for Node.js & browser using the WordNet database.",
|
||||||
"author": "Moos <mooster@42at.com>",
|
"author": "Moos <mooster@42at.com>",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
|
|
|
@ -160,12 +160,12 @@ function get(isFn) {
|
||||||
words = this.parse(text),
|
words = this.parse(text),
|
||||||
results = [],
|
results = [],
|
||||||
self = this,
|
self = this,
|
||||||
first = words[0];
|
first = words.shift();
|
||||||
|
|
||||||
// test one first & check for error, otherwise
|
// test one first & check for error, otherwise
|
||||||
// map is inoccuous to errors!
|
// map is inoccuous to errors!
|
||||||
return exec(first)
|
return exec(first)
|
||||||
.then(() => Promise.all(words.slice(1).map(exec)))
|
.then(() => Promise.all(words.map(exec)))
|
||||||
.then(done)
|
.then(done)
|
||||||
.catch(err => {
|
.catch(err => {
|
||||||
// done(); // callback signature is same! // FIXME
|
// done(); // callback signature is same! // FIXME
|
||||||
|
@ -224,13 +224,13 @@ function getPOS(text, callback) {
|
||||||
var args = [data];
|
var args = [data];
|
||||||
var matches = uniq(flat(Object.values(data)));
|
var matches = uniq(flat(Object.values(data)));
|
||||||
data.rest = diff(words, matches);
|
data.rest = diff(words, matches);
|
||||||
|
|
||||||
profile && args.push(new Date() - start);
|
profile && args.push(new Date() - start);
|
||||||
nextTick(callback, args);
|
nextTick(callback, args);
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
function error(err) {
|
function error(err) {
|
||||||
console.log('Error >>> ', err);
|
|
||||||
nextTick(callback, []);
|
nextTick(callback, []);
|
||||||
throw err;
|
throw err;
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,7 @@ function normalize(word) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function isStopword(stopwordsStr, word) {
|
function isStopword(stopwordsStr, word) {
|
||||||
return stopwordsStr.indexOf(' '+ word.toLowerCase() +' ') >= 0;
|
return stopwordsStr.indexOf(' '+word+' ') >= 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
function tokenizer(str) {
|
function tokenizer(str) {
|
||||||
|
|
171
test/cli_test.js
171
test/cli_test.js
|
@ -1,171 +0,0 @@
|
||||||
/**
|
|
||||||
* cli_test.js
|
|
||||||
*
|
|
||||||
* Test CLI script
|
|
||||||
*
|
|
||||||
* Copyright (c) 2012-2020 mooster@42at.com
|
|
||||||
* https://github.com/moos/wordpos
|
|
||||||
*
|
|
||||||
* Released under MIT license
|
|
||||||
*/
|
|
||||||
|
|
||||||
var
|
|
||||||
chai = require('chai'),
|
|
||||||
assert = chai.assert,
|
|
||||||
exec = require('child_process').exec,
|
|
||||||
testStr = 'The angry bear chased the frightened little squirrel',
|
|
||||||
cmd = 'node ' + __dirname + '/../bin/wordpos-cli ',
|
|
||||||
gDone;
|
|
||||||
|
|
||||||
// compare two list of words independent of word order
|
|
||||||
function cmp(act, exp) {
|
|
||||||
assert.equal(act.trim().split(' ').sort().join(), exp.split(' ').sort().join());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
describe('CLI tests', function() {
|
|
||||||
this.slow(300);
|
|
||||||
|
|
||||||
describe('Test CLI get', function() {
|
|
||||||
it('should get nouns', done => {
|
|
||||||
exec(cmd + '-n -b get ' + testStr, (error, stdout) => {
|
|
||||||
assert.isNull(error);
|
|
||||||
cmp(stdout, 'bear chased squirrel little');
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should get adjectives', done => {
|
|
||||||
exec(cmd + '-a -b get ' + testStr, (error, stdout) => {
|
|
||||||
assert.isNull(error);
|
|
||||||
cmp(stdout, 'angry frightened little');
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should get verbs', done => {
|
|
||||||
exec(cmd + '-v -b get ' + testStr, (error, stdout) => {
|
|
||||||
assert.isNull(error);
|
|
||||||
cmp(stdout, 'bear');
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should get adverbs', done => {
|
|
||||||
exec(cmd + '-r -b get ' + testStr, (error, stdout) => {
|
|
||||||
assert.isNull(error);
|
|
||||||
cmp(stdout, 'little');
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should get POS', done => {
|
|
||||||
exec(cmd + '-b get ' + testStr, (error, stdout, stderr) => {
|
|
||||||
assert.isNull(error);
|
|
||||||
cmp(stdout, 'bear chased squirrel little \n' +
|
|
||||||
'angry frightened little \n' +
|
|
||||||
'bear \n' +
|
|
||||||
'little');
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should get POS (single word)', done => {
|
|
||||||
exec(cmd + '-b get angry', (error, stdout, stderr) => {
|
|
||||||
assert.isNull(error);
|
|
||||||
assert.equal(stdout.trim(), 'angry');
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should get counts', done => {
|
|
||||||
exec(cmd + '-b -c get ' + testStr, (error, stdout, stderr) => {
|
|
||||||
assert.isNull(error);
|
|
||||||
assert.equal(stdout.trim(), '4 3 1 1 6');
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('Test CLI def', function() {
|
|
||||||
it('should define word', done => {
|
|
||||||
exec(cmd + 'def angry', (error, stdout) => {
|
|
||||||
assert.isNull(error);
|
|
||||||
assert(stdout.trim().startsWith('angry (def)\n a: feeling or showing anger;'));
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('Test CLI syn', function() {
|
|
||||||
it('should get synonyms', done => {
|
|
||||||
exec(cmd + 'syn angry', (error, stdout) => {
|
|
||||||
assert.isNull(error);
|
|
||||||
assert(stdout.trim().startsWith('angry (syn)\n a: angry'));
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('Test CLI exp', function() {
|
|
||||||
it('should get exmpale', done => {
|
|
||||||
exec(cmd + 'exp angry', (error, stdout) => {
|
|
||||||
assert.isNull(error);
|
|
||||||
assert(stdout.trim().startsWith('angry (exp)\n a: "angry at the weather"'));
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('Test CLI seek', function() {
|
|
||||||
it('should seek by offset', done => {
|
|
||||||
exec(cmd + '-a seek 00114629', (error, stdout) => {
|
|
||||||
assert.isNull(error);
|
|
||||||
assert(/lemma/.test(stdout), 'found lemma');
|
|
||||||
assert(/angry/.test(stdout), 'found angry');
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('Test CLI rand', function() {
|
|
||||||
it('should get a random word', done => {
|
|
||||||
exec(cmd + 'rand', (error, stdout) => {
|
|
||||||
assert.isNull(error);
|
|
||||||
assert(stdout.length > 1, 'got answer')
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should get a random word starting with...', done => {
|
|
||||||
exec(cmd + '-b rand angr', (error, stdout) => {
|
|
||||||
assert.isNull(error);
|
|
||||||
assert.equal(stdout.substr(0,4), 'angr');
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('Test CLI parse', function() {
|
|
||||||
it('should parse input', done => {
|
|
||||||
exec(cmd + '-b parse ' + testStr, (error, stdout) => {
|
|
||||||
assert.isNull(error);
|
|
||||||
assert.equal(stdout.trim(), 'angry bear chased frightened little squirrel');
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('Test CLI stopwords', function() {
|
|
||||||
let WordPOS = require('../src/wordpos');
|
|
||||||
|
|
||||||
it('should list stopwords', done => {
|
|
||||||
exec(cmd + '-j stopwords ' + testStr, (error, stdout) => {
|
|
||||||
assert.isNull(error);
|
|
||||||
assert.equal(stdout.trim(), JSON.stringify(WordPOS.stopwords));
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
});
|
|
|
@ -56,7 +56,7 @@ var str = "The angry bear chased the frightened little squirrel",
|
||||||
verbs: [ 'bear' ],
|
verbs: [ 'bear' ],
|
||||||
adjectives: [ 'little', 'angry', 'frightened' ],
|
adjectives: [ 'little', 'angry', 'frightened' ],
|
||||||
adverbs: [ 'little' ],
|
adverbs: [ 'little' ],
|
||||||
rest: []
|
rest: [ 'The' ]
|
||||||
},
|
},
|
||||||
garble = 'garblegarble', // expect not to find word
|
garble = 'garblegarble', // expect not to find word
|
||||||
offset = 1285602;
|
offset = 1285602;
|
||||||
|
|
Loading…
Reference in New Issue