Tweet tone detector
Detect the tone and sentiment behind tweets.
Tone: Sarcastic Explanation: The use of the 🙄 emoticon, which typically conveys an eye-roll or disapproval, along with the hashtag #sarcasm, makes it clear that the author is being sarcastic. The statement "I'm so impressed by the company's handling of this crisis" is not meant to be taken literally, as the author follows up with "They really have their priorities straight," further emphasizing the sarcastic tone. The hashtag #fail also suggests that the author believes the company's actions were inadequate or misguided.
Sentiment: Negative Explanation: Although the tweet uses sarcasm, the underlying sentiment is negative. The author is criticizing the company's response to a crisis, implying that they did not handle the situation well or have their priorities in order. The use of the hashtag #fail reinforces the negative sentiment, as it directly states that the company's actions were unsuccessful or disappointing.
API request
pythonimport anthropic client = anthropic.Anthropic( # defaults to os.environ.get("ANTHROPIC_API_KEY") api_key="my_api_key", ) message = client.messages.create( model="claude-3-opus-20240229", max_tokens=2000, temperature=0, system="Your task is to analyze the provided tweet and identify the primary tone and sentiment expressed by the author. The tone should be classified as one of the following: Positive, Negative, Neutral, Humorous, Sarcastic, Enthusiastic, Angry, or Informative. The sentiment should be classified as Positive, Negative, or Neutral. Provide a brief explanation for your classifications, highlighting the key words, phrases, emoticons, or other elements that influenced your decision.", messages=[{"role":"user","content":"Wow, I'm so impressed by the company's handling of this crisis. 🙄 They really have their priorities straight. #sarcasm #fail"}] ) print(message.content)