How to use the natural.NounInflector function in natural

To help you get started, we’ve selected a few natural examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github kylestetz / Sentencer / index.js View on Github external
var natural = require('natural');
var nounInflector = new natural.NounInflector();
var articles = require('articles/lib/Articles.js');
var randy = require('randy');
var _ = require('lodash');

// ---------------------------------------------
//                  DEFAULTS
// ---------------------------------------------

function Sentencer() {
  var self = this;

  self._nouns      = require('./words/nouns.js');
  self._adjectives = require('./words/adjectives.js');

  self.actions = {
    noun: function() {
github NaturalNode / natural / examples / inflection / noun.js View on Github external
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/

var natural = require('natural'),
    nounInflector = new natural.NounInflector();

plural = nounInflector.pluralize('radius');
console.log(plural);

plural = nounInflector.pluralize('beer');
console.log(plural);

singular = nounInflector.singularize('radii');
console.log(singular);

singular = nounInflector.singularize('beers');
console.log(singular);
github SuperMarcus / pgoogle / index.js View on Github external
await status("Preparing obfuscator...");

    let dummy = d => d;
    let wnet = new WNet({
        dataDir: wnetdb.path
    });
    let tzr = (new natural.TreebankWordTokenizer()).tokenize;
    let isWord = /\w+/;

    let ntrBf = path.join(path.dirname(require.resolve("natural")), "brill_pos_tagger");
    let defaultCat = '?';

    let lex = new natural.Lexicon(ntrBf + "/data/English/lexicon_from_posjs.json", defaultCat);
    let rules = new natural.RuleSet(ntrBf + "/data/English/tr_from_posjs.txt");
    let tagger = new natural.BrillPOSTagger(lex, rules);
    let np = new natural.NounInflector();
    let pvp = new natural.PresentVerbInflector();
    let stmr = natural.PorterStemmer;

    let _accumunator = 0;
    let _total = 0;
    let _st = "";
    let _swp = (w) => ( isWord.test(w[0]) );
    let accumunator = (w) => {
        _accumunator += 1;
        stageHandler.onProgress(_accumunator, _total);
        return w;
    };
    let _stage = (l, s) => {
        _total = l;
        _st = s;
        _accumunator = 0;
github sysrep / time-viz / src / lib / nlpHelpers.js View on Github external
function getSingularizedWord (array) {
  const nounInfector = new natural.NounInflector();
  return array.map(token => nounInfector.singularize(token));
}
github blprnt / ArtArchive / Class6 / MARC_Network / index.js View on Github external
onParseFinished();
	}); 

}




//------------------CHECK FOR MATCHES FUNCTION ---------------------------------------------------------------------------!!
//This function checks any string (input) against any list of candidate strings (candidates)
//Uses NLP to split the sentence into words and also to stem
var tokenizer = new natural.TreebankWordTokenizer();
//Used to singularize the words so that frogs matches frog. Wether or not you have to do this will depend on what data you're trying to match.
//For example if it's something *already* standardized (ie. Subjects) you won't have to. 
//This function is SLOW if there are a lot of words to check against 
var nounInflector = new natural.NounInflector();

function checkForMatches(input, candidates) {

	//Tokenize the record (break it into words)
	var words = [tokenizer.tokenize(input)][0];

	//Set up our return object, this is the state that is returned with no matches
	var chk = {chk:false, words:[]};
	
	for (var i = 0; i < candidates.length; i++) {
		var cand = nounInflector.singularize(candidates[i].toLowerCase());
		for (var j = 0; j < words.length; j++) {
			if (nounInflector.singularize(words[j].toLowerCase()) == cand) {
				chk.chk = true;
				chk.words.push(candidates[i]);
			}
github harthur / glossary / glossary.js View on Github external
var _ = require("underscore"),
    pos = require("pos"),
    natural = require("natural"),
    inflector = new natural.NounInflector();

function normalize(word) {
   return inflector.singularize(word);
}

function Glossary(opts) {
   this.opts = _(opts || {}).defaults({
      minFreq: 1,
      collapse: false,
      blacklist: [],
      verbose: false
   });
}

Glossary.prototype.extract = function(text) {
   var words = new pos.Lexer().lex(text);

natural

General natural language (tokenizing, stemming (English, Russian, Spanish), part-of-speech tagging, sentiment analysis, classification, inflection, phonetics, tfidf, WordNet, jaro-winkler, Levenshtein distance, Dice's Coefficient) facilities for node.

MIT
Latest version published 1 month ago

Package Health Score

98 / 100
Full package analysis