一个python包,用于标记和规范主要用igbo语言编写的文本
igbo-text的Python项目详细描述
什么是igbo文本
igbo文本是一个用于标记化和规范化主要用igbo语言编写的文本的库。
这是由Ifeanyi Reuben Nkechi J.,Ugwu Chidiebere,Adegbola Tunde编写的Analysis and Representation of Igbo Text Document for a Text-Based System文中的标记化和规范化算法的实现。
安装
$ pip install igbo-text
示例
标准化
from igbo_text import IgboText
# Create IgboText class instance
igbo_text = IgboText()
# normalize text
text = "Ọ nà-ezò nnukwu mmīri n'iro?"
normalized_text = igbo_text.normalize(text, convert_to_lower=True, remove_abbreviations=True)
print(normalized_text)
执行上述代码时,输出将为
na ezo nnukwu mmiri in iro
通过设置convert_to_lower=false,可以保留大写字符
通过将remove_缩写设置为true,可以不使用缩写
标记化
from igbo_text import IgboText
# Create IgboText class instance
igbo_text = IgboText()
# tokenize text
text = "Ndị Fàda kwènyèrè n'atọ̀ n'ime otù."
tokenized_text = igbo_text.tokenize(text)
print(tokenized_text)
当执行上述isi代码时,输出将是
[“nd_”,“fada”,“kwenyere”,“n'”,“at_”,“n'”,“ime”,“otu”,“]
您可以通过设置convert_to_lower=true将所有大写字符转换为小写字符。