{"id":21769938,"url":"https://github.com/mideind/greynircorrect","last_synced_at":"2025-10-16T11:27:47.390Z","repository":{"id":39584335,"uuid":"149779532","full_name":"mideind/GreynirCorrect","owner":"mideind","description":"Spelling and grammar correction for Icelandic","archived":false,"fork":false,"pushed_at":"2025-08-29T15:45:49.000Z","size":17169,"stargazers_count":16,"open_issues_count":7,"forks_count":3,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-09-29T11:19:44.490Z","etag":null,"topics":["correction","grammar","greynir","icelandic","icelandic-language","language","nlp","python","python3","spelling"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mideind.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2018-09-21T15:05:50.000Z","updated_at":"2025-08-29T15:42:32.000Z","dependencies_parsed_at":"2022-08-01T08:09:29.056Z","dependency_job_id":"6fb6b24a-de6c-4f37-b3bd-777eef5a372f","html_url":"https://github.com/mideind/GreynirCorrect","commit_stats":{"total_commits":758,"total_committers":13,"mean_commits":58.30769230769231,"dds":0.5910290237467019,"last_synced_commit":"7ec7c8ae2cafa95de6c2387ba4a509912c7deb41"},"previous_names":[],"tags_count":28,"template":false,"template_full_name":null,"purl":"pkg:github/mideind/GreynirCorrect","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mideind%2FGreynirCorrect","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mideind%2FGreynirCorrect/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mideind%2FGreynirCorrect/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mideind%2FGreynirCorrect/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mideind","download_url":"https://codeload.github.com/mideind/GreynirCorrect/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mideind%2FGreynirCorrect/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279183449,"owners_count":26121403,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-16T02:00:06.019Z","response_time":53,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["correction","grammar","greynir","icelandic","icelandic-language","language","nlp","python","python3","spelling"],"created_at":"2024-11-26T14:10:41.915Z","updated_at":"2025-10-16T11:27:47.357Z","avatar_url":"https://github.com/mideind.png","language":"Python","readme":"\n.. image:: https://img.shields.io/badge/License-MIT-yellow.svg\n    :target: https://opensource.org/licenses/MIT\n.. image:: https://img.shields.io/badge/python-3.9-blue.svg\n    :target: https://www.python.org/downloads/release/python-390/\n.. image:: https://img.shields.io/pypi/v/reynir-correct\n    :target: https://pypi.org/project/reynir-correct/\n.. image:: https://shields.io/github/v/release/mideind/GreynirCorrect?display_name=tag\n    :target: https://github.com/mideind/GreynirCorrect/releases\n.. image:: https://github.com/mideind/GreynirCorrect/actions/workflows/python-package.yml/badge.svg\n    :target: https://github.com/mideind/GreynirCorrect/actions?query=workflow%3A%22Python+package%22\n\n==============================================================\nGreynirCorrect: Spelling and grammar correction for Icelandic\n==============================================================\n\n********\nOverview\n********\n\n**GreynirCorrect** is a Python 3 (\u003e=3.9) package and command line tool for\n**checking and correcting spelling and grammar** in Icelandic text.\n\nGreynirCorrect relies on the `Greynir \u003chttps://pypi.org/project/reynir/\u003e`__ package,\nby the same authors, to tokenize and parse text.\n\nGreynirCorrect is documented in detail `here \u003chttps://yfirlestur.is/doc/\u003e`__.\n\nThe software has three main modes of operation, described below.\n\nAs a fourth alternative, you can call the JSON REST API\nof `Yfirlestur.is \u003chttps://yfirlestur.is\u003e`__\nto apply the GreynirCorrect spelling and grammar engine to your text,\nas `documented here \u003chttps://github.com/mideind/Yfirlestur#https-api\u003e`__.\n\nToken-level correction\n----------------------\n\nGreynirCorrect can tokenize text and return an automatically corrected token stream.\nThis catches token-level errors, such as spelling errors and erroneous\nphrases, but not grammatical errors. Token-level correction is relatively fast.\n\nFull grammar analysis\n---------------------\n\nGreynirCorrect can analyze text grammatically by attempting to parse\nit, after token-level correction. The parsing is done according to Greynir's\ncontext-free grammar for Icelandic, augmented with additional production\nrules for common grammatical errors. The analysis returns a set of annotations\n(errors and suggestions) that apply to spans (consecutive tokens) within\nsentences in the resulting token list. Full grammar analysis is considerably\nslower than token-level correction.\n\nCommand-line tool\n-----------------\n\nGreynirCorrect can be invoked as a command-line tool\nto perform token-level correction and, optionally, grammar analysis.\nThe command is ``correct infile.txt outfile.txt``.\nThe command-line tool is further documented below.\n\n********\nExamples\n********\n\nTo perform token-level correction from Python code:\n\n.. code-block:: python\n\n   \u003e\u003e\u003e from reynir_correct import tokenize\n   \u003e\u003e\u003e g = tokenize(\"Af gefnu tilefni fékk fékk daninn vilja sýnum \"\n   \u003e\u003e\u003e     \"framgengt í auknu mæli.\")\n   \u003e\u003e\u003e for tok in g:\n   \u003e\u003e\u003e     print(\"{0:10} {1}\".format(tok.txt or \"\", tok.error_description))\n\nOutput::\n\n   Að         Orðasambandið 'Af gefnu tilefni' var leiðrétt í 'að gefnu tilefni'\n   gefnu\n   tilefni\n   fékk       Endurtekið orð ('fékk') var fellt burt\n   Daninn     Orð á að byrja á hástaf: 'daninn'\n   vilja      Orðasambandið 'vilja sýnum framgengt' var leiðrétt í 'vilja sínum framgengt'\n   sínum\n   framgengt\n   í          Orðasambandið 'í auknu mæli' var leiðrétt í 'í auknum mæli'\n   auknum\n   mæli\n   .\n\nTo perform full spelling and grammar analysis of a sentence from Python code:\n\n.. code-block:: python\n\n   from reynir_correct import check_single\n   sent = check_single(\"Páli, vini mínum, langaði að horfa á sjónnvarpið.\")\n   for annotation in sent.annotations:\n       print(\"{0}\".format(annotation))\n\nOutput::\n\n   000-004: P_WRONG_CASE_þgf_þf Á líklega að vera 'Pál, vin minn' / [Pál , vin minn]\n   009-009: S004   Orðið 'sjónnvarpið' var leiðrétt í 'sjónvarpið'\n\n.. code-block:: python\n\n   sent.tidy_text\n\nOutput::\n\n   'Páli, vini mínum, langaði að horfa á sjónvarpið.'\n\nThe ``annotation.start`` and ``annotation.end`` properties\n(here ``start`` is 0 and ``end`` is 4) contain the 0-based indices of the first\nand last tokens to which the annotation applies.\nThe ``annotation.start_char`` and ``annotation.end_char`` properties\ncontain the indices of the first and last character to which the\nannotation applies, within the original input string.\n\n``P_WRONG_CASE_þgf_þf`` and ``S004`` are error codes.\n\nFor more detailed, low-level control, the ``check_errors()`` function\nsupports options and can produce various types of output:\n\n.. code-block:: python\n\n   from reynir_correct import check_errors\n   x = \"Páli, vini mínum, langaði að horfa á sjónnvarpið.\"\n   options = { \"input\": x, \"annotations\": True, \"format\": \"text\" }\n   s = check_errors(**options)\n   for i in s.split(\"\\n\"):\n      print(i)\n\nOutput::\n\n   Pál, vin minn, langaði að horfa á sjónvarpið.\n   000-004: P_WRONG_CASE_þgf_þf Á líklega að vera 'Pál, vin minn' | 'Páli, vini mínum,' -\u003e 'Pál, vin minn' | None\n   009-009: S004   Orðið 'sjónnvarpið' var leiðrétt í 'sjónvarpið' | 'sjónnvarpið' -\u003e 'sjónvarpið' | None\n\n\nThe following options can be specified:\n\n+-----------------------------------+--------------------------------------------------+-----------------+\n| | Option                          | Description                                      | Default value   |\n+-----------------------------------+--------------------------------------------------+-----------------+\n| | ``input``                       | Defines the input. Can be a string or an         | ``sys.stdin``   |\n|                                   | iterable of strings, such as a file object.      |                 |\n+-----------------------------------+--------------------------------------------------+-----------------+\n| | ``all_errors``                  | Defines the level of correction.                 | ``True``        |\n| | (alias ``grammar``)             | If False, only token-level annotation is         |                 |\n|                                   | carried out. If True, sentence-level             |                 |\n|                                   | annotation is carried out.                       |                 |\n+-----------------------------------+--------------------------------------------------+-----------------+\n| | ``annotate_unparsed_sentences`` | If True, sentences that cannot be parsed         | ``True``        |\n|                                   | are annotated in their entirety as errors.       |                 |\n+-----------------------------------+--------------------------------------------------+-----------------+\n| | ``generate_suggestion_list``    | If True, annotations can in certain              | ``False``       |\n|                                   | cases contain a list of possible corrections,    |                 |\n|                                   | for the user to pick from.                       |                 |\n+-----------------------------------+--------------------------------------------------+-----------------+\n| | ``suppress_suggestions``        | If True, more farfetched automatically           | ``False``       |\n|                                   | suggested corrections are suppressed.            |                 |\n+-----------------------------------+--------------------------------------------------+-----------------+\n| | ``ignore_wordlist``             | The value is a set of strings to whitelist.      | ``set()``       |\n|                                   | Each string is a word that should not be         |                 |\n|                                   | marked as an error or corrected. The comparison  |                 |\n|                                   | is case-sensitive.                               |                 |\n+-----------------------------------+--------------------------------------------------+-----------------+\n| | ``one_sent``                    | The input contains a single sentence only.       | ``False``       |\n|                                   | Sentence splitting should not be attempted.      |                 |\n+-----------------------------------+--------------------------------------------------+-----------------+\n| | ``ignore_rules``                | A set of error codes that should be ignored      | ``set()``       |\n|                                   | in the annotation process.                       |                 |\n+-----------------------------------+--------------------------------------------------+-----------------+\n| | ``tov_config``                  | Path to an additional configuration file that    | ``False``       |\n|                                   | may be provided for correcting custom            |                 |\n|                                   | tone-of-voice issues.                            |                 |\n+-----------------------------------+--------------------------------------------------+-----------------+\n\nAn overview of error codes is available `here \u003chttps://github.com/mideind/GreynirCorrect/blob/master/doc/errorcodes.rst\u003e`__.\n\n*************\nPrerequisites\n*************\n\nGreynirCorrect runs on CPython 3.9 or newer, and on PyPy 3.9 or newer. It has\nbeen tested on Linux, macOS and Windows. The\n`PyPi package \u003chttps://pypi.org/project/reynir-correct/\u003e`_\nincludes binary wheels for common environments, but if the setup on your OS\nrequires compilation from sources, you may need\n\n.. code-block:: bash\n\n   $ sudo apt-get install python3-dev\n\n...or something to similar effect to enable this.\n\n************\nInstallation\n************\n\nTo install this package (assuming you have Python \u003e= 3.9 with ``pip`` installed):\n\n.. code-block:: bash\n\n   $ pip install reynir-correct\n\nIf you want to be able to edit the source, do like so\n(assuming you have ``git`` installed):\n\n.. code-block:: bash\n\n   $ git clone https://github.com/mideind/GreynirCorrect\n   $ cd GreynirCorrect\n   $ # [ Activate your virtualenv here if you have one ]\n   $ pip install -e .\n\nThe package source code is now in ``GreynirCorrect/src/reynir_correct``.\n\n*********************\nThe command line tool\n*********************\n\nAfter installation, the corrector can be invoked directly from the command line:\n\n.. code-block:: bash\n\n   $ correct input.txt output.txt\n\n...or:\n\n.. code-block:: bash\n\n   $ echo \"Þinngið samþikkti tilöguna\" | correct\n   Þingið samþykkti tillöguna\n\nInput and output files are encoded in UTF-8. If the files are not\ngiven explicitly, ``stdin`` and ``stdout`` are used for input and output,\nrespectively.\n\nEmpty lines in the input are treated as sentence boundaries.\n\nBy default, the output consists of one sentence per line, where each\nline ends with a single newline character (ASCII LF, ``chr(10)``, ``\"\\n\"``).\nWithin each line, tokens are separated by spaces.\n\nThe following (mutually exclusive) options can be specified\non the command line:\n\n+-------------------+---------------------------------------------------+\n| | ``--csv``       | Output token objects in CSV                       |\n|                   | format, one per line. Sentences are separated by  |\n|                   | lines containing ``0,\"\",\"\"``                      |\n+-------------------+---------------------------------------------------+\n| | ``--json``      | Output token objects in JSON format, one per line.|\n+-------------------+---------------------------------------------------+\n| | ``--normalize`` | Normalize punctuation, causing e.g. quotes to be  |\n|                   | output in Icelandic form and hyphens to be        |\n|                   | regularized.                                      |\n+-------------------+---------------------------------------------------+\n| | ``--grammar``   | Output whole-sentence annotations, including      |\n|                   | corrections and suggestions for spelling and      |\n|                   | grammar. Each sentence in the input is output as  |\n|                   | a text line containing a JSON object, terminated  |\n|                   | by a newline.                                     |\n+-------------------+---------------------------------------------------+\n\nThe CSV and JSON formats of token objects are identical to those documented\nfor the `Tokenizer package \u003chttps://github.com/mideind/Tokenizer\u003e`__.\n\nThe JSON format of whole-sentence annotations is identical to the one documented for\nthe `Yfirlestur.is HTTPS REST API \u003chttps://github.com/mideind/Yfirlestur#https-api\u003e`__.\n\nType ``correct -h`` to get a short help message.\n\n\nCommand Line Examples\n---------------------\n\n.. code-block:: bash\n\n   $ echo \"Atvinuleysi jógst um 3%\" | correct\n   Atvinnuleysi jókst um 3%\n\n\n.. code-block:: bash\n\n   $ echo \"Barnið vil grænann lit\" | correct --csv\n   6,\"Barnið\",\"\"\n   6,\"vil\",\"\"\n   6,\"grænan\",\"\"\n   6,\"lit\",\"\"\n   0,\"\",\"\"\n\n\nNote how *vil* is not corrected, as it is a valid and common word, and\nthe ``correct`` command does not perform grammar checking by default.\n\n\n.. code-block:: bash\n\n   $ echo \"Pakkin er fyrir hestin\" | correct --json\n   {\"k\":\"BEGIN SENT\"}\n   {\"k\":\"WORD\",\"t\":\"Pakkinn\"}\n   {\"k\":\"WORD\",\"t\":\"er\"}\n   {\"k\":\"WORD\",\"t\":\"fyrir\"}\n   {\"k\":\"WORD\",\"t\":\"hestinn\"}\n   {\"k\":\"END SENT\"}\n\nTo perform whole-sentence grammar checking and annotation as well as spell checking,\nuse the ``--grammar`` option:\n\n\n.. code-block:: bash\n\n   $ echo \"Ég kláraði verkefnið þrátt fyrir að ég var þreittur.\" | correct --grammar\n   {\n      \"original\":\"Ég kláraði verkefnið þrátt fyrir að ég var þreittur.\",\n      \"corrected\":\"Ég kláraði verkefnið þrátt fyrir að ég var þreyttur.\",\n      \"tokens\":[\n         {\"k\":6,\"x\":\"Ég\",\"o\":\"Ég\"},\n         {\"k\":6,\"x\":\"kláraði\",\"o\":\" kláraði\"},\n         {\"k\":6,\"x\":\"verkefnið\",\"o\":\" verkefnið\"},\n         {\"k\":6,\"x\":\"þrátt fyrir\",\"o\":\" þrátt fyrir\"},\n         {\"k\":6,\"x\":\"að\",\"o\":\" að\"},\n         {\"k\":6,\"x\":\"ég\",\"o\":\" ég\"},\n         {\"k\":6,\"x\":\"var\",\"o\":\" var\"},\n         {\"k\":6,\"x\":\"þreyttur\",\"o\":\" þreittur\"},\n         {\"k\":1,\"x\":\".\",\"o\":\".\"}\n      ],\n      \"annotations\":[\n         {\n            \"start\":6,\n            \"end\":6,\n            \"start_char\":35,\n            \"end_char\":37,\n            \"code\":\"P_MOOD_ACK\",\n            \"text\":\"Hér er réttara að nota viðtengingarhátt\n               sagnarinnar 'vera', þ.e. 'væri'.\",\n            \"detail\":\"Í viðurkenningarsetningum á borð við 'Z'\n               í dæminu 'X gerði Y þrátt fyrir að Z' á sögnin að vera\n               í viðtengingarhætti fremur en framsöguhætti.\",\n            \"suggest\":\"væri\"\n         },\n         {\n            \"start\":7,\n            \"end\":7,\n            \"start_char\":38,\n            \"end_char\":41,\n            \"code\":\"S004\",\n            \"text\":\"Orðið 'þreittur' var leiðrétt í 'þreyttur'\",\n            \"detail\":\"\",\n            \"suggest\":\"þreyttur\"\n         }\n      ]\n   }\n\n\nThe output has been formatted for legibility - each input sentence is actually\nrepresented by a JSON object in a single line of text, terminated by newline.\n\nNote that the ``corrected`` field only includes token-level spelling correction\n(in this case *þreittur* ``-\u003e`` *þreyttur*), but no grammar corrections.\nThe grammar corrections are found in the ``annotations`` list.\nTo apply corrections and suggestions from the annotations,\nreplace source text or tokens (as identified by the ``start`` and ``end``,\nor ``start_char`` and ``end_char`` properties) with the ``suggest`` field, if present.\n\n*****\nTests\n*****\n\nTo run the built-in tests, install `pytest \u003chttps://docs.pytest.org/en/latest/\u003e`_,\n``cd`` to your ``GreynirCorrect`` subdirectory (and optionally activate your\nvirtualenv), then run:\n\n.. code-block:: bash\n\n   $ python -m pytest\n\n****************\nAcknowledgements\n****************\n\nParts of this software are developed under the auspices of the\nIcelandic Government's 5-year Language Technology Programme for Icelandic,\nwhich is managed by Almannarómur and described\n`here \u003chttps://www.stjornarradid.is/lisalib/getfile.aspx?itemid=56f6368e-54f0-11e7-941a-005056bc530c\u003e`__\n(English version `here \u003chttps://clarin.is/media/uploads/mlt-en.pdf\u003e`__).\n\n*********************\nCopyright and License\n*********************\n\n.. image:: https://github.com/mideind/GreynirPackage/raw/master/doc/_static/MideindLogoVert100.png?raw=true\n   :target: https://mideind.is\n   :align: right\n   :alt: Miðeind ehf.\n\n**Copyright © 2018-2025 Miðeind ehf.**\n\nGreynirCorrect's original author is *Vilhjálmur Þorsteinsson*.\n\nThis software is licensed under the *MIT License*:\n\n   *Permission is hereby granted, free of charge, to any person\n   obtaining a copy of this software and associated documentation\n   files (the \"Software\"), to deal in the Software without restriction,\n   including without limitation the rights to use, copy, modify, merge,\n   publish, distribute, sublicense, and/or sell copies of the Software,\n   and to permit persons to whom the Software is furnished to do so,\n   subject to the following conditions:*\n\n   *The above copyright notice and this permission notice shall be\n   included in all copies or substantial portions of the Software.*\n\n   *THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\n   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\n   IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\n   CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\n   TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\n   SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*\n\n----\n\nGreynirCorrect indirectly embeds the `Database of Icelandic Morphology \u003chttps://bin.arnastofnun.is\u003e`_\n(`Beygingarlýsing íslensks nútímamáls \u003chttps://bin.arnastofnun.is\u003e`_), abbreviated BÍN,\nalong with directly using\n`Ritmyndir \u003chttps://bin.arnastofnun.is/DMII/LTdata/comp-format/nonstand-form/\u003e`_,\na collection of non-standard word forms.\nMiðeind does not claim any endorsement by the BÍN authors or copyright holders.\n\nThe BÍN source data are publicly available under the\n`CC BY-SA 4.0 license \u003chttps://creativecommons.org/licenses/by-sa/4.0/\u003e`_, as further\ndetailed `here in English \u003chttps://bin.arnastofnun.is/DMII/LTdata/conditions/\u003e`_\nand `here in Icelandic \u003chttps://bin.arnastofnun.is/gogn/mimisbrunnur/\u003e`_.\n\nIn accordance with the BÍN license terms, credit is hereby given as follows:\n\n*Beygingarlýsing íslensks nútímamáls. Stofnun Árna Magnússonar í íslenskum fræðum.*\n*Höfundur og ritstjóri Kristín Bjarnadóttir.*\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmideind%2Fgreynircorrect","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmideind%2Fgreynircorrect","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmideind%2Fgreynircorrect/lists"}