@happyaccident/wink-sentiment
Version:
Accurate and fast sentiment scoring of phrases with emoticons :) & emojis 🎉
331 lines (262 loc) • 11.3 kB
HTML
<html lang="en">
<head>
<meta charset="utf-8">
<title>wink-sentiment - Wink JS - Summary</title>
<script src="scripts/prettify/prettify.js"></script>
<script src="scripts/prettify/lang-css.js"></script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/prettify.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc.css">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-47082559-2"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-47082559-2');
</script>
<script src="https://use.typekit.net/cwc1qce.js"></script>
<script>
((window.gitter = {}).chat = {}).options = {
room: 'winkjs/Lobby'
};
window.onload = function () {
document.querySelector('.gitter-open-chat-button').innerText = 'Need help?'
document.querySelector('.gitter-open-chat-button').style.display = 'block';
}
</script>
<script src="https://sidecar.gitter.im/dist/sidecar.v1.js" async defer></script>
<script>try{Typekit.load({ async: true });}catch(e){}</script>
<style media="screen">
body {
font-family: 'ff-tisa-sans-web-pro', serif;
}
.navbar {
border-top: 4px solid #6C307D;
box-sizing: border-box;
height: 64px;
background-color: #222;
position: fixed;
top: 0;
right: 0;
left: 0;
z-index: 1030;
display: flex;
justify-content: space-between;
}
.navbar-header {
font-weight: bold;
font-size: 30px;
}
.navbar-header a img {
height: 24px;
}
.navbar a {
color: #fff;
line-height: 60px;
margin-left: 0;
}
.navbar a.navbar-brand {
margin-left: 20px;
display: block;
min-width: 40px;
}
.navbar-right {
margin: 0;
line-height: 50px;
list-style: none;
}
.navbar-right li {
float: left;
margin-right: 20px;
text-transform: uppercase;
letter-spacing: 1px;
padding-left: 20px;
font-size: 14px;
}
/* Override docdash */
#main {
margin-top: 30px;
}
/* Gitter */
.gitter-open-chat-button {
background: #6C307D;
display: none;
}
.gitter-open-chat-button:hover {
opacity: 0.8;
background: #6C307D;
}
.gitter-chat-embed {
top: 64px;
}
</style>
<script type="text/javascript">
window.addEventListener('DOMContentLoaded', function () {
if ( window.location.hash ) {
openMember();
window.setTimeout( function () {
window.scrollTo( 0, (window.pageYOffset || document.documentElement.scrollTop) - 72);
}, 0)
}
document.getElementById('toc-button').addEventListener('click', function () {
if (document.getElementById('side-nav').className === '') {
document.getElementById('side-nav').className = 'is-open';
document.getElementById('toc-button-img').setAttribute('src','./close.svg');
} else {
document.getElementById('side-nav').className = '';
document.getElementById('toc-button-img').setAttribute('src','./menu.svg');
}
})
});
window.addEventListener( 'hashchange', function (e) {
e.stopPropagation();
openMember();
} );
function openMember() {
var id = window.location.hash.substr(1),
toggler = document.getElementById( id ),
offset = toggler.getBoundingClientRect().top,
y = window.scrollY + offset - 62 - 10;
window.scrollTo(0, y);
}
</script>
<header>
<div class="navbar">
<div class="navbar-header">
<a href="https://winkjs.org/" title="wink" class="navbar-brand">
<img src="https://winkjs.org/images/logo.svg">
<span>wink</span>
</a>
</div>
<div class="sausage-links">
<ul class="nav navbar-nav navbar-right collapse navbar-collapse" id="main-nav">
<li><a href="https://winkjs.org/packages.html" class="">Packages</a></li>
<li><a href="https://winkjs.org/showcase.html" class="">Showcase</a></li>
<li><a href="https://winkjs.org/blog.html" class="">Blog</a></li>
<li><a href="http://github.com/winkjs">Github</a></li>
<li><a href="https://winkjs.org/about.html" class="">About</a></li>
</div>
</nav>
</div>
</header>
<div id="toc-button">
<img src="./menu.svg" alt="" id="toc-button-img">
</div>
<div class="content-container">
<div class="main-container">
<div id="main">
<section class="package">
<h3> </h3>
</section>
<section class="readme">
<article><h1>wink-sentiment</h1>
<p>Accurate & fast sentiment scoring of phrases with #hashtags, emoticons:) & emojis🎉</p>
<h3><a href="https://travis-ci.org/winkjs/wink-sentiment"><img src="https://api.travis-ci.org/winkjs/wink-sentiment.svg?branch=master" alt="Build Status"></a> <a href="https://coveralls.io/github/winkjs/wink-sentiment?branch=master"><img src="https://coveralls.io/repos/github/winkjs/wink-sentiment/badge.svg?branch=master" alt="Coverage Status"></a> <a href="https://david-dm.org/winkjs/wink-sentiment"><img src="https://david-dm.org/winkjs/wink-sentiment/status.svg" alt="dependencies Status"></a> <a href="https://david-dm.org/winkjs/wink-sentiment?type=dev"><img src="https://david-dm.org/winkjs/wink-sentiment/dev-status.svg" alt="devDependencies Status"></a> <a href="https://gitter.im/winkjs/Lobby"><img src="https://img.shields.io/gitter/room/nwjs/nw.js.svg" alt="Gitter"></a></h3>
<p><a href="http://winkjs.org/"><img align="right" src="https://decisively.github.io/wink-logos/logo-title.png" width="100px" ></a></p>
<p>Analyze sentiment of tweets, product reviews, social media content or any text using <strong><code>wink-sentiment</code></strong>. It is based on <a href="https://arxiv.org/abs/1103.2903">AFINN</a> and <a href="http://journals.plos.org/plosone/article?id=10.1371/journal.pone.0144296">Emoji Sentiment Ranking</a>; it's features include:</p>
<ol>
<li>Intelligent negation handling; for example, phrase "good product" will get a positive score whereas "not a good product" gets a negative score.</li>
<li>Automatic detection and scoring of two-word phrases in a text; for example, "cool stuff", "well done", and "short sighted".</li>
<li>Processes each emoji, emoticon and/or hashtag separately while scoring.</li>
<li>Embeds a powerful <a href="https://www.npmjs.com/package/wink-tokenizer">tokenizer</a> that returns the tokenized phrase.</li>
<li>Returns the sentiment score and tokens. Each token contains a set of properties defining its sentiment, if any.</li>
<li>Achieves accuracy of 77%, when validated using Amazon Product Review <a href="https://archive.ics.uci.edu/ml/machine-learning-databases/00331/">Sentiment Labelled Sentences Data Set</a> at <a href="https://archive.ics.uci.edu/ml/index.php">UCI Machine Learning Repository</a>.</li>
</ol>
<h3>Installation</h3>
<p>Use <a href="https://www.npmjs.com/package/wink-sentiment">npm</a> to install:</p>
<pre><code>npm install wink-sentiment --save
</code></pre>
<h3>Getting Started</h3>
<pre class="prettyprint source lang-javascript"><code>// Load wink-sentiment package.
var sentiment = require( 'wink-sentiment' );
// Just give any phrase and checkout the sentiment score. A positive score
// means a positive sentiment, whereas a negative score indicates a negative
// sentiment. Neutral sentiment is signalled by a near zero score.
// Positive sentiment text.
sentiment( 'Excited to be part of the @imascientist team:-)!' );
// -> { score: 5,
// normalizedScore: 2.5,
// tokenizedPhrase: [
// { value: 'Excited', tag: 'word', score: 3 },
// { value: 'to', tag: 'word' },
// { value: 'be', tag: 'word' },
// { value: 'part', tag: 'word' },
// { value: 'of', tag: 'word' },
// { value: 'the', tag: 'word' },
// { value: '@imascientist', tag: 'mention' },
// { value: 'team', tag: 'word' },
// { value: ':-)', tag: 'emoticon', score: 2 },
// { value: '!', tag: 'punctuation' }
// ]
// }
// Negative sentiment text.
console.log( sentiment( 'Not a good product :(' ) );
// -> { score: -5,
// normalizedScore: -2.5,
// tokenizedPhrase: [
// { value: 'Not', tag: 'word' },
// { value: 'a', tag: 'word', negation: true },
// { value: 'good', tag: 'word', negation: true, score: -3 },
// { value: 'product', tag: 'word' },
// { value: ':(', tag: 'emoticon', score: -2 }
// ]
// }
// Neutral sentiment text.
console.log( sentiment( 'I will meet you tomorrow.' ) );
// -> { score: 0,
// normalizedScore: 0,
// tokenizedPhrase: [
// { value: 'I', tag: 'word' },
// { value: 'will', tag: 'word' },
// { value: 'meet', tag: 'word' },
// { value: 'you', tag: 'word' },
// { value: 'tomorrow', tag: 'word' },
// { value: '.', tag: 'punctuation' }
// ]
// }
</code></pre>
<p>Try <a href="https://npm.runkit.com/wink-sentiment">experimenting with this example and more on Runkit</a> in the browser.</p>
<h3>Documentation</h3>
<p>Check out the <a href="http://winkjs.org/wink-sentiment/">wink sentiment API</a> documentation to learn more.</p>
<h3>Need Help?</h3>
<p>If you spot a bug and the same has not yet been reported, raise a new <a href="https://github.com/winkjs/wink-sentiment/issues">issue</a> or consider fixing it and sending a pull request.</p>
<h3>About wink</h3>
<p><a href="http://winkjs.org/">Wink</a> is a family of open source packages for <strong>Statistical Analysis</strong>, <strong>Natural Language Processing</strong> and <strong>Machine Learning</strong> in NodeJS. The code is <strong>thoroughly documented</strong> for easy human comprehension and has a <strong>test coverage of ~100%</strong> for reliability to build production grade solutions.</p>
<h3>Copyright & License</h3>
<p><strong>wink-sentiment</strong> is copyright 2017-18 <a href="http://graype.in/">GRAYPE Systems Private Limited</a>.</p>
<p>It is licensed under the terms of the MIT License.</p></article>
</section>
</div>
</div>
<nav id="side-nav">
<h2><a href="index.html">Summary</a></h2><h2><a href="https://github.com/winkjs/wink-sentiment" target="_blank" >Github</a></h2><h3>Global</h3><ul><li><a href="global.html#sentiment">sentiment</a></li></ul>
</nav>
</div>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.3</a> on Thu Aug 08 2019 20:49:19 GMT+0530 (IST) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
</footer>
<script>prettyPrint();</script>
<script src="scripts/linenumber.js"></script>
<script src="https://embed.runkit.com"></script>
<script type="text/javascript">
var els = document.getElementsByClassName("runkit");
Array.prototype.forEach.call(els, function(el) {
// Do stuff here
var source = el.innerHTML;
el.innerHTML = '';
var n = RunKit.createNotebook( {
element: el,
source: source
} );
});
</script>
</body>
</html>