简体   繁体   English

如何获取属性的实际文档字符串

[英]how to get the actual docstring of an attribute

I wanted to find out what .ent_iob_ was by doing this: 我想通过以下操作找出.ent_iob_是什么:

doc = nlp('Hello World!')
token = doc[0]
token.ent_iob_?

The help returned these: 帮助返回了以下内容:

Type:        str
String form: O
Length:      1
Docstring:  
str(object='') -> str
str(bytes_or_buffer[, encoding[, errors]]) -> str

Create a new string object from the given object. If encoding or
errors is specified, then the object must expose a data buffer
that will be decoded using the given encoding and error handler.
Otherwise, returns the result of object.__str__() (if defined)
or repr(object).
encoding defaults to sys.getdefaultencoding().
errors defaults to 'strict'.

Instead of this: 代替这个:

"""
IOB code of named entity tag. "B" means the token begins an entity, "I" means it is inside an entity, "O" means it is outside an entity, and "" means no entity tag is set.
"""

Could someone please point out what I did wrong? 有人可以指出我做错了什么吗? Thank you in advance! 先感谢您!

I just accidentally figured this out: 我只是不小心发现了这一点:

spacy.tokens.token.Token.ent_iob_?

will return the desired explanation: 将返回所需的解释:

Type:        getset_descriptor
String form: <attribute 'ent_iob_' of 'spacy.tokens.token.Token' objects>
Docstring:  
IOB code of named entity tag. "B" means the token begins an entity,
"I" means it is inside an entity, "O" means it is outside an entity,
and "" means no entity tag is set.

RETURNS (unicode): IOB code of named entity tag.

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

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