natural 5.1.11 → 5.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
// Afinn
|
|
26
26
|
const englishAfinnVoca = require('afinn-165')
|
|
27
27
|
const spanishAfinnVoca = require('./Spanish/afinnShortSortedSpanish.json')
|
|
28
|
+
const portugueseAfinnVoca = require('./Portuguese/afinnShortSortedPortuguese.json')
|
|
28
29
|
|
|
29
30
|
// Senticon
|
|
30
31
|
const spanishSenticonVoca = require('./Spanish/senticon_es.json')
|
|
@@ -43,12 +44,14 @@ const frenchPatternVoca = require('./French/pattern-sentiment-fr.json')
|
|
|
43
44
|
const englishNegations = require('./English/negations_en.json').words
|
|
44
45
|
const spanishNegations = require('./Spanish/negations_es.json').words
|
|
45
46
|
const dutchNegations = require('./Dutch/negations_du.json').words
|
|
47
|
+
const portugueseNegations = require('./Portuguese/negations_pt.json').words
|
|
46
48
|
|
|
47
49
|
// Mapping from type of vocabulary to language to vocabulary
|
|
48
50
|
const languageFiles = {
|
|
49
51
|
afinn: {
|
|
50
52
|
English: [englishAfinnVoca, englishNegations],
|
|
51
|
-
Spanish: [spanishAfinnVoca, spanishNegations]
|
|
53
|
+
Spanish: [spanishAfinnVoca, spanishNegations],
|
|
54
|
+
Portuguese: [portugueseAfinnVoca, portugueseNegations]
|
|
52
55
|
},
|
|
53
56
|
senticon: {
|
|
54
57
|
Spanish: [spanishSenticonVoca, spanishNegations],
|
|
@@ -74,6 +77,7 @@ class SentimentAnalyzer {
|
|
|
74
77
|
// or in subsequent execution the polarity will be undefined
|
|
75
78
|
// shallow copy - requires ES6
|
|
76
79
|
this.vocabulary = Object.assign({}, languageFiles[type][language][0])
|
|
80
|
+
Object.setPrototypeOf(this.vocabulary, null)
|
|
77
81
|
if (type === 'senticon') {
|
|
78
82
|
Object.keys(this.vocabulary).forEach(word => {
|
|
79
83
|
this.vocabulary[word] = this.vocabulary[word].pol
|
|
@@ -93,7 +97,7 @@ class SentimentAnalyzer {
|
|
|
93
97
|
}
|
|
94
98
|
|
|
95
99
|
if (stemmer) {
|
|
96
|
-
const vocaStemmed =
|
|
100
|
+
const vocaStemmed = Object.create(null)
|
|
97
101
|
for (const token in this.vocabulary) {
|
|
98
102
|
vocaStemmed[stemmer.stem(token)] = this.vocabulary[token]
|
|
99
103
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "natural",
|
|
3
3
|
"description": "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.",
|
|
4
|
-
"version": "5.
|
|
4
|
+
"version": "5.2.0",
|
|
5
5
|
"homepage": "https://github.com/NaturalNode/natural",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|