克罗地亚语言的形态/屈折/词元化引擎,词性标注器,停用词
项目描述
克罗地亚语言的形态/屈折/词元化引擎
“text-hr”是使用Python编程语言编写的克罗地亚语言的形态/屈折/词元化引擎。包括停用词和基于逆屈折算法的词性标注器(POS标注)。
由于API尚未冻结,此项目仍处于alpha阶段。
标志
克罗地亚语,词元化,Python库,形态学,屈折,逆屈折,词性识别,自然语言处理,停用词,形态词汇
功能
- 以下是最重要的
屈折系统 - 用于产生一个单词的所有形式
从现有单词形式的列表中检测单词类型(词性标注)
停用词列表
系统基于Unicode字符串,默认代码页为cp-1250。
查看入门。
安装
安装说明 - 如果您已安装pip包 http://pypi.python.org/pypi/pip
pip install text-hr
- 如果没有,那么就按老方法做
解压缩
打开shell
转到分发目录
python setup.py install
入门指南
- 该项目提供三个重要部分
屈折系统 - 用于生成一个词的所有形式
词类型检测(POS 标记) - 从现有的词形列表中
屈折系统
用法示例 - 启动 Python 命令行
>>> from text_hr import Verb >>> v = Verb("platiti") >>> for k in sorted(v.forms.keys()): ... print(k, v.forms[k]) ... AOR/P/1 [u'platismo'] AOR/P/2 [u'platiste'] AOR/P/3 [u'plati\u0161e'] AOR/S/1 [u'platih'] AOR/S/2 [u'plati'] AOR/S/3 [u'plati'] IMP/P/1 [u'platasmo', u'pla\u0107asmo', u'platijasmo'] IMP/P/2 [u'plataste', u'pla\u0107aste', u'platijaste'] IMP/P/3 [u'platahu', u'pla\u0107ahu', u'platijahu'] ... VA_PA//P_O+S+V+N [u'pla\u0107eno'] X_INF// [u'platiti'] X_VAD_PAS// [u'plativ\u0161i'] X_VAD_PRE// [u'plate\u0107i'] X_VAD_PRE// [u'plate\u0107i']
词类型检测(POS 标记)
TODO: 待完成 - 检查 test_detect.txt 中的样本,以及 detect.py 中的逻辑
test_detect.txt 中的第一个示例
>>> from text_hr.detect import WordTypeRecognizerExample >>> def test_it(word_list, wt_filter=None, level=2): ... wdh = WordTypeRecognizerExample(word_list, silent=True) ... if not wt_filter is None: ... wdh.detect(wt_filter=wt_filter, level=level) # e.g. wt_filter=["N"] ... else: ... wdh.detect(level=level) # all word types ... lines_file = LinesFile() ... wdh.dump_result(lines_file) # doctest: +NORMALIZE_WHITESPACE +ELLIPSIS ... print("\n".join(lines_file.lines)) ... return wdh >>> class LinesFile(object): ... def __init__(self): ... self.lines = [] ... def write(self, s): ... self.lines.append(repr(s.rstrip())) >>> word_list = [ ... "Broj 84" ... , "broji 34" ... , "Brojila 28" ... , "broje 23" ... , "brojeći 22" ... , "brojim 7" ... , "brojimo 5" ... , "brojiš 4" ... , "brojahu 2" ... , "brojaše 1" ... , "brojite 1" ... , "-brijestovu 1" ... , "brijestovi 1" #the only one checked with endswith, but all other will be checked with get_freq ... , "-brijestove 1" ... , "-brijestova 1" ... ] Lowest quality, but fastest >>> wdh = test_it(word_list, level=4) # doctest: +ELLIPSIS " 10/ 183 -> brojati (u'V-XX_-_JATI-je\\u0107i-0') 84/broj,34/broji,23/broje,22/broje\xe6i,7/brojim,5/brojimo,4/broji\x9a,2/brojahu,1/brojite,1/broja\x9ae"
停用词列表
位于 std_words.txt 中,您可以直接从这里读取
http://bitbucket.org/trebor74hr/text-hr/src/tip/text_hr/std_words.txt
列表可以按如下方式更新
>>> import text_hr >>> text_hr.dump_all_std_words() Totaly 2904 word forms dumped to r:\hg-clones\python\text-hr\text_hr\std_words.txt in codepage utf8
遍历所有单词的方式如下
from text_hr import get_all_std_words for word_base, l_key, cnt, _suff_id, wform_key, wform in get_all_std_words(): print(word_base, l_key, cnt, _suff_id, wform_key, wform)
进一步
由于目前没有良好的文档,最佳的信息来源是阅读模块内的测试和测试目录中的测试(开发版本)。更多信息请参阅 运行测试。您始终可以阅读源代码。
文档
目前没有文档。正在进行中…
支持
由于该项目受限于我的空闲时间,支持有限。
报告错误或请求功能
如果您遇到错误,最佳做法是将错误报告到 bitbucket 网页 http://bitbucket.org/trebor74hr/text-hr。
如果对其他屈折丰富的语言开发感兴趣,我很乐意解耦特定语言代码,并创建一个能够处理多种语言的新项目。
联系我的最佳方式是通过邮件(在许可中查找)。
待办事项列表在 readme.txt 中(开发版本)。
贡献
由于该项目目前不在稳定的 API 阶段,贡献应该等待一段时间。
运行测试
所有测试都是 doctests(不是 unittests)。该软件包中有三种类型的测试
每个模块中的 doctests - 例如在 verbs.py 中
tests/test_*.txt 中的 doctests - 仅开发版本
不自动比较的测试 - 即在特殊调用模式下,detect.py 可以生成输出文件,需要手动与某些现有文件进行比较。这种测试非常慢。需要将其更改为自动。
直接运行每个模块将运行 1. 和 2.,如果从开发版本运行。要获取开发版本,请使用以下方法使用开发版本(http://bitbucket.org/trebor74hr/text-hr)
hg clone https://bitbucket.org/trebor74hr/text-hr
在 Python site-packages 目录中创建 text_hr.pth,并包含 text-hr 的路径,例如。
r:\hg-clones\python\text-hr
- 要运行所有测试
转到测试目录
运行 tests.py,例如(带有示例输出)
> python tests.py testing module __init__ testing module adjectives ... testing textfile R:\hg-clones\python\text-hr\tests\test_adj.txt ... testing textfile R:\hg-clones\python\text-hr\tests\test_verbs_type.txt
- 要运行单个模块的测试
转到 text_hr 目录
运行模块,例如
> py pronouns.py __main__: running doctests ..\tests\test_pronouns.txt: running doctests
如果您不是从 dev 版本运行,您将得到如下输出
> py pronouns.py __main__: running doctests ..\tests\test_pronouns.txt: Not found, skipping
附加信息
克罗地亚语的硕士学位论文 pdf(134 页)的标题为
Lociranje sličnih logičkih cjelina u tekstualnim dokumentima na hrvatskome jeziku
可以在以下位置找到
http://bitbucket.org/trebor74hr/text-hr/downloads/magistarski-konacni.pdf
TODO
各种事情,详细信息请参阅 readme.txt。
变更
0.20
- RL 200507
迁移到 python 3+,在 python 3.7 上测试,所有测试通过
0.18
- RL 121210
修复了 bitbucket 主页上的错误说明
0.17
- RL 100617
utf-8 设置
0.16
- RL 100617
将硕士学位论文 pdf 添加到存储库(克罗地亚语,134 页)
0.15
- RL 100617
一些小变化
0.14
- RL 100617
beta 版本
标签:词形还原,词干提取
0.13
- RL 100610
重新组织了 text_hr 软件包(__init__.py 与 __all__ 和导入…)
删除了 word_types.py
std_words.txt
0.12
- RL 100608
README
为所有测试启用了 tests.py 中的测试
从每个模块直接启用了测试
0.11
- RL 100607
在 bitbucket 上重新创建了存储库
zip 文件中没有 .suff_registry.pickle 和 testing_*.out
0.10
- RL 100605
第一个可安装版本
项目详情
下载文件
下载适用于您平台的文件。如果您不确定选择哪个,请了解有关安装包的更多信息。
源分发
构建分发
text-hr-0.20.tar.gz的散列
算法 | 散列摘要 | |
---|---|---|
SHA256 | ca1f236a9ded1b89f937308dc3084969bc972ff09b68be9e550700caa2cf536c |
|
MD5 | 9d4835cf646c68ea0619d28f6802ee86 |
|
BLAKE2b-256 | 4a0aef163de006a7f00f529a6e0ae58352d4fd85afa85092911195e19b234b0e |
text_hr-0.20-py3-none-any.whl的散列
算法 | 散列摘要 | |
---|---|---|
SHA256 | 08056e732d21c269d1b77533314ef4d7c75c81bcaf63be55cc51194f19900689 |
|
MD5 | 8d28b766b613e43fac2e2260a299d55b |
|
BLAKE2b-256 | 6e312bc50f65fc3dcb21622d93b4089f97be692dbdce7444bd253dcd46ea56d5 |