Skip to content

Instantly share code, notes, and snippets.

View RinatValiullov's full-sized avatar
👷‍♂️
Looking for a job

Rinat Valiullov RinatValiullov

👷‍♂️
Looking for a job
View GitHub Profile
@RinatValiullov
RinatValiullov / sentiment-output.js
Created November 29, 2019 20:50
For translation of article "Natural language processing for Node.js" - https://bit.ly/2QZsts1
0.42857142857142855 // указывает на относительно отрицательное утверждение
@RinatValiullov
RinatValiullov / sentiment-index.js
Last active December 3, 2019 11:30
For translation of article "Natural language processing for Node.js" - https://bit.ly/2QZsts1
// 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"]));
@RinatValiullov
RinatValiullov / classification-output.js
Created November 29, 2019 20:49
For translation of article "Natural language processing for Node.js" - https://bit.ly/2QZsts1
sell
buy
@RinatValiullov
RinatValiullov / classification-index.js
Last active December 2, 2019 06:04
For translation of article "Natural language processing for Node.js" - https://bit.ly/2QZsts1
// 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();
@RinatValiullov
RinatValiullov / string_distance-output.js
Created November 29, 2019 20:48
For translation of article "Natural language processing for Node.js" - https://bit.ly/2QZsts1
3
3
-1
@RinatValiullov
RinatValiullov / string_distance-index.js
Last active December 2, 2019 10:32
For translation of article "Natural language processing for Node.js" - https://bit.ly/2QZsts1
// 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));
@RinatValiullov
RinatValiullov / stemming-output.js
Created November 29, 2019 20:47
For translation of article "Natural language processing for Node.js" - https://bit.ly/2QZsts1
[ 'go', 'friend' ]
@RinatValiullov
RinatValiullov / stemming-index.js
Created November 29, 2019 20:46
For translation of article "Natural language processing for Node.js" - https://bit.ly/2QZsts1
// index.js
var natural = require('natural');
natural.PorterStemmer.attach();
console.log("I can see that we are going to be friends".tokenizeAndStem());
@RinatValiullov
RinatValiullov / tokenization-output.js
Created November 29, 2019 20:46
For translation of article "Natural language processing for Node.js" - https://bit.ly/2QZsts1
[ 'The',
'quick',
'brown',
'fox',
'jumps',
'over',
'the',
'lazy',
'dog' ]
@RinatValiullov
RinatValiullov / tokenization-index.js
Created November 29, 2019 20:44
For translation of article "Natural language processing for Node.js" - https://bit.ly/2QZsts1
// index.js
var natural = require('natural');
var tokenizer = new natural.WordTokenizer();
console.log(tokenizer.tokenize("The quick brown fox jumps over the lazy dog"));