nlp-sentiment
Advanced tools
Comparing version 1.0.0 to 1.0.1
@@ -9,9 +9,5 @@ import { Sentence, SentenceResult } from "./types"; | ||
withPositiveWords(words: string[]): NlpSentiment; | ||
withPositiveAsFile(filePath: string): NlpSentiment; | ||
withNegativeWords(words: string[]): NlpSentiment; | ||
withNegativeAsFile(filePath: string): NlpSentiment; | ||
withIntensifierWords(words: string[]): NlpSentiment; | ||
withIntensifierAsFile(filePath: string): NlpSentiment; | ||
withNegationWords(words: string[]): NlpSentiment; | ||
withNegationAsFile(filePath: string): NlpSentiment; | ||
analyse(sentences: Sentence[]): SentenceResult[]; | ||
@@ -18,0 +14,0 @@ } |
@@ -16,6 +16,2 @@ "use strict"; | ||
}; | ||
NlpSentiment.prototype.withPositiveAsFile = function (filePath) { | ||
this._positiveVocabulary = (0, vocabulary_1.formVocabularyFromFile)(filePath, 1); | ||
return this; | ||
}; | ||
NlpSentiment.prototype.withNegativeWords = function (words) { | ||
@@ -25,6 +21,2 @@ this._negativeVocabulary = (0, vocabulary_1.formVocabularyFromWords)(words, -1); | ||
}; | ||
NlpSentiment.prototype.withNegativeAsFile = function (filePath) { | ||
this._negativeVocabulary = (0, vocabulary_1.formVocabularyFromFile)(filePath, -1); | ||
return this; | ||
}; | ||
NlpSentiment.prototype.withIntensifierWords = function (words) { | ||
@@ -34,6 +26,2 @@ this._intensifierVocabulary = (0, vocabulary_1.formVocabularyFromWords)(words, 1.5); | ||
}; | ||
NlpSentiment.prototype.withIntensifierAsFile = function (filePath) { | ||
this._intensifierVocabulary = (0, vocabulary_1.formVocabularyFromFile)(filePath, 1.5); | ||
return this; | ||
}; | ||
NlpSentiment.prototype.withNegationWords = function (words) { | ||
@@ -43,6 +31,2 @@ this._negationVocabulary = (0, vocabulary_1.formVocabularyFromWords)(words, -1); | ||
}; | ||
NlpSentiment.prototype.withNegationAsFile = function (filePath) { | ||
this._negationVocabulary = (0, vocabulary_1.formVocabularyFromFile)(filePath, -1); | ||
return this; | ||
}; | ||
NlpSentiment.prototype.analyse = function (sentences) { | ||
@@ -49,0 +33,0 @@ var _this = this; |
import { Vocabulary } from "./types"; | ||
export declare const formVocabularyFromFile: (pathToFile: string, value: number) => Vocabulary; | ||
export declare const formVocabularyFromWords: (words: string[], value: number) => Vocabulary; |
@@ -14,23 +14,3 @@ "use strict"; | ||
exports.__esModule = true; | ||
exports.formVocabularyFromWords = exports.formVocabularyFromFile = void 0; | ||
var fs = require("fs"); | ||
var formVocabularyFromFile = function (pathToFile, value) { | ||
if (!pathToFile || !value) { | ||
return {}; | ||
} | ||
if (!fs.existsSync("foo.txt")) { | ||
console.error("File \"".concat(pathToFile, "\" does not exist")); | ||
return {}; | ||
} | ||
var text = fs.readFileSync(pathToFile); | ||
var textByLine = text.toString().split("\n"); | ||
return textByLine.reduce(function (obj, word) { | ||
var _a; | ||
if (word.length > 0) { | ||
return __assign(__assign({}, obj), (_a = {}, _a[word] = value, _a)); | ||
} | ||
return obj; | ||
}, {}); | ||
}; | ||
exports.formVocabularyFromFile = formVocabularyFromFile; | ||
exports.formVocabularyFromWords = void 0; | ||
var formVocabularyFromWords = function (words, value) { | ||
@@ -37,0 +17,0 @@ if (!words || !value) { |
{ | ||
"name": "nlp-sentiment", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "A very tiny, fast and useful tool for sentiment analysis. It works with any language and can also use provided intensifier words!", | ||
@@ -42,2 +42,2 @@ "main": "lib/index.js", | ||
} | ||
} | ||
} |
@@ -6,3 +6,8 @@ # 😛 Sentiment — javascript NLP tool for fast and simple sentiment analysis | ||
[](https://codecov.io/gh/MarkusBansky/sentiment) | ||
[](https://snyk.io/test/github/MarkusBansky/sentiment) | ||
[](https://sonarcloud.io/summary/new_code?id=MarkusBansky_sentiment) | ||
[](https://sonarcloud.io/summary/new_code?id=MarkusBansky_sentiment) | ||
[](https://sonarcloud.io/summary/new_code?id=MarkusBansky_sentiment) | ||
This is a small and fast library for nlp sentiment analysis which supports any language, or any custom vocabulary. | ||
@@ -9,0 +14,0 @@ It can also use intensifiers with positive or negative words adding more contrast. |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
102
0
49807
174