Created
April 11, 2020 14:23
-
-
Save nickheal/a3bd6a0f1629714d52866cc148e5feca to your computer and use it in GitHub Desktop.
The joy of pipelines part 2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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