小编use*_*007的帖子

Spacy - Tokenize引用字符串

我正在使用spacy 2.0并使用带引号的字符串作为输入.

示例字符串

"The quoted text 'AA XX' should be tokenized"
Run Code Online (Sandbox Code Playgroud)

并期望提取

[The, quoted, text, 'AA XX', should, be, tokenized]
Run Code Online (Sandbox Code Playgroud)

然而,我在尝试时得到了一些奇怪的结果.Noun chunk和ents失去了其中一个引用.

import spacy
nlp = spacy.load('en')
s = "The quoted text 'AA XX' should be tokenized"
doc = nlp(s)
print([t for t in doc])
print([t for t in doc.noun_chunks])
print([t for t in doc.ents])
Run Code Online (Sandbox Code Playgroud)

结果

[The, quoted, text, ', AA, XX, ', should, be, tokenized]
[The quoted text 'AA XX]
[AA XX']
Run Code Online (Sandbox Code Playgroud)

解决我需要什么的最佳方法是什么

nlp python-3.x spacy

6
推荐指数
1
解决办法
1788
查看次数

标签 统计

nlp ×1

python-3.x ×1

spacy ×1