流水线

流水线函数

其他内置管道组件和辅助工具

merge_noun_chunks 函数

将名词块合并为单个词元。也可以通过字符串名称"merge_noun_chunks"调用。

名称描述
docThe Doc object to process, e.g. the Doc in the pipeline. Doc

merge_entities 函数

将命名实体合并为单个词元。也可以通过字符串名称"merge_entities"调用该功能。

名称描述
docThe Doc object to process, e.g. the Doc in the pipeline. Doc

merge_subtokens 函数

将子词合并为单个词。也可以通过字符串名称"merge_subtokens"调用。从v2.1版本开始,解析器能够预测后续应合并为单个词的"子词"。这对于中文、日语或韩语等语言特别重要,因为这些语言的"词"并非定义为由空格分隔的字符序列。该组件底层使用Matcher来查找带有依赖标签"subtok"的词序列,然后将它们合并为单个词。

名称描述
docThe Doc object to process, e.g. the Doc in the pipeline. Doc
labelThe subtoken dependency label. Defaults to "subtok". str

token_splitter 函数v3.0

将超过最小长度的标记分割为更短的标记。旨在用于transformer管道,其中过长的spaCy标记会导致输入文本超出transformer模型的最大长度限制。

设置描述
min_lengthThe minimum length for a token to be split. Defaults to 25. int
split_lengthThe length of the split tokens. Defaults to 5. int

doc_cleaner 函数v3.2.1

清理Doc属性。适用于在包含tok2vectransformer管道组件的流水线末端使用,这些组件会存储张量和其他可能占用大量内存的值,而这些值在整条流水线运行完成后通常不再需要。

设置描述
attrsA dict of the Doc attributes and the values to set them to. Defaults to {"tensor": None, "_.trf_data": None} to clean up after tok2vec and transformer components. dict
silentIf False, show warnings if attributes aren’t found or can’t be set. Defaults to True. bool

span_cleaner 函数实验性

根据键前缀从doc.spans中移除SpanGroup。当CoreferenceResolverSpanResolver配对使用时,此方法用于清理后续数据。

设置描述
prefixA prefix to check SpanGroup keys for. Any matching groups will be removed. Defaults to "coref_head_clusters". str