tweet-sentiment | Serverless App that publishes sentiment score metrics | Cloud Functions library
kandi X-RAY | tweet-sentiment Summary
kandi X-RAY | tweet-sentiment Summary
This code is made available under the MIT license. See the LICENSE file.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- This method is called to publish metrics to the user
- Convert a list of Sentences to a batchDetect metric datum
- Publish sentence metrics
- Converts a batch detect item result into a metric set
- To metric metric datum
- Provide the Tweiment for Twitter
- Gets the text value
- Put the specified metric data to the cloud watch
tweet-sentiment Key Features
tweet-sentiment Examples and Code Snippets
Community Discussions
Trending Discussions on tweet-sentiment
QUESTION
I have a stream of tweets in text format (TwitterStream) and a stream of sentiments for each tweet (SentimentStream). The SentimentStream subscribes to the TwitterStream, does a sentiment analysis and publishes a new message with the result and the TwitterStream sequence number.
I'm trying to join these two streams where SentimentStream.seq is equal to the sequence number of the tweets. The problem I'm having is that I cannot get a "handle" of the sequence number from the TwitterStream.
I've been trying to find a way to get event "metadata" that might give some insights on the position / sequence number of the event.
...ANSWER
Answered 2019-Oct-28 at 12:02We have created a feature improvement request through https://github.com/siddhi-io/siddhi-io-nats/issues/25 to provide this support.
QUESTION
import sys
import json
# subroutine for calculating setiment scores for each tweets
def compute_score(text,scores):
total = 0.0
words = text.split()
for word in words:
if word in scores.keys():
total = total + scores[word]
return total
def main():
sent_file = open(sys.argv[1]) # first argument of the function call is the sentiment file
tweet_file = open(sys.argv[2]) # second argument of the function call is the tweets file
# creating a dictionary for sentiment-word mapping
scores = {} # initialize an empty dictionary to store sentiment scores for words
for line in sent_file:
term, score = line.split("\t") # The file is tab-delimited. "\t" means "tab character"
scores[term] = int(score) # Convert the score to an integer.
# creating a dictionary for tweet-sentiment_score mapping
tweets_scores = {} # initialize an empty dictionary
index = 0
for line in tweet_file:
index = index + 1
tweet = json.loads(line)
text = tweet.get("text")
# calculating setiment score
if text:
text = text.encode("utf-8")
tweets_scores[index] = compute_score(text,scores)
else: tweets_scores[index] = 0.0
# print out results
for i in tweets_scores:
print(str(tweets_scores[i]))
if __name__ == '__main__':
main()
...ANSWER
Answered 2018-Dec-29 at 09:43You have to specify your filenames as command line arguments. sys.argv is the list of command line arguments passed to a Python script.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install tweet-sentiment
Go to this app's page on the Serverless Application Repository and click "Deploy"
Go to the AWS Lambda Console and note down the name of the TweetSentiment function that was created by the deployment.
The tweet-sentiment app uses the aws-serverless-twitter-event-source app as a source of Tweet data. So after deploying the tweet-sentiment app to your account, you need to install the aws-serverless-twitter-event-source app to send twitter events to the tweet-sentiment app.
TweetProcessorFunctionName - This should be set to the name of the TweetSentiment function that you noted down when installing the tweet-sentiment app.
BatchSize - It's fine to use the aws-serverless-twitter-event-source default value of 15.
SearchText - This controls what tweets are pulled in for sentiment analysis. The search used during the live stream was #AWSLambda -filter:nativeretweets. However, you can use whatever Twitter search you'd like to perform sentiment analysis on. Note, if you want to change the SearchText after deploying the app, you can always do this via the AWS Lambda Console by finding the TwitterSearchPoller lambda created by the aws-serverless-twitter-event-source app and changing its SEARCH_TEXT environment variable value.
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page