gramophone
Advanced tools
Comparing version 0.0.2 to 0.0.3
19
index.js
@@ -97,4 +97,19 @@ var _ = require('lodash'); | ||
// Return results with scores or without depending on options | ||
combined = options.score ? combined : _.pluck(combined, 'term'); | ||
if (options.flatten){ | ||
// Flatten the results so that there is a list item for every occurence of | ||
// the term | ||
combined = _.flatten( | ||
_.map(combined, function(result){ | ||
var flattened = []; | ||
for (var i=0; i < result.tf; i++){ | ||
flattened.push(result.term); | ||
} | ||
return flattened; | ||
}) | ||
); | ||
}else{ | ||
// Return results with scores or without depending on options | ||
combined = options.score ? combined : _.pluck(combined, 'term'); | ||
} | ||
@@ -101,0 +116,0 @@ // Limit the results |
{ | ||
"name": "gramophone", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"main": "index.js", | ||
@@ -13,3 +13,3 @@ "description": "extracts most frequently used keywords and phrases from text", | ||
"scripts": { | ||
"test": "./node_modules/.bin/tap test" | ||
"test": "./node_modules/.bin/tap test/*" | ||
}, | ||
@@ -16,0 +16,0 @@ "license": "MIT", |
@@ -65,2 +65,13 @@ Gramophone | ||
#### Option: flatten | ||
Returns all occurrences of the ngram. Useful for passing data to Natural's | ||
TF-IDF function. Note: the original order is not maintained. Off by default. | ||
```js | ||
keyword.extract('beep beep and foo bar and beep beep and beep beep and foo bar', {flaten: true}) | ||
``` | ||
Returns `['beep beep', 'beep beep', 'beep beep', 'foo bar', 'foo bar']`. | ||
#### Option: html | ||
@@ -67,0 +78,0 @@ |
27782
13
403
202