mirror of
https://github.com/wassname/talk.git
synced 2026-09-10 12:43:11 +08:00
Cleanup and apply pr suggestions
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user