英文

codeswitch-hineng-lid-lince

这是一个用于识别印地英语代码混合数据的预训练语言识别模型,从 LinCE 中使用。

此模型是根据以下存储库进行训练的。

https://github.com/sagorbrur/codeswitch

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

pip install codeswitch

识别语言

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

tokenizer = AutoTokenizer.from_pretrained("sagorsarker/codeswitch-hineng-lid-lince")

model = AutoModelForTokenClassification.from_pretrained("sagorsarker/codeswitch-hineng-lid-lince")
lid_model = pipeline('ner', model=model, tokenizer=tokenizer)

lid_model("put any hindi english code-mixed sentence")
  • 方法-2
from codeswitch.codeswitch import LanguageIdentification
lid = LanguageIdentification('hin-eng') 
text = "" # your code-mixed sentence 
result = lid.identify(text)
print(result)