Package: reynir
GreynirEngineA fast, efficient natural language processor for IcelandicOverviewGreynir is a Python 3 (>= 3.8) package,
published byMiðeind ehf., forworking with Icelandic natural language text.
Greynir can parse text intosentence trees, findlemmas,
inflectnoun phrases, assignpart-of-speech tagsand much more.Greynir's sentence trees caninter aliabe used to extract
information from text, for instance about people, titles, entities, facts,
actions and opinions.Full documentation for Greynir isavailable here.Greynir is the engine ofGreynir.is,
a natural-language front end for a database of over 10 million
sentences parsed from Icelandic news articles, andEmbla, a voice-driven virtual assistant app
for smart devices such as iOS and Android phones.Greynir includes a hand-writtencontext-free grammarfor the Icelandic language, consisting of over 7,000 lines of grammatical
productions inextended Backus-Naur format.
Its fast C++ parser core is able to cope with long and ambiguous sentences,
using anEarley-type parserasenhanced by Scott and Johnstone.Greynir employs theTokenizerpackage,
by the same authors, to tokenize text, and
usesBinPackageas its database of
Icelandic vocabulary and morphology.ExamplesUse Greynir to easily inflect noun phrasesfromreynirimportNounPhraseasNl# Create a NounPhrase ('nafnliður') objectkarfa=Nl("þrír lúxus-miðar á Star Wars og tveir brimsaltir pokar af poppi")# Print the NounPhrase in the correct case for each context# (þf=þolfall/accusative, þgf=þágufall/dative). Note that# the NounPhrase class implements __format__(), allowing you# to use the case as a format specification, for instance in f-strings.print(f"Þú keyptir{karfa:þf}.")print(f"Hér er kvittunin þín fyrir{karfa:þgf}.")The program outputs the following text, correctly inflected:Þú keyptir þrjá lúxus-miða á Star Wars og tvo brimsalta poka af poppi.
Hér er kvittunin þín fyrir þremur lúxus-miðum á Star Wars og tveimur brimsöltum pokum af poppi.Use Greynir to parse a sentence>>>fromreynirimportGreynir>>>g=Greynir()>>>sent=g.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_p3NP-OBJno_et_þf_kvk/NP-OBJ/VP/IP/S-MAINp/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']PrerequisitesThis package runs on CPython 3.8 or newer, and on PyPy 3.9 or newer.To find out which version of Python you have, enter:python--versionIf a binary wheel package isn't available onPyPIfor your system, you may need to have thepython3-devpackage
(or its Windows equivalent) installed on your
system to set up Greynir successfully. This is
because a source distribution install requires a C++ compiler and linker:# Debian or Ubuntu:sudoapt-getinstallpython3-devDepending on your system, you may also need to installlibffi-dev:# Debian or Ubuntusudoapt-getinstalllibffi-devInstallationTo install this package, assuming Python 3 is your default Python:pipinstallreynirIf you havegitinstalled and want to be able to edit
the source, do like so:gitclonehttps://github.com/mideind/GreynirPackagecdGreynirPackage# [ Activate your virtualenv here if you have one ]pipinstall-e.The package source code is inGreynirPackage/src/reynir.TestsTo run the built-in tests, installpytest,cdto yourGreynirPackagesubdirectory (and optionally activate your
virtualenv), then run:python-mpytestEvaluationA parsing test pipeline for different parsing schemas, including the Greynir schema,
has been developed. It is availablehere.DocumentationPlease consultGreynir's documentationfor detailedinstallation instructions,
aquickstart guide,
andreference information,
as well as important information aboutcopyright and licensing.Copyright and licensingGreynir is Copyright © 2023 byMiðeind ehf..The original author of this software isVilhjálmur Þorsteinsson.This software is licensed under theMIT License:Permission is hereby granted, free of charge, to any personobtaining a copy of this software and associated documentationfiles (the "Software"), to deal in the Software without restriction,including without limitation the rights to use, copy, modify, merge,publish, distribute, sublicense, and/or sell copies of the Software,and to permit persons to whom the Software is furnished to do so,subject to the following conditions:The above copyright notice and this permission notice shall beincluded in all copies or substantial portions of the Software.THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OFMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANYCLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THESOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.If you would like to use this software in ways that are incompatible
with the standard MIT license,contact Miðeind ehf.to negotiate custom arrangements.GreynirPackage indirectly embeds theDatabase of Icelandic Morphology,
(Beygingarlýsing íslensks nútímamáls), abbreviated BÍN.
GreynirPackage does not claim any endorsement by the BÍN authors or copyright holders.The BÍN source data are publicly available under theCC BY-SA 4.0 license, as further
detailedhere in Englishandhere in Icelandic.In accordance with the BÍN license terms, credit is hereby given as follows:Beygingarlýsing íslensks nútímamáls. Stofnun Árna Magnússonar í íslenskum fræðum.Höfundur og ritstjóri Kristín Bjarnadóttir.