Skip to content

Instantly share code, notes, and snippets.

@nickheal
Created April 11, 2020 14:23
Show Gist options
  • Save nickheal/a3bd6a0f1629714d52866cc148e5feca to your computer and use it in GitHub Desktop.
Save nickheal/a3bd6a0f1629714d52866cc148e5feca to your computer and use it in GitHub Desktop.
The joy of pipelines part 2
import { JSDOM } from 'jsdom';
import getElements from './common/getElements';
import fetchSentiments from './common/fetchSentiments';
import formatSentiments from './common/formatSentiments';
import getSentences from './common/getSentences';
import groupSentencesUpTo5000 from './common/groupSentencesUpTo5000';
import stripNonSentences from './common/stripNonSentences';
/**
* Gets the 'sentiment' of an HTML page using the AWS Comprehend API
* @param {string} html - the html to process
*/
export default async (html) => {
const { window: { document: { body } } } = new JSDOM(html);
return body
|> getElements
|> getSentences
|> stripNonSentences
|> groupSentencesUpTo5000
|> await fetchSentiments(#)
|> formatSentiments;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment