gramophone
Advanced tools
Comparing version 0.0.1 to 0.0.2
14
index.js
@@ -20,4 +20,6 @@ var _ = require('lodash'); | ||
var stem = natural.PorterStemmer.stem(word); | ||
if (!unstemmed.hasOwnProperty(stem)) unstemmed[stem] = []; | ||
unstemmed[stem].push(word); | ||
// Store the shortest word that matches this stem for later destemming | ||
if (!unstemmed.hasOwnProperty(stem) || word.length < unstemmed[stem].length){ | ||
unstemmed[stem] = word; | ||
} | ||
return stem; | ||
@@ -27,9 +29,3 @@ }; | ||
var destem = function(stem){ | ||
// Find the most frequent word associated with this stem and return it | ||
return _.chain(unstemmed[stem]) | ||
.groupBy() | ||
.values() | ||
.sortBy('length') | ||
.last() | ||
.value()[0]; | ||
return unstemmed[stem]; | ||
}; | ||
@@ -36,0 +32,0 @@ |
{ | ||
"name": "gramophone", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"main": "index.js", | ||
@@ -5,0 +5,0 @@ "description": "extracts most frequently used keywords and phrases from text", |
@@ -18,4 +18,4 @@ Gramophone | ||
``` | ||
readable-stream | ||
writable-stream | ||
readable stream | ||
writable stream | ||
``` | ||
@@ -103,3 +103,2 @@ | ||
```js | ||
// Only return 2 and 3 word length phrases | ||
keyword.extract('foo et bar et foo et bar et foo', {stopWords: ['et']}) | ||
@@ -115,3 +114,2 @@ ``` | ||
```js | ||
// Only return 2 and 3 word length phrases | ||
keyword.extract('foo and bar with foo and bar', {startWords: ['and']}) | ||
@@ -118,0 +116,0 @@ ``` |
26069
363
191