diff --git a/lib/natural/sentiment/SentimentAnalyzer.js b/lib/natural/sentiment/SentimentAnalyzer.js index 41736b0d6..c1222a075 100644 --- a/lib/natural/sentiment/SentimentAnalyzer.js +++ b/lib/natural/sentiment/SentimentAnalyzer.js @@ -25,6 +25,7 @@ // Afinn const englishAfinnVoca = require('afinn-165') const spanishAfinnVoca = require('./Spanish/afinnShortSortedSpanish.json') +const portugueseAfinnVoca = require('./Portuguese/afinnShortSortedPortuguese.json') // Senticon const spanishSenticonVoca = require('./Spanish/senticon_es.json') @@ -43,12 +44,14 @@ const frenchPatternVoca = require('./French/pattern-sentiment-fr.json') const englishNegations = require('./English/negations_en.json').words const spanishNegations = require('./Spanish/negations_es.json').words const dutchNegations = require('./Dutch/negations_du.json').words +const portugueseNegations = require('./Portuguese/negations_pt.json').words // Mapping from type of vocabulary to language to vocabulary const languageFiles = { afinn: { English: [englishAfinnVoca, englishNegations], - Spanish: [spanishAfinnVoca, spanishNegations] + Spanish: [spanishAfinnVoca, spanishNegations], + Portuguese: [portugueseAfinnVoca, portugueseNegations] }, senticon: { Spanish: [spanishSenticonVoca, spanishNegations], diff --git a/spec/SentimentAnalyzer_spec.js b/spec/SentimentAnalyzer_spec.js index bf96fdb3f..56a4a1425 100644 --- a/spec/SentimentAnalyzer_spec.js +++ b/spec/SentimentAnalyzer_spec.js @@ -166,6 +166,16 @@ const testConfigurations = [ { sentence: 'El poco miedo a parecer estúpida, por otra parte, hace de esta incursión en las debilidades masculinas un retrato divertido a la par que honesto, e incluso cuando se sitúa en espacios más frívolos sabe encontrar los resortes adecuados para hacer que del chiste broten risas ácidas.', score: 0.00719148936170213 }, { sentence: 'Hay imágenes en Ready Player One realmente ingeniosas, así como set pieces abrumadores (que mejor no desvelar para no estropear el visionado); aunque el conglomerado de citas no siempre acaba funcionando, y la mezcla, por tanto, se transforma en mezcolanza: en un abigarrado fresco de todas esas cosas que han molado en los últimos 40 años, apelotonadas sin demasiado rigor ni pensamiento. Poca duda cabe de que Spielberg ha pulido mucho la literatura de Cline (es notorio en el último tramo del largometraje), pero aún y así el toque mágico del Rey Midas se resiente (algo), sobre todo cuando nos damos cuenta de que debajo de los adoquines, esa pátina espectacular de píxeles destellantes, no está escondida la playa. Ni nada que se le parezca.', score: -0.00584 } ] + }, + { + language: 'Portuguese', + stemmer: 'PorterStemmerPt', + vocabularyType: 'afinn', + testSentences: [ + { sentence: 'Juan Carlos prepara regresso a Espanha. Victoria Federica, neta do rei emérito, confirmou a informação à imprensa.', score: 0 }, + { sentence: 'fortalecimento', score: 2 }, + { sentence: 'fortalecimento controverso', score: 0 } + ] } ]