英文

codeswitch-spaeng-sentiment-analysis-lince

这是一个预训练模型,用于对西班牙-英语混合代码的情感分析,数据来源于 LinCE

这个模型是为以下仓库训练的。

https://github.com/sagorbrur/codeswitch

要安装codeswitch,请执行以下操作:

pip install codeswitch

西班牙-英语混合代码的情感分析

  • 方法-1
from transformers import AutoTokenizer, AutoModelForSequenceClassification, pipeline

tokenizer = AutoTokenizer.from_pretrained("sagorsarker/codeswitch-spaeng-sentiment-analysis-lince")

model = AutoModelForSequenceClassification.from_pretrained("sagorsarker/codeswitch-spaeng-sentiment-analysis-lince")

nlp = pipeline('sentiment-analysis', model=model, tokenizer=tokenizer)
sentence = "El perro le ladraba a La Gatita .. .. lol #teamlagatita en las playas de Key Biscayne este Memorial day"
nlp(sentence)
  • 方法-2
from codeswitch.codeswitch import SentimentAnalysis
sa = SentimentAnalysis('spa-eng')
sentence = "El perro le ladraba a La Gatita .. .. lol #teamlagatita en las playas de Key Biscayne este Memorial day"
result = sa.analyze(sentence)
print(result)