@happyaccident/wink-sentiment
Version:
Accurate and fast sentiment scoring of phrases with emoticons :) & emojis 🎉
521 lines (276 loc) • 9.87 kB
HTML
<html lang="en">
<head>
<meta charset="utf-8">
<title>wink-sentiment - Wink JS - Global</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">
<h1 class="page-title">Global</h1>
<section>
<header>
<!--<h2>
</h2>-->
</header>
<article>
<div class="container-overview">
<dl class="details">
<!---->
</dl>
</div>
<h3 class="subsection-title">Methods</h3>
<h4 class="name" id="sentiment">
sentiment
</h4>
<div class="name-signature"><span class="type-signature"></span>sentiment<span class="signature">(phrase)</span><span class="type-signature"> → {object}</span></div
<dl class="details">
<!--
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="wink-sentiment.js.html">wink-sentiment.js</a>, <a href="wink-sentiment.js.html#line111">line 111</a>
</li></ul></dd>
-->
</dl>
<div class="description">
<p>Computes the absolue and normalized sentiment scores of the input <code>phrase</code>,
after tokenizing it.</p>
<p>The normalized score is computed by taking into account of absolute scores of
words, emojis, emoticons, and hashtags and adjusting it on the basis of total
words in the text; this is always between -5 and +5. A score of less than 0 indicates
negative sentiments and a score of more than 0 indicates positive sentiments;
wheras a near zero score suggests a neutral sentiment. While counting tokens
only the ones tagged as <strong><code>word</code></strong>, <strong><code>emoji</code></strong>, or <strong><code>emoticon</code></strong> are counted;
and one letter words are ignored.</p>
<p>It performs tokenization using <a href="http://winkjs.org/wink-tokenizer/">wink-tokenizer</a>.
During sentiment analysis, each token may be assigned up to 3 new properties.
These properties are:</p>
<ol>
<li><strong><code>score</code></strong> — contains the sentiment score of the word, emoji, emoticon or hashtag, which is always
between -5 and +5. This is added only when the word in question has a positive or
negative sentiment associated with it.</li>
<li><strong><code>negation</code></strong> — is added & set to <strong>true</strong> whenever the <code>score</code> of the
token has beeen impacted due to a negation word apprearing prior to it.</li>
<li><strong><code>grouped</code></strong> — is added whenever, the token is the first
word of a short idiom or a phrase. It's value provides the number of tokens
that have been grouped together to form the phrase/idiom.</li>
</ol>
</div>
<h5>Example</h5>
<pre class="prettyprint"><code>sentiment( 'not a good product #fail' );
// -> { score: -5,
// normalizedScore: -2.5,
// tokenizedPhrase: [
// { value: 'not', tag: 'word' },
// { value: 'a', tag: 'word' },
// { value: 'good', tag: 'word', negation: true, score: -3 },
// { value: 'product', tag: 'word' },
// { value: '#fail', tag: 'hashtag', score: -2 }
// ]
// }</code></pre>
<h5>Parameters</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name">phrase</td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="description last"><p>whoes sentiment score needs to be computed.</p></td>
</tr>
</tbody>
</table>
<h5>Returns</h5>
<div class="param-desc">
<p>absolute <code>score</code>, <code>normalizedScore</code> and <code>tokenizedPhrase</code> of <code>phrase</code>.</p>
</div>
<dl class="param-type">
<dt>
Type
</dt>
<dd>
<span class="param-type">object</span>
</dd>
</dl>
<hr>
</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>