Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
@christophe77/sentiment-js
Advanced tools
SentimentsJS is build on to of **tensorflow js**. It allows you to add a sentiment analysis on your node or browser javascript app. With this package you'll be able to get the overall **sentiment** from a text and the **toxicity** classification.
SentimentsJS is build on to of tensorflow js. It allows you to add a sentiment analysis on your node or browser javascript app. With this package you'll be able to get the overall sentiment from a text and the toxicity classification.
yarn add @christophe77/sentiment-js
or
npm install @christophe77/sentiment-js
the "analyse" function takes an object as parameter.
The object has 2 properties :
The function will return the result like this :
{
"sentiment": {
"score": 0.9931357502937317,
"result": "positive"
},
"toxicity": [
{"label": "insult", "result": true},
{"label": "toxicity","result": true},
{.......}
]
}
property "label" can have those values :
Exemple :
import sjs from '@christophe77/sentiment-js';
const checkThisText = async () => {
// sentiment
const beerScore = await sjs.analyse({
text: 'I love cold beers',
type: 'sentiment',
});
console.log("'I love cold beers' : ", JSON.stringify(beerScore));
// toxicity
const vegetableScore = await sjs.analyse({
text: 'I really hate those fucking vegetables',
type: 'toxicity',
});
console.log("'I really hate those fucking vegetables' : ", JSON.stringify(vegetableScore));
// both
const insultScore = await sjs.analyse({
text: 'You are just a fucking bitch. You just deserve to receive cum on your dirty shitty face',
type: 'both',
});
console.log( "'You are just a fucking bitch. You just deserve to receive cum on your dirty shitty face' : ", JSON.stringify(insultScore) );
// combined
const combinedScore = await sjs.analyse({
text: 'You are just a fucking bitch. You just deserve to receive cum on your dirty shitty face',
type: 'combined',
});
console.log( "'You are just a fucking bitch. You just deserve to receive cum on your dirty shitty face' : ", JSON.stringify(combinedScore) );
};
Console output will be :
'I love cold beers' : {
"sentiment": { score":0.8631731867790222,"result":"positive"},
"toxicity":[]
}
'I really hate those fucking vegetables' : {
"sentiment": {"score":0.1487867832183838,"result":"negative"},
"toxicity":[{"label":"toxicity","result":true}]
}
'You are just a fucking bitch. You just deserve to receive cum on your dirty shitty face' :
{
"sentiment":{"score":0.9931357502937317,"result":"positive"},
"toxicity":[
{"label":"insult","result":true},
{"label":"toxicity","result":true}
]
}
'You are just a fucking bitch. You just deserve to receive cum on your dirty shitty face' :
{
"combined":"negative"
}
Has you can see on the 3rd exemple, the sentences are very vulgar but the sentiment is computed as "positive". That's why I added a "combined" classification so you can check both toxicity and sentiment result to determinate if it's a false positive.
FAQs
Get sentiment and toxicity of a text.
The npm package @christophe77/sentiment-js receives a total of 1 weekly downloads. As such, @christophe77/sentiment-js popularity was classified as not popular.
We found that @christophe77/sentiment-js demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.