英文

codeswitch-hineng-ner-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-ner-lince")

model = AutoModelForTokenClassification.from_pretrained("sagorsarker/codeswitch-hineng-ner-lince")

ner_model = pipeline('ner', model=model, tokenizer=tokenizer)

ner_model("put any hindi english code-mixed sentence")
  • 方法-2
from codeswitch.codeswitch import NER
ner = NER('hin-eng')
text = "" # your mixed sentence 
result = ner.tag(text)
print(result)