affectimo
Advanced tools
Comparing version 2.1.0 to 2.1.1
36
index.js
/** | ||
* affectimo | ||
* v2.1.0 | ||
* v2.1.1 | ||
* | ||
@@ -34,2 +34,3 @@ * Get the sentiment (affect or valence) and intensity (arousal) of a string. | ||
* 'sortBy': 'freq', | ||
* 'suppressLog': false, | ||
* 'wcGrams': false, | ||
@@ -78,3 +79,5 @@ * } | ||
if (!str) { | ||
console.warn('affectimo: no string found. Returning null.'); | ||
if (!opts || !opts.suppressLog) { | ||
console.warn('affectimo: no string found. Returning null.'); | ||
} | ||
return null; | ||
@@ -88,3 +91,2 @@ } | ||
if (!opts || typeof opts !== 'object') { | ||
console.log('affectimo: using default options.'); | ||
opts = { | ||
@@ -98,2 +100,3 @@ 'encoding': 'binary', | ||
'sortBy': 'freq', | ||
'suppressLog': false, | ||
'wcGrams': false, | ||
@@ -109,6 +112,9 @@ }; | ||
opts.sortBy = opts.sortBy || 'freq'; | ||
opts.suppressLog = opts.suppressLog || false; | ||
opts.wcGrams = opts.wcGrams || false; | ||
if (!Array.isArray(opts.nGrams)) { | ||
console.warn('affectimo: nGrams option must be an array! ' + | ||
'Defaulting to [2, 3].'); | ||
if (!opts || !opts.suppressLog) { | ||
console.warn('affectimo: nGrams option must be an array! ' + | ||
'Defaulting to [2, 3].'); | ||
} | ||
opts.nGrams = [2, 3]; | ||
@@ -124,3 +130,5 @@ } | ||
if (!tokens) { | ||
console.warn('affectimo: no tokens found. Returned null.'); | ||
if (!opts || !opts.suppressLog) { | ||
console.warn('affectimo: no tokens found. Returned null.'); | ||
} | ||
return null; | ||
@@ -136,8 +144,12 @@ } | ||
} else { | ||
console.warn('affectimo: wordcount less than n-gram value "' + n + | ||
'". Ignoring.'); | ||
if (!opts || !opts.suppressLog) { | ||
console.warn('affectimo: wordcount less than n-gram value "' + n + | ||
'". Ignoring.'); | ||
} | ||
} | ||
callback(); | ||
}, function(err) { | ||
if (err) console.error('affectimo: nGram error: ', err); | ||
if (err && !opts.suppressLog) { | ||
console.error('affectimo: nGram error: ', err); | ||
} | ||
}); | ||
@@ -178,4 +190,6 @@ } | ||
if (!output.match(/lex/gi)) { | ||
console.warn('affectimo: output option ("' + output + | ||
'") is invalid, defaulting to "lex".'); | ||
if (!opts || !opts.suppressLog) { | ||
console.warn('affectimo: output option ("' + output + | ||
'") is invalid, defaulting to "lex".'); | ||
} | ||
} | ||
@@ -182,0 +196,0 @@ // default to lexical values |
{ | ||
"name": "affectimo", | ||
"version": "2.1.0", | ||
"version": "2.1.1", | ||
"description": "Analyse the sentiment (affect or valence) and intensity (arousal) of a string.", | ||
@@ -9,3 +9,3 @@ "main": "index.js", | ||
"happynodetokenizer": "^0.3.0", | ||
"lex-helpers": "^0.2.0", | ||
"lex-helpers": "^0.2.1", | ||
"simplengrams": "^0.2.0" | ||
@@ -12,0 +12,0 @@ }, |
@@ -16,2 +16,3 @@ # affectimo | ||
'sortBy': 'freq', | ||
'suppressLog': false, | ||
'wcGrams': false, | ||
@@ -23,2 +24,3 @@ } | ||
``` | ||
--- | ||
@@ -28,4 +30,4 @@ ## Default Output Example | ||
{ | ||
'AFFECT': 5.34, | ||
'INTENSITY': 2.83 | ||
'AFFECT': 5.341427583, | ||
'INTENSITY': 2.832817563 | ||
} | ||
@@ -43,2 +45,4 @@ ``` | ||
--- | ||
## The Options Object | ||
@@ -98,2 +102,10 @@ | ||
### ''suppressLog' | ||
**Boolean - valid options: true, or false (default)** | ||
When set to true, no console logs, warnings, or errors will be printed. | ||
You may want to set this to true for production. | ||
### 'wcGrams' | ||
@@ -137,2 +149,4 @@ | ||
--- | ||
## {output: 'matches'} Output Example | ||
@@ -166,2 +180,4 @@ | ||
--- | ||
## Acknowledgements | ||
@@ -168,0 +184,0 @@ |
128668
196
187
Updatedlex-helpers@^0.2.1