Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
var natural = require('natural');
var _ = require('underscore')._;
var wordnet = new natural.WordNet();
var sym = []
wordnet.lookupSynonyms('offer', function(results) {
results.forEach(function(result) {
// sym.push(result.synonyms)
// sym.push(result.lemma)
sym = sym.concat(result.synonyms)
// console.log(result)
// console.log(result.ptrs)
// console.log('------------------------------------');
// console.log(result.synsetOffset);
/// console.log(result.pos);
// console.log(result.lemma);
// console.log(result.synonyms);
// c//onsole.log(result.gloss);
// console.log(result)
var fs = require('fs');
var natural = require('natural');
var Tagger = require('simple-pos-tagger');
var ChartParsers = require('../index');
var parserFactory = new ChartParsers.ParserFactory();
var GrammarParser = ChartParsers.GrammarParser;
var path = './data/';
var sentences_file = path + 'sentences.txt';
var grammar_file = path + 'English grammar using Wordnet tags.txt';
var tagger_config_file = '../node_modules/simple-pos-tagger/data/English/lexicon_files.json';
tokenizer = new natural.TreebankWordTokenizer();
var wordnet = new natural.WordNet();
var sentences;
function initialise(callback) {
// read sentences from file
fs.readFile(sentences_file, 'utf8', function (error, sentences_text) {
if (error) {
logger.error(error);
}
sentences = sentences_text.split('\n');
// read grammar from file
fs.readFile(grammar_file, 'utf8', function (error, grammar_text) {
if (error) {
logger.error(error);
}
// parse the grammar
var grammar = GrammarParser.parse(grammar_text);
var natural = require('natural'),
pos = require('pos'),
wordnet = new natural.WordNet(),
_ = require('underscore'),
NGrams = natural.NGrams,
classifier = new natural.BayesClassifier(),
tokenizer = new natural.TreebankWordTokenizer(); // natural.WordTokenizer();
natural.PorterStemmer.attach();
// load the classifier data and learn the schema
/*natural.BayesClassifier.load('./classifier.json', null, function(err, classifier) {
// if the classifier hasn't been saved, then calculate it now
if (err) {
var traindata = require('./trainingdata.json');
for (i in traindata)
{
classifier.addDocument(traindata[i].query, traindata[i].category);
}
// Underscore
var _ = require('underscore');
// Natural
var natural = require('natural');
var wordnet = new natural.WordNet();
// Spencer Kelly's nlp-node libs
var sentenceParser = require('./nlp-node-master/sentence_parser/sentence');
var dateExtractor = require('./nlp-node-master/date_parser/date_extractor');
// Fortnight Lab's libs
var pos = require('pos');
var glossary = require("glossary")({ collapse: true });
// Constructor
function nlpsum() {}
nlpsum.prototype.test = function(text) {
wordnet.lookup('node', function(results) {
results.forEach(function(result) {
//http://wordnet.princeton.edu/man/wninput.5WN.html
// n for noun files, v for verb files, a for adjective files, r for adverb files
// http://stackoverflow.com/questions/1833252/java-stanford-nlp-part-of-speech-labels
// @ Hypernym
// ~ Hyponym
// synset diambiguation = [all, the most frequent]
// relation = [ syn, hypo_0, cohypo ]
var _ = require('underscore')._;
var natural = require('natural');
var wordnet = new natural.WordNet();
var async = require('async');
var params = process.argv.slice();
params.splice(0,2)
var POS = {
'n': ['NN', 'NNS', 'NNP', 'NNPS', 'noun'],
'a': ['JJ', 'JJR', 'JJS', 'adj'],
's': ['JJ', 'JJR', 'JJS', 'adj'],
'r': ['RB', 'RBR', 'RBS','WRB', 'adv'],
'v': ['VB', 'VBD', 'VBG', 'VBN', 'VBP', 'VBZ', 'verb']
}
var gl_relations = ['synonym', 'hypernym', 'hypernym_1','hypernym_2','hypernym_3', 'hyponym', 'cohyponym']
console.log('\n-- tfidf for word "Congress" in three test documents:');
console.log('Congress:');
tfidf.tfidfs('Congress', function(i, measure) {
console.log('document #' + i + ' is ' + measure);
});
console.log('\n-- tfidf for word "taxes" in three test documents:');
console.log('taxes:');
tfidf.tfidfs('taxes', function(i, measure) {
console.log('document #' + i + ' is ' + measure);
});
var wordnet_data_path = process.env.WORDNET_DATA;
console.log("Wordnet data path: " + wordnet_data_path);
var wordnet = new natural.WordNet(wordnet_data_path);
var pos_map = {v: 'verb', n: 'noun', a: 'adjective', s: 'adjective', r: 'adverb'};
wordnet.lookup('bank', function(results) {
results.forEach(function(result) {
console.log('\n-- Wordnet data for "bank":');
console.log(' part of speech: ' + pos_map[result.pos]);
console.log(' lemma: ' + result.lemma);
console.log(' synonyms: ' + result.synonyms);
console.log(' gloss: ' + result.gloss);
});
});