在heb中使用polyglot包进行命名实体识别

2024-10-06 12:25:19 发布

您现在位置:Python中文网/ 问答频道 /正文

我尝试使用polyglot包在希伯来语中进行命名实体识别。
这是我的代码:

# -*- coding: utf8 -*-
import polyglot
from polyglot.text import Text, Word
from polyglot.downloader import downloader
downloader.download("embeddings2.iw")
text = Text(u"in france and in germany")
print(type(text))
text2 = Text(u"נסעתי מירושלים לתל אביב")
print(type(text2))
print(text.entities)
print(text2.entities)

这是输出:

^{pr2}$

英国人有用,但希伯来人不行。
无论我是否尝试下载包u'embeddings2.iw',我都得到:

ValueError: Package u'embeddings2.iw' not found in index

Tags: textinfromimport实体typedownloader命名
1条回答
网友
1楼 · 发布于 2024-10-06 12:25:19

我明白了!
在我看来这是个虫子。
语言检测将语言定义为'iw',这是以前用于希伯来语的iso639语言代码,并被改为'he'text.entities无法识别iw代码,因此我将其更改如下:

text2.hint_language_code = 'he'

相关问题 更多 >