Cleanup and apply pr suggestions

This commit is contained in:
Chi Vinh Le
2017-09-07 15:38:39 +07:00
parent b1b3db51a6
commit 43b7326db4
6 changed files with 85 additions and 94 deletions
@@ -3,8 +3,8 @@ const {API_ENDPOINT, API_KEY, TOXICITY_THRESHOLD} = require ('./config');
/**
* Get scores from the perspective api
* @param {string} text to be anaylized
* @return {object} object containing toxicity scores
* @param {string} text text to be anaylized
* @return {object} object containing toxicity scores
*/
async function getScores(text) {
const response = await fetch(`${API_ENDPOINT}/comments:analyze?key=${API_KEY}`, {
@@ -38,8 +38,8 @@ async function getScores(text) {
/**
* Get toxicity probability
* @param {object} scores as returned by `getScores`
* @return {number} toxicity probability from 0 - 1.0
* @param {object} scores scores as returned by `getScores`
* @return {number} toxicity probability from 0 - 1.0
*/
function getProbability(scores) {
return scores.SEVERE_TOXICITY.summaryScore;
@@ -47,7 +47,7 @@ function getProbability(scores) {
/**
* isToxic determines if given probabilty or scores meets the toxicity threshold.
* @param {object|number} scores or probability
* @param {object|number} scoresOrProbability scores or probability
* @return {boolean}
*/
function isToxic(scoresOrProbability) {