Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Rule-based facts extraction for Russian language

License

NotificationsYou must be signed in to change notification settings

natasha/yargy

Repository files navigation

CI

Yargy uses rules and dictionaries to extract structured information from Russian texts. Yargy is similar toTomita parser.

Install

Yargy supports Python 3.7+, PyPy 3, depends only onPymorphy2.

$ pip install yargy

Usage

fromyargyimportParser,rule,and_,not_fromyargy.interpretationimportfactfromyargy.predicatesimportgramfromyargy.relationsimportgnc_relationfromyargy.pipelinesimportmorph_pipelineName=fact('Name',    ['first','last'],)Person=fact('Person',    ['position','name'])LAST=and_(gram('Surn'),not_(gram('Abbr')),)FIRST=and_(gram('Name'),not_(gram('Abbr')),)POSITION=morph_pipeline(['управляющий директор','вице-мэр'])gnc=gnc_relation()NAME=rule(FIRST.interpretation(Name.first    ).match(gnc),LAST.interpretation(Name.last    ).match(gnc)).interpretation(Name)PERSON=rule(POSITION.interpretation(Person.position    ).match(gnc),NAME.interpretation(Person.name    )).interpretation(Person)parser=Parser(PERSON)match=parser.match('управляющий директор Иван Ульянов')print(match)Person(position='управляющий директор',name=Name(first='Иван',last='Ульянов'    ))

Documentation

All materials are in Russian:

Support

Development

Dev env

brew install graphvizpython -m venv~/.venvs/natasha-yargysource~/.venvs/natasha-yargy/bin/activatepip install -r requirements/dev.txtpip install -e.python -m ipykernel install --user --name natasha-yargy

Test + lint

maketest

Update docs

make exec-docs# Manually check git diff docs/, commit

Release

# Update setup.py versiongit commit -am'Up version'git tag v0.16.0git pushgit push --tags# Github Action builds dist and publishes to PyPi

[8]ページ先頭

©2009-2025 Movatter.jp