Socket
Socket
Sign inDemoInstall

string-analysis

Package Overview
Dependencies
38
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    string-analysis

A combined experience of sentiment analysis, bad-word detection and filteration with power to get adjectives, nouns and verbs from a string.


Version published
Weekly downloads
3
increased by200%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

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: 0, intensity: { neg: 0, neu: 1, pos: 0, compound: 0 } }

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"], // optional
    nouns: ["car"], // optional
    verbs: ["some verbs"] //optional
});

Get list of nouns

var Analyze = require('string-analysis');
var analyze = new Analyze();
analyze.getNouns("sentence") // returns words array

Get list of Adjectives

var Analyze = require('string-analysis');
var analyze = new Analyze();
analyze.getAdjectives("sentence") // returns words array

Get list of Verbs

var Analyze = require('string-analysis');
var analyze = new Analyze();
analyze.getVerbs("sentence")  // returns words array

Bad Words Detection

Usage

var Analyze = require('string-analysis'),
    analyze = new Analyze();

console.log(analyze.clean("Don't be an ash0le")); //Don't be an ******

Placeholder Overrides

var Analyze = require('string-analysis');
var analyze = new Analyze({ placeHolder: 'x'});

analyze.clean("Don't be an ash0le"); //Don't be an xxxxxx

Regex Overrides

var analyze = new Analyze({ regex: /\*|\.|$/gi });

var analyze = new Analyze({ replaceRegex:  /[A-Za-z0-9가-힣_]/g }); 
//multilingual support for word filtering

Add words to the blacklist

var analyze = new Analyze(); 

analyze.addWords('some', 'bad', 'word');

analyze.clean("some bad word!") //**** *** ****!

//or use an array using the spread operator

var newBadWords = ['some', 'bad', 'word'];

analyze.addWords(...newBadWords);

analyze.clean("some bad word!") //**** *** ****!

//or

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'); //hell this wont clean anything

Remove words from the blacklist

let analyze = new Analyze(); 

analyze.removeWords('hells', 'sadist');

analyze.clean("some hells word!"); //some hells word!

//or use an array using the spread operator

let removeWords = ['hells', 'sadist'];

analyze.removeWords(...removeWords);

analyze.clean("some sadist hells word!"); //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

Keywords

FAQs

Last updated on 24 Nov 2021

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc