spacy pipeline bg
1.0.0
論文:改進的保加利亞自然語言處理管道,國際信息系統會議論文集,嵌入式系統和智能應用程序(ISHIA)2023。
首先,需要從HuggingFace下載到repo文件夾中。
為了使用管道,應將其安裝為本地Python軟件包:
python -m spacy package ./models_v3.3/model-best/ packages --name bg --version 1.0.0 --code language_components/custom_bg_lang.py
pip install packages/bg_bg-1.0.0/dist/bg_bg-1.0.0.tar.gz
您可以使用pip list命令正確安裝管道。
成功安裝後,可以在Python文件中以Spacy語言模型打開管道。需要手動添加令牌。
import spacy
nlp = spacy . load ( "bg_bg" )
from language_components . custom_tokenizer import *
nlp . tokenizer = custom_tokenizer ( nlp )有關如何使用管道的更多詳細信息,請查看模型加載和使用筆記本以及官方Spacy文檔。
管道包括以下步驟:
可以從FastText網站下載預估計的FastText矢量並將其放入vectors/文件夾中。
在下載了預定的單詞矢量和驗證的模型後,該項目應由以下文件夾組成:
configs/ - 配置文件,corpus/ - 火車/開發/測試數據集,以.spacy格式,language_components/ - 自定義語言組件的文件(tokenizer,sencencizer和connected文件),models_v3.3/ - Spacy 3.3中的訓練有素的管道模型,models_v3.4/ - Spacy 3.4中的訓練有素的管道模型,tests/ - 定制組件的Unitests,vectors/ - 審計的單詞嵌入(fastText),visualiations/ - 依賴性解析測試集的可視化。 令牌化是管道的第一步。保加利亞令牌包括自定義規則,例外和停止詞。它可以與管道的其餘部分分開使用。
基於規則的令牌規則在file language_components/custom_tokenizer.py中。它們由以下常規例外定義:
prefix_re = re . compile ( r'''^[[("'“„]''' )
suffix_re = re . compile ( r'''[])"'.?!,:%$€“„]$''' )
infix_re = re . compile ( r'''[~]''' )
simple_url_re = re . compile ( r'''^https?://''' )Tokenizer異常在file language_components/token_exceptions.py.它們在以下變量中分組:
METRICS_NO_DOT_EXC措施單位DASH_ABBR_EXC帶有內在破折號的縮寫DASH_ABBR_TITLE_EXC帶有內在破折號的縮寫,大寫ABBR_DOT_MIDDLE_EXC帶有一個不能在句子結尾處的點的縮寫ABBR_DOT_MIDDLE_TITLE_EXC與大寫字母相同ABBR_DOT_END_EXC帶有句子結尾處的點的縮寫ABBR_UPPERCASE_EXC大寫縮寫在file language_components/stopwords.py中。停止詞是從Bultreebank網站上獲取的。
有關管道中其餘部分的詳細信息,請參考文章。
如果您在學術項目中使用管道,請引用為:
@ article
{berbatova2023improved,
title={An improved Bulgarian natural language processing pipelihttps://github.com/melaniab/spacy-pipeline-bgne},
author={Berbatova, Melania and Ivanov, Filip},
journal={Annual of Sofia University St. Kliment Ohridski. Faculty of Mathematics and Informatics},
volume={110},
pages={37--50},
year={2023}
}麻省理工學院許可證
版權(C)2023 Melania Berbatova