AINLP06 – Analyze sentiment
4 mins read

AINLP06 – Analyze sentiment

(Source: https://learn.microsoft.com/en-us/training/modules/analyze-text-ai-language/5-analyze-sentiment)

Sentiment analysis is used to evaluate how positive or negative a text document is, which can be useful in various workloads, such as:

+ Evaluating a movie, book, or product by quantifying sentiment based on reviews.
+ Prioritizing customer service responses to correspondence received through email or social media messaging.
When using Azure AI Language to evaluate sentiment, the response includes overall document sentiment and individual sentence sentiment for each document submitted to the service.

For example, you could submit a single document for sentiment analysis like this:


Phân tích cảm xúc (Sentiment analysis) được sử dụng để đánh giá mức độ tích cực hay tiêu cực (to evaluate how positive or negative) của một văn bản, điều này có thể hữu ích trong nhiều công việc khác nhau (can be useful in various workloads), chẳng hạn như:

+ Đánh giá (Evaluating) một bộ phim, cuốn sách hoặc sản phẩm bằng cách định lượng cảm xúc dựa trên các đánh giá.

+ Ưu tiên phản hồi dịch vụ khách hàng (Prioritizing customer service responses to correspondence) cho các thư từ nhận được qua email hoặc tin nhắn trên mạng xã hội.

Khi sử dụng Azure AI Language để đánh giá cảm xúc (evaluate sentiment), phản hồi bao gồm cảm xúc tổng thể của tài liệu (document sentiment) và cảm xúc của từng câu (individual sentence) trong mỗi tài liệu được gửi đến dịch vụ.

Ví dụ, bạn có thể gửi một tài liệu để phân tích cảm xúc (sentiment analysis)như thế này:

{
  "kind": "SentimentAnalysis",
  "parameters": {
    "modelVersion": "latest"
  },
  "analysisInput": {
    "documents": [
      {
        "id": "1",
        "language": "en",
        "text": "Good morning!"
      }
    ]
  }
}

The response from the service might look like this:

{
  "kind": "SentimentAnalysisResults",
  "results": {
    "documents": [
      {
        "id": "1",
        "sentiment": "positive",
        "confidenceScores": {
          "positive": 0.89,
          "neutral": 0.1,
          "negative": 0.01
        },
        "sentences": [
          {
            "sentiment": "positive",
            "confidenceScores": {
              "positive": 0.89,
              "neutral": 0.1,
              "negative": 0.01
            },
            "offset": 0,
            "length": 13,
            "text": "Good morning!"
          }
        ],
        "warnings": []
      }
    ],
    "errors": [],
    "modelVersion": "2022-11-01"
  }
}

Sentence sentiment is based on confidence scores for positivenegative, and neutral classification values between 0 and 1.

Overall document sentiment is based on sentences:

  • If all sentences are neutral, the overall sentiment is neutral.
  • If sentence classifications include only positive and neutral, the overall sentiment is positive.
  • If the sentence classifications include only negative and neutral, the overall sentiment is negative.
  • If the sentence classifications include positive and negative, the overall sentiment is mixed.

Cảm xúc của câu (Sentence sentiment) dựa trên các điểm tin cậy (confidence scores) cho các giá trị phân loại tích cực, tiêu cực và trung tính (positive, negative, and neutral classification) trong khoảng từ 0 đến 1.

Cảm xúc tổng thể của tài liệu (Overall document sentiment) dựa trên các câu:

+ Nếu tất cả các câu đều là trung tính, cảm xúc tổng thể là trung tính.

+ Nếu phân loại câu chỉ bao gồm tích cực và trung tính, cảm xúc tổng thể là tích cực.

+ Nếu phân loại câu chỉ bao gồm tiêu cực và trung tính, cảm xúc tổng thể là tiêu cực.

+ Nếu phân loại câu bao gồm cả tích cực và tiêu cực, cảm xúc tổng thể là hỗn hợp.

Leave a Reply

Your email address will not be published. Required fields are marked *