冰岛语的自然语言分析器
reynir的Python项目详细描述
概述
reynir是用于 将冰岛文本解析成句子树(即full 选区解析树)。这些树可以用来提取 来自文本的信息,例如关于人、头衔、实体的信息, 事实、行动和意见。
一路上,reynir标记文本,找到lemmas并分配 part of speech(pos)标记每个单词。
reynir的完整文档是available here。
雷诺是自然语言Greynir.is的引擎 800万个冰岛语句子数据库的前端 新闻文章。
雷尼尔使用Tokenizer包, 由相同的作者来标记文本。
示例
>>> from reynir import Reynir >>> r = Reynir() >>> sent = r.parse_single("Ása sá sól.") >>> print(sent.tree.view) P # Root +-S-MAIN # Main sentence +-IP # Inflected phrase +-NP-SUBJ # Noun phrase, subject +-no_et_nf_kvk: 'Ása' # Noun, singular, nominative, feminine +-VP # Verb phrase containing arguments +-VP # Verb phrase containing verb +-so_1_þf_et_p3: 'sá' # Verb, 1 accusative arg, singular, 3rd p +-NP-OBJ # Noun phrase, object +-no_et_þf_kvk: 'sól' # Noun, singular, accusative, feminine +-'.' # Punctuation >>> sent.tree.nouns ['Ása', 'sól'] >>> sent.tree.verbs ['sjá'] >>> sent.tree.flat 'P S-MAIN IP NP-SUBJ no_et_nf_kvk /NP-SUBJ VP so_1_þf_et_p3 NP-OBJ no_et_þf_kvk /NP-OBJ /VP /IP /S-MAIN p /P' >>> # The subject noun phrase (S.IP.NP also works) >>> sent.tree.S.IP.NP_SUBJ.lemmas ['Ása'] >>> # The verb phrase >>> sent.tree.S.IP.VP.lemmas ['sjá', 'sól'] >>> # The object within the verb phrase (S.IP.VP.NP also works) >>> sent.tree.S.IP.VP.NP_OBJ.lemmas ['sól']
先决条件
这个包运行在cpython 3.4或更新版本上,pypy3.5或更新版本上。
如果PyPi上没有二进制轮包 对于您的系统,您可能需要有python3-dev和/或潜在的 python3.6-dev安装在 系统成功设置Reynir。这是因为 安装需要一个C++编译器和链接器:
# Debian or Ubuntu: sudo apt-get install python3-dev sudo apt-get install python3.6-dev
安装
要安装此软件包:
$ pip3 install reynir # or pip install reynir if Python3 is your default
如果您希望能够编辑源代码,请这样做(假设 您已经安装了git:
$ git clone https://github.com/mideind/ReynirPackage $ cd ReynirPackage $ # [ Activate your virtualenv here if you have one ] $ python setup.py develop
包源代码现在位于ReynirPackage/src/reynir中。
文档
详情请咨询Reynir’s documentationinstallation instructions, 一个quickstart guide, 以及reference information, 以及重要信息 关于copyright and licensing。