string-analysis
A combined experience of sentiment analysis, bad-word detection and filteration with power to get adjectives, nouns and verbs from a string.
Installtion
npm i string-analysis
Usage
const Analyze = require('string-analysis');
const analyze = new Analyze();
Sentiment Analysis
console.log(analyze.analyzeEmotion("I am testing this package"))
Analysis
- Analysis will have 3 type of values, negative, zero and positive
- Negative means negative emotions
- Positive means positive emotions
- Zero means neutral
intensity
Intensity cleary states, negative, neutral, positive and compound ratio in a sentence
Nouns Adjectives and Verbs
Adding Adjectives, Nouns and verbs to existing list in library
var Analyze = require('string-analysis');
var analyze = new Analyze({
adjectives: ["bashful"],
nouns: ["car"],
verbs: ["some verbs"]
});
Get list of nouns
var Analyze = require('string-analysis');
var analyze = new Analyze();
analyze.getNouns("sentence")
Get list of Adjectives
var Analyze = require('string-analysis');
var analyze = new Analyze();
analyze.getAdjectives("sentence")
Get list of Verbs
var Analyze = require('string-analysis');
var analyze = new Analyze();
analyze.getVerbs("sentence")
Bad Words Detection
Usage
var Analyze = require('string-analysis'),
analyze = new Analyze();
console.log(analyze.clean("Don't be an ash0le"));
Placeholder Overrides
var Analyze = require('string-analysis');
var analyze = new Analyze({ placeHolder: 'x'});
analyze.clean("Don't be an ash0le");
Regex Overrides
var analyze = new Analyze({ regex: /\*|\.|$/gi });
var analyze = new Analyze({ replaceRegex: /[A-Za-z0-9가-힣_]/g });
Add words to the blacklist
var analyze = new Analyze();
analyze.addWords('some', 'bad', 'word');
analyze.clean("some bad word!")
var newBadWords = ['some', 'bad', 'word'];
analyze.addWords(...newBadWords);
analyze.clean("some bad word!")
var analyze = new Analyze({ list: ['some', 'bad', 'word'] });
analyze.clean("some bad word!")
Instantiate with an empty list
var analyze = new Analyze({ emptyList: true });
analyze.clean('hell this wont clean anything');
Remove words from the blacklist
let analyze = new Analyze();
analyze.removeWords('hells', 'sadist');
analyze.clean("some hells word!");
let removeWords = ['hells', 'sadist'];
analyze.removeWords(...removeWords);
analyze.clean("some sadist hells word!");
Get list of bad words
let analyze = new Analyze();
analyze.getBadWords("Some words that I cannot type here");
Ref. taken for bad-words
Used and tweaked code from https://www.npmjs.com/package/bad-words as per The MIT License (MIT)
Support
For support, connect with me on Linkedin (https://www.linkedin.com/in/lazycoderr) or twitter (https://twitter.com/lazycoderr).
Authors