Colorize HTML texts by analyzing each sentence's sentiment using Cohere NLP model.
npm i cohere-sentimentify
cohere-sentimentify
uses the finance-sentiment
NLP classification model by Co:here, therefore the client application needs to apply an API key. However, this model is accessible using the trial API key, with a limit of 100 calls / minute.
cohere-sentimentify
takes in HTML as a string and produces a new HTML with the same text content and similar DOM structure but with colors (based on sentence sentiment)
import { intialize, sentimentifyHtml } from 'cohere-sentimentify';
import { readFileSync } from 'fs';
(async () => {
const API_KEY = process.env.API_KEY;
intialize(API_KEY);
const html = readFileSync('./examples/email.html', 'utf-8');
const colorizedHtml = await sentimentifyHtml(html);
console.log(colorizedHtml);
})();
This project is under the MIT license.
All contributions are welcomed!