1
0
mirror of https://github.com/node-red/node-red-nodes.git synced 2023-10-10 13:36:58 +02:00

revert sentiment node to English only to save loads of space

both in memory and on disk
This commit is contained in:
Dave Conway-Jones 2019-03-13 14:25:23 +00:00
parent df24e56de8
commit 8c91f5c0d8
No known key found for this signature in database
GPG Key ID: 9E7F9C73F5168CD4
4 changed files with 14 additions and 144 deletions

View File

@ -1,120 +1,11 @@
<script type="text/x-red" data-template-name="sentiment"> <script type="text/x-red" data-template-name="sentiment">
<div class="form-row">
<label for="node-input-lang"><i class="fa fa-language"></i> <span data-i18n="sentiment.label.language"></span></label>
<select type="text" id="node-input-lang" style="width:70%;">
<option value="">set by msg.lang</option>
<option value="af">Afrikaans</option>
<option value="sq">Albanian</option>
<option value="am">Amharic</option>
<option value="ar">Arabic</option>
<option value="hy">Armenian</option>
<option value="az">Azerbaijani</option>
<option value="bn">Bangla</option>
<option value="eu">Basque</option>
<option value="be">Belarusian</option>
<option value="bs">Bosnian</option>
<option value="bg">Bulgarian</option>
<option value="my">Burmese</option>
<option value="ca">Catalan</option>
<option value="ceb">Cebuano</option>
<option value="zh">Chinese</option>
<option value="zh-tw">Chinese (Taiwanese)</option>
<option value="co">Corsican</option>
<option value="hr">Croatian</option>
<option value="cs">Czech</option>
<option value="da">Danish</option>
<option value="nl">Dutch</option>
<option value="en">English</option>
<option value="eo">Esperanto</option>
<option value="et">Estonian</option>
<option value="fi">Finnish</option>
<option value="fr">French</option>
<option value="fy">Frisian</option>
<option value="gl">Galician</option>
<option value="ka">Georgian</option>
<option value="de">German</option>
<option value="el">Greek</option>
<option value="gu">Gujarati</option>
<option value="ht">Haitian Creole</option>
<option value="ha">Hausa</option>
<option value="haw">Hawaiian</option>
<option value="hi">Hindi</option>
<option value="hmn">Hmong</option>
<option value="hu">Hungarian</option>
<option value="is">Icelandic</option>
<option value="ig">Igbo</option>
<option value="id">Indonesian</option>
<option value="ga">Irish</option>
<option value="it">Italian</option>
<option value="ja">Japanese</option>
<option value="kn">Kannada</option>
<option value="kk">Kazakh</option>
<option value="km">Khmer</option>
<option value="ko">Korean</option>
<option value="ku">Kurdish</option>
<option value="ky">Kyrgyz</option>
<option value="lo">Lao</option>
<option value="la">Latin</option>
<option value="lv">Latvian</option>
<option value="lt">Lithuanian</option>
<option value="lb">Luxembourgish</option>
<option value="mk">Macedonian</option>
<option value="mg">Malagasy</option>
<option value="ms">Malay</option>
<option value="ml">Malayalam</option>
<option value="mt">Maltese</option>
<option value="mi">Maori</option>
<option value="mr">Marathi</option>
<option value="mn">Mongolian</option>
<option value="ne">Nepali</option>
<option value="no">Norwegian</option>
<option value="ny">Nyanja</option>
<option value="ps">Pashto</option>
<option value="fa">Persian</option>
<option value="pl">Polish</option>
<option value="pt">Portuguese</option>
<option value="pa">Punjabi</option>
<option value="ro">Romanian</option>
<option value="ru">Russian</option>
<option value="sm">Samoan</option>
<option value="gd">Scottish Gaelic</option>
<option value="sr">Serbian</option>
<option value="sn">Shona</option>
<option value="sd">Sindhi</option>
<option value="si">Sinhala</option>
<option value="sk">Slovak</option>
<option value="sl">Slovenian</option>
<option value="so">Somali</option>
<option value="st">Southern Sotho</option>
<option value="es">Spanish</option>
<option value="su">Sundanese</option>
<option value="sw">Swahili</option>
<option value="sv">Swedish</option>
<option value="tl">Tagalog</option>
<option value="tg">Tajik</option>
<option value="ta">Tamil</option>
<option value="te">Telugu</option>
<option value="th">Thai</option>
<option value="tr">Turkish</option>
<option value="uk">Ukrainian</option>
<option value="ur">Urdu</option>
<option value="uz">Uzbek</option>
<option value="vi">Vietnamese</option>
<option value="cy">Welsh</option>
<option value="xh">Xhosa</option>
<option value="yi">Yiddish</option>
<option value="yo">Yoruba</option>
<option value="zu">Zulu</option>
</select>
</div>
<div class="form-row"> <div class="form-row">
<label for="node-input-property"><i class="fa fa-ellipsis-h"></i> <span data-i18n="node-red:common.label.property"></span></label> <label for="node-input-property"><i class="fa fa-ellipsis-h"></i> <span data-i18n="node-red:common.label.property"></span></label>
<input type="text" id="node-input-property" style="width:70%;"/> <input type="text" id="node-input-property" style="width:70%;"/>
</div> </div>
<div class="form-row"> <div class="form-row">
<label for="node-input-name"><i class="fa fa-tag"></i> <span data-i18n="node-red:common.label.name"></span></label> <label for="node-input-name"><i class="fa fa-tag"></i> <span data-i18n="common.label.name"></span></label>
<input type="text" id="node-input-name" data-i18n="[placeholder]node-red:common.label.name"> <input type="text" id="node-input-name" data-i18n="[placeholder]common.label.name">
</div> </div>
</script> </script>
@ -129,22 +20,13 @@
</dl> </dl>
<h3>Inputs</h3> <h3>Inputs</h3>
<dl class="message-properties"> <dl class="message-properties">
<dt>words <span class="property-type">object</span></dt> <dt>overrides <span class="property-type">object</span></dt>
<dd>an object of words and scores to override or add words can be supplied - <code>{ word:score,... }</code>.</dd> <dd>an object of word score overrides can be supplied - <code>{ word:score,... }</code>.</dd>
</dl>
<dl class="message-properties">
<dt>lang <span class="property-type">string</span></dt>
<dd>Two letter cldr code to specify the language to use - from the list below</dd>
</dl> </dl>
<h3>Details</h3> <h3>Details</h3>
<p>A score greater than zero is positive and less than zero is negative.</p> <p>A score greater than zero is positive and less than zero is negative.</p>
<p>The score typically ranges from -5 to +5, but can go higher and lower.</p> <p>The score typically ranges from -5 to +5, but can go higher and lower.</p>
<p>See <a href="https://github.com/marcellobarile/multilang-sentiment/blob/develop/README.md" target="_blank">the Sentiment docs here</a>.</p> <p>See <a href="https://github.com/thisandagain/sentiment/blob/master/README.md" target="_blank">the Sentiment docs here</a>.</p>
<p>The node can also be configured to let the language be specified by setting <code>msg.lang</code> to one of the codes below</p>
<p>The language codes supported are - af, am, ar, az, be, bg, bn, bs, ca, ceb, co, cs, cy, da, de, el, en, eo, es, et, eu, fa, fi,
fr, fy, ga, gd, gl, gu, ha, haw, hi, hmn, hr, ht, hu, hy, id, ig, is, it, iw, ja, jw, ka, kk, km, kn, ko, ku, ky, la, lb, lo, lt,
lv, mg, mi, mk, ml, mn, mr, ms, mt, my, ne, nl, no, ny, pa, pl, ps, pt, ro, ru, sd, si, sk, sl, sm, sn, so, sq, sr, st, su, sv,
sw, ta, te, tg, th, tl, tr, uk, ur, uz, vi, xh, yi, yo, zh, zh-tw, zu</p>
</script> </script>
<script type="text/javascript"> <script type="text/javascript">
@ -153,8 +35,7 @@
color:"#E6E0F8", color:"#E6E0F8",
defaults: { defaults: {
name: {value:""}, name: {value:""},
property: {value:"payload",required:true}, property: {value:"payload",required:true}
lang: {value:"en"}
}, },
inputs:1, inputs:1,
outputs:1, outputs:1,

View File

@ -1,22 +1,16 @@
module.exports = function(RED) { module.exports = function(RED) {
"use strict"; "use strict";
var sentiment = require('multilang-sentiment'); var sentiment = require('sentiment');
function SentimentNode(n) { function SentimentNode(n) {
RED.nodes.createNode(this,n); RED.nodes.createNode(this,n);
this.lang = n.lang;
this.property = n.property||"payload"; this.property = n.property||"payload";
var node = this; var node = this;
this.on("input", function(msg) { this.on("input", function(msg) {
var value = RED.util.getMessageProperty(msg,node.property); var value = RED.util.getMessageProperty(msg,node.property);
if (value !== undefined) { if (value !== undefined) {
if (msg.hasOwnProperty("overrides")) { sentiment(value, msg.overrides || null, function (err, result) {
msg.extras = msg.overrides;
delete msg.overrides;
}
sentiment(value, node.lang || msg.lang || 'en', {words: msg.extras || null}, function (err, result) {
msg.sentiment = result; msg.sentiment = result;
node.send(msg); node.send(msg);
}); });

View File

@ -4,6 +4,8 @@ node-red-node-sentiment
A <a href="http://nodered.org" target="new">Node-RED</a> node that scores incoming words A <a href="http://nodered.org" target="new">Node-RED</a> node that scores incoming words
using the AFINN-165 wordlist and attaches a sentiment.score property to the msg. using the AFINN-165 wordlist and attaches a sentiment.score property to the msg.
NOTE: We also have a multi-language version available as <b>node-red-node-multilang-sentiment</b>.
Install Install
------- -------
@ -19,13 +21,6 @@ Uses the AFINN-165 wordlist to attempt to assign scores to words in text.
Attaches `msg.sentiment` to the msg and within that `msg.sentiment.score` holds the score. Attaches `msg.sentiment` to the msg and within that `msg.sentiment.score` holds the score.
Supports multiple languages. These can be preselected in the node configuration. You can also set it so that `msg.lang` can be used to set the language dynamically if required. The cldr language codes supported are:
af, am, ar, az, be, bg, bn, bs, ca, ceb, co, cs, cy, da, de, el, en, eo, es, et, eu, fa, fi,
fr, fy, ga, gd, gl, gu, ha, haw, hi, hmn, hr, ht, hu, hy, id, ig, is, it, iw, ja, jw, ka, kk, km, kn, ko, ku, ky, la, lb, lo, lt,
lv, mg, mi, mk, ml, mn, mr, ms, mt, my, ne, nl, no, ny, pa, pl, ps, pt, ro, ru, sd, si, sk, sl, sm, sn, so, sq, sr, st, su, sv,
sw, ta, te, tg, th, tl, tr, uk, ur, uz, vi, xh, yi, yo, zh, zh-tw, zu
A score greater than zero is positive and less than zero is negative. The score typically ranges from -5 to +5, but can go higher and lower. A score greater than zero is positive and less than zero is negative. The score typically ranges from -5 to +5, but can go higher and lower.
See the <a href="https://github.com/marcellobarile/multilang-sentiment/blob/develop/README.md" target="_blank">Multilang Sentiment docs here</a>.</p> See the <a href="https://github.com/thisandagain/sentiment/blob/develop/README.md" target="_blank">Sentiment docs here</a>.</p>

View File

@ -1,9 +1,9 @@
{ {
"name" : "node-red-node-sentiment", "name" : "node-red-node-sentiment",
"version" : "0.1.1", "version" : "0.1.2",
"description" : "A Node-RED node that uses the AFINN-165 wordlists for sentiment analysis of words translated into multiple languages including emojis.", "description" : "A Node-RED node that uses the AFINN-165 wordlists for sentiment analysis of words.",
"dependencies" : { "dependencies" : {
"multilang-sentiment" : "^1.1.6" "sentiment" : "2.1.0"
}, },
"repository" : { "repository" : {
"type":"git", "type":"git",