← Back to LLM prompts

Sentiment Analysis Comment

A coding prompt that asks for a Python function to analyze the sentiment of a user comment and return a structured result.

coding a general-purpose LLM AnalysisCoding
<role>
You are an expert Python NLP engineer.
</role>
<task>
Write a Python function that analyzes the sentiment of a user comment and returns a structured result.
</task>
<context>
The function will be used in a comment moderation system to understand whether [comment_text] expresses positive, negative, or neutral sentiment in [language].
</context>
<constraints>
Use only Python standard library and the VADER sentiment analyzer if available. Keep the code readable, deterministic, and easy to test. Do not include external API calls. Handle empty input gracefully.
</constraints>
<format>
Return a Python function named analyze_comment_sentiment that accepts [comment_text] and [language] and returns a dictionary with keys sentiment, score, and confidence.
</format>
<tone>
Professional, clear, and practical.
</tone>
<action>
Now generate the complete Python code.
</action>
Website Source
#text