spaCy SPECIAL-1令牌覆盖后缀规则,导致注释未对齐

时间:2020-04-14 14:26:08

标签: python tokenize spacy rules

我的文字就像

'Laboratories, Inc.'

哪个被标记化

Laboratories     TOKEN
,    SUFFIX
Inc.     SPECIAL-1

但是注释通常不包含诸如'。'之类的后缀字符。

因此,我尝试添加后缀规则以对'。'进行标记。

(r'[.]+$',) 

但是它不适用于'Inc.'这样的字符串。或“圣”标记为SPECIAL-1 问题是这样的,而像这样的标记化问题由于这些未对齐问题而导致大量注释被忽略,从而大大减少了训练过程中有价值的示例。

任何建议都值得赞赏。

1 个答案:

答案 0 :(得分:2)

令牌生成器例外(也:特殊情况,规则)比其他模式具有优先权,因此您需要删除不需要的特殊情况。

class Dogs { //Declare Dog Variables string name; string breed; string colour; string gender; public Dogs() { name = null; breed = null; colour = null; gender = null; Dogs dogList = new Dogs(); } public Dogs(string dogName, string dogBreed, string dogColour, string dogGender) { name = dogName; breed = dogBreed; colour = dogColour; gender = dogGender; } public void Display() { if (name == null || breed == null || colour == null || gender == null) { Console.Write("No dog record exists"); } else { Console.WriteLine("The dogs name is: " + name); Console.WriteLine("The breed of the dog is: " + breed); Console.WriteLine("The colour of the dog is: " + colour); Console.WriteLine("The dogs gender is: " + gender); } } } 包含特殊情况,您可以对其进行修改。删除所有带句点的例外,例如:

nlp.tokenizer.rules