npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

airscore

v0.0.2

Published

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

Downloads

6

Readme

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