Share
Embed
Transcript
17 slides
-
Sentiment Analysis as a Service A case study of Twitter
Analytics Lochemem Bruno Michael United States International University - Africa -
Background Sentiment Analysis and related text-analysis techniques are available in
many contexts Renowned projects like Google Cloud NLP and MonkeyLearn are popular SaaS options Custom NLP toolkits written in Python, Java, and Julia are also prominent The SA-aa-S project combines aspects of said Sentiment Insight acquisition techniques -
Problem Statement A great deal of opinions are pulsed through
the internet - via Social Media - with great regularity There exists a need to classify - via appropriate annotation - said opinions The vastness of diverse text patterns warrants additional text analyses (collocation, keyword extraction) -
What the algorithm says Sentiment Positive Negative Neutral Compound mostly
positive 0.247 0.097 0.657 0.8776 Compound score factors in intensity of all words -
A Simple Project A SA-aa-S project which offers Sentiment, Collocation,
and Keyword analyses of Twitter text The app polls Twitter for text data; analyzes said data and conveys chart visuals to users authenticated via the platform -
Envisaged Benefits Automated text data consumption via daemon Quantification of
word and emoticon intensity Algorithmic grading of phraseme relevance Algorithmic grading of collocations -
Development Challenges Difficulty writing a fault-tolerant long-running daemon Implementing synchronous
Twitter OAauth in asynhronous environment Finding a compatible, comprehensive text analysis tool Writing performant code at all app tiers -
Salient Philosophies Functional Programming function jwtEncode(array $claims): string { $ret
= _\compose( _\partial(_\extend, JWT_DEFAULT_CLAIMS), _\partialRight( Firebase\\JWT\\JWT::encode , JWT_SECRET ) ); return $ret($claims); } -
More stuff Asynchronous programming for potent I/O ... public function
searchTweets( array $opts = [] ): PromiseInterface { $ret = _\partialRight(self::trimTweet, false); return $ret($this->_search( searchTweets , _\extend( $opts, [ include_entities => false, result_type => mixed ]) )); } ... -
Even more stuff State management for efficient data manipulation (Flux/Redux
pattern) export let oauthLoginReducer = ( state = false, action ) => { switch (action.type) { case OAUTH_LOGIN_SUCCESS: return action.result case OAUTH_LOGOUT_SUCCESS: { const { result } = action if (has(result, [ token ]) && result.token) return false } default: return state } } -
More complicated? Virtual DOM-based UI rendering const LoadingPane: React.FC<LoadingPaneType> =
({ comp, tabId }) => ( <TabPane tabId={tabId}> <Loading classes="w-5 mx-auto" /> {comp} </TabPane> ) -
How about some map-reduce? Tweet data tracking //map function (doc)
{ if (doc.created_at) { emit(new Date(doc.created_at).toDateString(), 1) } } //reduce function (keys, values, rereduce) { ... if (rereduce) { ret.total += values[acc].total ... } else { ret.total = sum(values) ... } ... } -
NLP, Anyone? Collocations via PMI function collocation(string $text): array {
$ret = (new TokensDocument(_tokenize($text))) ... ->applyTransformation(new PunctuationFilter( PUNCTUATION_LIST )) ->applyTransformation(new StopWordsFilter( STOPWORDS_LIST )) ... return (new CollocationFinder($ret->toArray(), 3)) ->getCollocationsByPmi(); }