使用spaCy
是否可以将上下文状态作为令牌扩展?想像一个句子。
Now I am talking about cities and that is my current state. But now I talk about countries and then that is my state.
对于令牌Now I am talking about
,状态未知,而对于cities and that is my current state. But now I talk about
,状态为CITY
,其余状态为COUNTRY
。不用管这个坏例子。
现在我可以拥有类似的东西
Token.set_extension('state', default=None)
,然后在我匹配Doc
和cities
时更改countries
中所有剩余标记的属性,但这会使事情变慢很多,这是一个令人担忧的问题。
spaCy
是否有更聪明的方法来实现这种逻辑?