New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

airscore

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

airscore

Rate strings (tweets, texts and more) by your own custom criteria

  • 0.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
Maintainers
1
Weekly downloads
 
Created
Source

airscore

Rate strings (tweets, texts and more) by your own custom criteria.

Install

$ npm install --save airscore

Usage

var Airscore = require('airscore');

var tweet = new Airscore();

// When setting a text, an internal array of words will automatically be parsed by airscore
tweet.set('text', 'Some good text example with some negative and positive words. This is a well defined example. But it also contains some not so nice words');

// You can also set the words directly yourself.
// tweet.set('words', ['good', 'bad']);

// Add the tones by which you want to rate your text

// Every tone has a label/type and an array of words, each word has its own weight, the weight is optional and defaults to: 1
tweet.addTone('positive', [
    { word: 'good', weight: 1 },
    { word: 'positive', weight: 1 },
    { word: 'well', weight: 1 },
    { word: 'nice', weight: 1.5 }
]);

tweet.addTone('negative', [
    { word: 'bad', weight: 1.5 },
    { word: 'not', weight: 1 },
    { word: 'negative', weight: 1 }
]);

// We can now call the method to get the individual scores.
var score = tweet.getScore(); // balance defaults to: 'fair'
console.log(score); // returns: { positive: '0.18', negative: '0.08' }

// The above example returns a 'fair' weight, counting every word of the text.
// We could instead only take into account the positive and negative words.
score = tweet.getScore({ balance: 'strict' });
console.log(score); // returns: { positive: '4.50', negative: '2.00' }

// Or in percent 'fair'
score = tweet.getScore({ percent: true });
console.log(score); // returns: { positive: '18.00%', negative: '8.00%' }

// In percent 'strict'
score = tweet.getScore({ balance: 'strict', percent: true });
console.log(score); // returns: { positive: '69.23%', negative: '30.77%' }

// You are in control of the decimals aswell. (percent or not..)
score = tweet.getScore({ balance: 'strict', percent: true, decimals: 6 });
console.log(score); // returns: { positive: '69.230769%', negative: '30.769231%' }

API

instance.set(key, value)

  • Sets the 'key' to 'value' in the instances attributes.
instance.set('text', 'Hello im a text.')
  • Sets the instances words array to: ['Hello', 'im', 'a', 'text']
instance.set('words', ['Hello', 'text'])
  • Sets the instances words array to: ['Hello', 'text']

instance.add('words', 'here')

  • Updates the instances words array to: ['Hello', 'text', 'here']

instace.addTone(string, [Array of indicators])

  • Adds one tone to the instance
  • A tone has many indicators
  • An indicator has the 'word' its identified by and a weight, the weight defaults to: 1
  • 1 indicator looks like that:
{
    word: 'Hello',
    weight: 1
}

instance.getScore(options)

  • Gets the score
  • Accepts the following options:
  • balance: fair/strict defaults to: fair
  • decimals: the decimals for every result
  • percent: true or false defaults to: false

License

MIT © Linus Gubenis

FAQs

Package last updated on 06 Aug 2015

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc