【问题标题】:how to use analysis.sentiment.polarity in indonesian to judge sentiment如何在印度尼西亚语中使用 analysis.sentiment.polarity 来判断情绪
【发布时间】:2021-11-29 23:26:18
【问题描述】:

我使用来自 twitter 的 python 进行情感分析来判断它是消极的、积极的还是中性的,代码如下:

  hasilAnalisis = []
    
    for tweets in hasilUser:
        tweets_properties = {}
        tweets_properties['tanggal_tweet'] = tweets.created_at
        tweets_properties['pengguna'] = tweets.user.screen_name
        tweets_properties['isi_tweet'] = tweets.text
        tweets_full_cleansing = ' '.join(re.sub("(@[A-Za-z0-9]+)|([^0-9A-Za-z \t])|(\w+:\/\/\S+)"," ",tweets.text).split())
        
        analysis = TextBlob(tweets_full_cleansing)
             
        try:
            analysis = analysis.translate(to='en')
        except Exception as e:
            print(e)
        
        if analysis.sentiment.polarity > 0.0:
            tweets_properties["sentimen"] = "positif"
        elif analysis.sentiment.polarity == 0.0:
            tweets_properties["sentimen"] = "Netral"
        else:
            tweets_properties["sentimen"] = "Negatif"
            
            
        if tweets.retweet_count > 0:
            if tweets_properties not in hasilAnalisis:
                hasilAnalisis.append(tweets_properties)
        else:
        hasilAnalisis.append(tweets_properties)

问题是,由于我要查找的推文是印度尼西亚语,所以我必须先使用此代码将其翻译成英文

try:
            analysis = analysis.translate(to='en')
        except Exception as e:
            print(e)

之后代码可以根据情绪来判断或评估,因为已经转换为英文并且可以完成analysis.sentiment.polarity

有没有什么办法可以在不先翻译成英文的情况下做到这一点?

基于此https://ksnugroho.medium.com/dasar-text-preprocessing-dengan-python-a4fa52608ffe 我可以使用sastrawi 进行标记化,但不知道如何在印度尼西亚语中使用情感极性。

【问题讨论】:

    标签: python tokenize sentiment-analysis


    【解决方案1】:

    我调查了您的问题,并找到了解决此问题的方法。您可以使用:

    1. Sentiment Lexicon 印度尼西亚语This Github link

    情感词典通常适用于每种语言。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-06-04
      • 2019-09-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多