spaCy - Retokenizer.merge 方法



此 retokenizer 方法將標記一段 span 進行合併。

引數

下表解釋了它的引數 −

名稱 型別 說明
Span Span 它表示要合併的 span。
Attrs dict 這些是要在合併的 token 上設定的屬性。

示例

Retokenizer.merge 方法的示例如下 −

import spacy
nlp_model = spacy.load("en_core_web_sm")
doc = nlp_model("This is Tutorialspoint.com.")
with doc.retokenize() as retokenizer:
   attrs = {"LEMMA": "Tutorialspoint.com"}
   retokenizer.merge(doc[2:4], attrs=attrs)
doc

輸出

您會收到以下輸出 −

This is Tutorialspoint.com.
spacy_doc_class_contextmanager_and_property.htm
廣告
© . All rights reserved.