고객이나 다른 출처로부터 의견이나 리뷰를 받을 기회가 있고 그들이 얼마나 긍정적인지 평가하고 싶다고 가정합니다. 감정분석이라는 댓글을 분석하는 방법이 있습니다. 이 게시물은 C#을 사용하는 심층 신경망 모델을 기반으로 하는 감정 분석 도구에 중점을 둡니다. 이 모델은 광범위한 작업에 적합합니다.

.NET용 감정 분석 API

프로그래밍 방식으로 감정 분석을 수행하려는 경우 GroupDocs.Classification이 해당 용도를 제공합니다. 제품 리뷰, 매장 리뷰, 애플리케이션 리뷰, 피드백 등의 어조를 평가하는 데 사용할 수 있는 범용 감정 분류기를 구현합니다.

.NET용 GroupDocs.Classification

이 기사에서는 GroupDocs.Classification for .NET과 함께 C#을 사용하여 댓글을 분류하고 양성을 분석하는 방법을 안내합니다. 따라서 시작하기 전에 다음 방법 중 하나로 API를 설치해야 합니다.

  • NuGet 패키지 관리자를 사용하여 설치합니다.
  • 다운로드 DLL을 프로젝트에 참조하십시오.

C#에서 감정 분석을 사용하여 텍스트를 분류하는 방법

이러한 작업을 해결하기 위해 Classifier라는 일반 클래스를 사용하거나 좀 더 간단하고 가벼운 클래스인 Sentiment Classifier를 사용할 수 있습니다. 단계는 다음과 같습니다.

  • SentimentClassifier를 초기화합니다.
  • SentimentClassifier 클래스의 PositiveProbability 메소드를 호출하여 분석이 필요한 파라미터로 텍스트를 전달합니다.
  • PositiveProbability 메서드는 0에서 1 사이의 양성을 반환합니다.

다음은 감정 분류를 사용하여 문장의 어조를 찾는 C# 코드입니다. 다음 감정을 예로 선택했습니다.

“경험이란 우리가 실수에 붙인 이름일 뿐입니다.”

// Analyze the positivity of text using sentiment classifier in C#.
var sentiment = "Experience is simply the name we give our mistakes";
var sentimentClassifier = new SentimentClassifier();
/// PositiveProbability method returns the positive probability of the sentiment.
var positiveProbability = sentimentClassifier.PositiveProbability(sentiment);
Console.WriteLine($"Positive Probability of the sentiment { positiveProbability }");
Positive Probability of the sentiment: **0.1118**

0.5보다 큰 값은 감정이 긍정적임을 의미하고 0과 0.5 사이의 범위는 부정적임을 나타냅니다.

이제 추출된 양성에 따라 해당 베스트 클래스의 감정과 확률에 대한 베스트 클래스를 얻을 수 있습니다. 긍정적인 확률은 0.11이므로 부정적인 주석으로 분류되어야 하며 Best Class는 긍정적인 대신 부정적인이어야 합니다.

So what would be its Best Class Probability? Yes, it will be 0.89. 이제 코드에서 살펴보겠습니다.

var sentiment = "Experience is simply the name we give our mistakes";
/// Classify method returns ClassificationResult object with the best class probability and name.
var response = sentimentClassifier.Classify(sentiment);
Console.WriteLine($"Best Class Name: {response.BestClassName}");
Console.WriteLine($"Best Class Probability: { response.BestClassProbability}");
Best Class Name: **Negative**
Best Class Probability: **0.8882**

C#에서 감정 분석을 사용하여 여러 댓글 분류

일반적으로 수천 개의 의견과 피드백이 있는데 어떻게 고객의 피드백을 분석할 수 있습니까? 간단합니다. 피드백을 배열에 넣으면 됩니다. 문자열 배열을 검토 소스로 사용합니다. 또한 파일 또는 데이터베이스 또는 서비스의 구문 분석된 응답일 수 있습니다. 문자열 배열을 긍정적인 감정 확률의 float 배열로 변환할 수 있습니다.

var sentiments = new string\[\] {
                "Now that is out of the way, this thing is a beast. It is fast and runs cool.",
                "Experience is simply the name we give our mistakes",
                "When I used compressed air a cloud of dust bellowed out from the card (small scuffs and scratches).",
                "This is Pathetic."
            };
            var classifier = new GroupDocs.Classification.SentimentClassifier();
            var sentimentPositivity = sentiments.Select(x => classifier.PositiveProbability(x)).ToArray();
            Console.WriteLine(string.Join("\\n", sentimentPositivity));
**0.8959** - "Now that is out of the way, this thing is a beast..."
**0.1118** - "Experience is simply the name we give our mistakes"
**0.1252** - "When I used compressed air a cloud ..."
**0.0970** - "This is Pathetic."

목표 감정으로 무엇을 할 수 있습니까? 대상 제품, 상점 등에 대한 평균 또는 중간값을 측정할 수 있습니다. 최악의 값을 선택하고 고객에게 응답합니다. 우리는 또한 제품의 긍정적 확률 값과 평가 사이의 불일치를 찾는 것과 같은 분석을 수행할 수 있습니다.

이 게시물이 유용하기를 바랍니다. 언급된 리소스에서 C#의 텍스트 분류 또는 감정 분석에 대해 자세히 알아볼 수 있습니다.

GroupDocs.Classification API에 대해 자세히 알아보기

GitHub 예제를 다운로드하고 실행하는 것은 시작하는 가장 쉽고 쉬운 방법입니다.

또한보십시오