简体   繁体   English

如何将 spaCy 令牌 `ent_type` 的 `int` hash 值与字符串相关联?

[英]How do I correlate the `int` hash value of a spaCy Token `ent_type` to a string?

Is there some way to decode the hash of spaCy token entity types without accessing the ent_type_ attribute?是否有某种方法可以在不访问ent_type_属性的情况下解码 spaCy 令牌实体类型的 hash?

For example:例如:

for token in doc:
    hash_val = token.ent_type
    string_repr = some_map[hash_val]

It's stored in the vocab.它存储在词汇表中。

nlp.vocab.strings[token.ent_type] == token.ent_type_

Not sure why you would need to do that though.不知道为什么你需要这样做。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM