Skip to main content

A natural language parser for Icelandic

Project description

https://github.com/mideind/ReynirPackage/blob/master/doc/_static/ReynirLogo216.png?raw=true https://travis-ci.com/mideind/ReynirPackage.svg?branch=master

Overview

Reynir is a Python 3.x package for parsing Icelandic text into sentence trees (i.e. full constituency parse trees). The trees can then be used to extract information from the text, for instance about people, titles, entities, facts, actions and opinions.

Along the way, Reynir tokenizes the text, finds lemmas and assigns part-of-speech (POS) tags to every word.

Full documentation for Reynir is available here.

Reynir is the engine of Greynir.is, a natural-language front end for a database of 8 million sentences parsed from Icelandic news articles.

Reynir uses the Tokenizer package, by the same authors, to tokenize text.

Example

>>> 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']

Prerequisites

This package runs on CPython 3.4 or newer, and on PyPy 3.5 or newer.

If a binary wheel package isn’t available on PyPi for your system, you may need to have the python3-dev and/or potentially python3.6-dev packages (or their Windows equivalents) installed on your system to set up Reynir successfully. This is because a source distribution install requires a C++ compiler and linker:

# Debian or Ubuntu:
sudo apt-get install python3-dev
sudo apt-get install python3.6-dev

Installation

To install this package:

$ pip3 install reynir   # or pip install reynir if Python3 is your default

If you want to be able to edit the source, do like so (assuming you have git installed):

$ git clone https://github.com/mideind/ReynirPackage
$ cd ReynirPackage
$ # [ Activate your virtualenv here if you have one ]
$ python setup.py develop

The package source code is now in ReynirPackage/src/reynir.

Tests

To run the built-in tests, install pytest, cd to your ReynirPackage subdirectory (and optionally activate your virtualenv), then run:

$ python -m pytest

Documentation

Please consult Reynir’s documentation for detailed installation instructions, a quickstart guide, and reference information, as well as important information about copyright and licensing.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

reynir-1.7.1.tar.gz (39.3 MB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

reynir-1.7.1-cp37-cp37m-manylinux1_x86_64.whl (39.4 MB view details)

Uploaded CPython 3.7m

reynir-1.7.1-cp36-cp36m-manylinux1_x86_64.whl (39.4 MB view details)

Uploaded CPython 3.6m

reynir-1.7.1-cp35-cp35m-manylinux1_x86_64.whl (39.4 MB view details)

Uploaded CPython 3.5m

reynir-1.7.1-cp34-cp34m-manylinux1_x86_64.whl (39.4 MB view details)

Uploaded CPython 3.4m

File details

Details for the file reynir-1.7.1.tar.gz.

File metadata

  • Download URL: reynir-1.7.1.tar.gz
  • Upload date:
  • Size: 39.3 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.20.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.32.1 PyPy/7.0.0

File hashes

Hashes for reynir-1.7.1.tar.gz
Algorithm Hash digest
SHA256 8e91258a5887b9886addcec5530e2dc5594d38959a05e58aeba9afa39f7ff94f
MD5 28a0f37bd62c5bd570e5b5913be85dd4
BLAKE2b-256 d9b005657d1123026da6a04df048a10de6f8572825a4a56958375835b5f2eacf

See more details on using hashes here.

File details

Details for the file reynir-1.7.1-cp37-cp37m-manylinux1_x86_64.whl.

File metadata

  • Download URL: reynir-1.7.1-cp37-cp37m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 39.4 MB
  • Tags: CPython 3.7m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.20.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.32.1 PyPy/7.0.0

File hashes

Hashes for reynir-1.7.1-cp37-cp37m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 25a78f414cd31d4a7ab2f620d0b39da873742683b073047d608dbfe911126ab6
MD5 2bb049d311f589acd93136fd57744215
BLAKE2b-256 5b881acbadc8b02b33b7152c5438ee695a350f60547ac38c365adc96db9ae70a

See more details on using hashes here.

File details

Details for the file reynir-1.7.1-cp36-cp36m-manylinux1_x86_64.whl.

File metadata

  • Download URL: reynir-1.7.1-cp36-cp36m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 39.4 MB
  • Tags: CPython 3.6m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.20.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.32.1 PyPy/7.0.0

File hashes

Hashes for reynir-1.7.1-cp36-cp36m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 28d8ba41b11319f72142dde996198a89c1d417fc332b75af548d1d301371f990
MD5 ee10b868ad17d09542b7fd2f0d8e8d62
BLAKE2b-256 b72823c52cf5911c1b0a97a90f085fdb35d6563f64fd8d8e3fb8ad4dca3db9ab

See more details on using hashes here.

File details

Details for the file reynir-1.7.1-cp35-cp35m-manylinux1_x86_64.whl.

File metadata

  • Download URL: reynir-1.7.1-cp35-cp35m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 39.4 MB
  • Tags: CPython 3.5m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.20.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.32.1 PyPy/7.0.0

File hashes

Hashes for reynir-1.7.1-cp35-cp35m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 a29e6c10d94391e6e638b64a3336c61e3a77bd129b4e685f1ec56cb2a9570066
MD5 42faff84ff9a45553449a90dbc32d39c
BLAKE2b-256 105b4a718986d8ca508a325ed61e2b5444de161c9509284487740a291a85d239

See more details on using hashes here.

File details

Details for the file reynir-1.7.1-cp34-cp34m-manylinux1_x86_64.whl.

File metadata

  • Download URL: reynir-1.7.1-cp34-cp34m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 39.4 MB
  • Tags: CPython 3.4m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.20.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.32.1 PyPy/7.0.0

File hashes

Hashes for reynir-1.7.1-cp34-cp34m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 4901d6d0d8c0f0c929380cd3f7cb118810aa845c7312dcd5ed2a4f2bbb23cf4d
MD5 c7c558350058f222ce54f875a0ca2a94
BLAKE2b-256 5910cd90ab70c4840442aeb325e36fcb51f5509c6355050b2b16d8c6d3f9f297

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page