View sentiment-output.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
0.42857142857142855 // указывает на относительно отрицательное утверждение |
View sentiment-index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// index.js | |
var natural = require('natural'); | |
var Analyzer = natural.SentimentAnalyzer; | |
var stemmer = natural.PorterStemmer; | |
var analyzer = new Analyzer("English", stemmer, "afinn"); | |
// getSentiment ожидает массив строк | |
console.log(analyzer.getSentiment(["I", "don't", "want", "to", "play", "with", "you"])); |
View classification-output.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sell | |
buy |
View classification-index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// index.js | |
var natural = require('natural'); | |
var classifier = new natural.BayesClassifier(); | |
classifier.addDocument('i am long qqqq', 'buy'); | |
classifier.addDocument('buy the q\'s', 'buy'); | |
classifier.addDocument('short gold', 'sell'); | |
classifier.addDocument('sell gold', 'sell'); | |
classifier.train(); |
View string_distance-output.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 | |
3 | |
-1 |
View string_distance-index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// index.js | |
var natural = require('natural'); | |
console.log(natural.HammingDistance("karolin", "kathrin", false)); | |
console.log(natural.HammingDistance("karolin", "kerstin", false)); | |
console.log(natural.HammingDistance("short string", "longer string", false)); |
View stemming-output.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ 'go', 'friend' ] |
View stemming-index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// index.js | |
var natural = require('natural'); | |
natural.PorterStemmer.attach(); | |
console.log("I can see that we are going to be friends".tokenizeAndStem()); |
View tokenization-output.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ 'The', | |
'quick', | |
'brown', | |
'fox', | |
'jumps', | |
'over', | |
'the', | |
'lazy', | |
'dog' ] |
View tokenization-index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// index.js | |
var natural = require('natural'); | |
var tokenizer = new natural.WordTokenizer(); | |
console.log(tokenizer.tokenize("The quick brown fox jumps over the lazy dog")); |