Skip to content

StefanKjartansson/ReynirPackage

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

49 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Reynir: A fast, efficient natural language parser for Icelandic

Overview

Reynir is a Python 3.x package for parsing Icelandic text into sentence 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.

Example

>>> from reynir import Reynir
>>> r = Reynir()
>>> job = r.submit("Ása sá sól.")
>>> sent = next(job.sentences())
>>> sent.parse()
True
>>> 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
      +-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'
>>> sent.tree.S.IP.NP_SUBJ.lemmas # The subject noun phrase (S.IP.NP also works)
['Ása']
>>> sent.tree.S.IP.VP.lemmas # The verb phrase
['sjá', 'sól']
>>> sent.tree.S.IP.VP.NP_OBJ.lemmas # The object within the verb phrase (S.IP.VP.NP also works)
['sól']

Prerequisites

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

You may need to have python3-dev and/or potentially python3.6-dev installed on your system to set up Reynir successfully:

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

Installation

To install this package:

$ pip3 install reynir

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

$ git clone https://github.com/vthorsteinsson/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.

About

The Reynir NLP parser for Icelandic, packaged for PyPi

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 82.7%
  • C++ 16.9%
  • Shell 0.4%