reynir-correct


Namereynir-correct JSON
Version 4.0.0 PyPI version JSON
download
home_pagehttps://github.com/mideind/GreynirCorrect
SummaryA spelling and grammar corrector for Icelandic
upload_time2023-09-15 15:51:48
maintainer
docs_urlNone
authorMiðeind ehf
requires_python
licenseMIT
keywords nlp parser icelandic spellchecker
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            
.. image:: https://img.shields.io/badge/License-MIT-yellow.svg
    :target: https://opensource.org/licenses/MIT
.. image:: https://img.shields.io/badge/python-3.8-blue.svg
    :target: https://www.python.org/downloads/release/python-380/
.. image:: https://img.shields.io/pypi/v/reynir-correct
    :target: https://pypi.org/project/reynir-correct/
.. image:: https://shields.io/github/v/release/mideind/GreynirCorrect?display_name=tag
    :target: https://github.com/mideind/GreynirCorrect/releases
.. image:: https://github.com/mideind/GreynirCorrect/actions/workflows/python-package.yml/badge.svg
    :target: https://github.com/mideind/GreynirCorrect/actions?query=workflow%3A%22Python+package%22

==============================================================
GreynirCorrect: Spelling and grammar correction for Icelandic
==============================================================

********
Overview
********

**GreynirCorrect** is a Python 3 (>= 3.8) package and command line tool for
**checking and correcting spelling and grammar** in Icelandic text.

GreynirCorrect relies on the `Greynir <https://pypi.org/project/reynir/>`__ package,
by the same authors, to tokenize and parse text.

GreynirCorrect is documented in detail `here <https://yfirlestur.is/doc/>`__.

The software has three main modes of operation, described below.

As a fourth alternative, you can call the JSON REST API
of `Yfirlestur.is <https://yfirlestur.is>`__
to apply the GreynirCorrect spelling and grammar engine to your text,
as `documented here <https://github.com/mideind/Yfirlestur#https-api>`__.

Token-level correction
----------------------

GreynirCorrect can tokenize text and return an automatically corrected token stream.
This catches token-level errors, such as spelling errors and erroneous
phrases, but not grammatical errors. Token-level correction is relatively fast.

Full grammar analysis
---------------------

GreynirCorrect can analyze text grammatically by attempting to parse
it, after token-level correction. The parsing is done according to Greynir's
context-free grammar for Icelandic, augmented with additional production
rules for common grammatical errors. The analysis returns a set of annotations
(errors and suggestions) that apply to spans (consecutive tokens) within
sentences in the resulting token list. Full grammar analysis is considerably
slower than token-level correction.

Command-line tool
-----------------

GreynirCorrect can be invoked as a command-line tool
to perform token-level correction and, optionally, grammar analysis.
The command is ``correct infile.txt outfile.txt``.
The command-line tool is further documented below.

********
Examples
********

To perform token-level correction from Python code:

.. code-block:: python

   >>> from reynir_correct import tokenize
   >>> g = tokenize("Af gefnu tilefni fékk fékk daninn vilja sýnum "
   >>>     "framgengt í auknu mæli.")
   >>> for tok in g:
   >>>     print("{0:10} {1}".format(tok.txt or "", tok.error_description))

Output::

   Að         Orðasambandið 'Af gefnu tilefni' var leiðrétt í 'að gefnu tilefni'
   gefnu
   tilefni
   fékk       Endurtekið orð ('fékk') var fellt burt
   Daninn     Orð á að byrja á hástaf: 'daninn'
   vilja      Orðasambandið 'vilja sýnum framgengt' var leiðrétt í 'vilja sínum framgengt'
   sínum
   framgengt
   í          Orðasambandið 'í auknu mæli' var leiðrétt í 'í auknum mæli'
   auknum
   mæli
   .

To perform full spelling and grammar analysis of a sentence from Python code:

.. code-block:: python

   from reynir_correct import check_single
   sent = check_single("Páli, vini mínum, langaði að horfa á sjónnvarpið.")
   for annotation in sent.annotations:
       print("{0}".format(annotation))

Output::

   000-004: P_WRONG_CASE_þgf_þf Á líklega að vera 'Pál, vin minn' / [Pál , vin minn]
   009-009: S004   Orðið 'sjónnvarpið' var leiðrétt í 'sjónvarpið'

.. code-block:: python

   sent.tidy_text

Output::

   'Páli, vini mínum, langaði að horfa á sjónvarpið.'

The ``annotation.start`` and ``annotation.end`` properties
(here ``start`` is 0 and ``end`` is 4) contain the 0-based indices of the first
and last tokens to which the annotation applies.
The ``annotation.start_char`` and ``annotation.end_char`` properties
contain the indices of the first and last character to which the
annotation applies, within the original input string.

``P_WRONG_CASE_þgf_þf`` and ``S004`` are error codes.

For more detailed, low-level control, the ``check_errors()`` function
supports options and can produce various types of output:

.. code-block:: python

   from reynir_correct import check_errors
   x = "Páli, vini mínum, langaði að horfa á sjónnvarpið."
   options = { "input": x, "annotations": True, "format": "text" }
   s = check_errors(**options)
   for i in s.split("\n"):
      print(i)

Output::

   Pál, vin minn, langaði að horfa á sjónvarpið.
   000-004: P_WRONG_CASE_þgf_þf Á líklega að vera 'Pál, vin minn' | 'Páli, vini mínum,' -> 'Pál, vin minn' | None
   009-009: S004   Orðið 'sjónnvarpið' var leiðrétt í 'sjónvarpið' | 'sjónnvarpið' -> 'sjónvarpið' | None


The following options can be specified:

+-----------------------------------+--------------------------------------------------+-----------------+
| | Option                          | Description                                      | Default value   |
+-----------------------------------+--------------------------------------------------+-----------------+
| | ``input``                       | Defines the input. Can be a string or an         | ``sys.stdin``   |
|                                   | iterable of strings, such as a file object.      |                 |
+-----------------------------------+--------------------------------------------------+-----------------+
| | ``all_errors``                  | Defines the level of correction.                 | ``True``        |
| | (alias ``grammar``)             | If False, only token-level annotation is         |                 |
|                                   | carried out. If True, sentence-level             |                 |
|                                   | annotation is carried out.                       |                 |
+-----------------------------------+--------------------------------------------------+-----------------+
| | ``annotate_unparsed_sentences`` | If True, sentences that cannot be parsed         | ``True``        |
|                                   | are annotated in their entirety as errors.       |                 |
+-----------------------------------+--------------------------------------------------+-----------------+
| | ``generate_suggestion_list``    | If True, annotations can in certain              | ``False``       |
|                                   | cases contain a list of possible corrections,    |                 |
|                                   | for the user to pick from.                       |                 |
+-----------------------------------+--------------------------------------------------+-----------------+
| | ``suppress_suggestions``        | If True, more farfetched automatically           | ``False``       |
|                                   | suggested corrections are suppressed.            |                 |
+-----------------------------------+--------------------------------------------------+-----------------+
| | ``ignore_wordlist``             | The value is a set of strings to whitelist.      | ``set()``       |
|                                   | Each string is a word that should not be         |                 |
|                                   | marked as an error or corrected. The comparison  |                 |
|                                   | is case-sensitive.                               |                 |
+-----------------------------------+--------------------------------------------------+-----------------+
| | ``one_sent``                    | The input contains a single sentence only.       | ``False``       |
|                                   | Sentence splitting should not be attempted.      |                 |
+-----------------------------------+--------------------------------------------------+-----------------+
| | ``ignore_rules``                | A set of error codes that should be ignored      | ``set()``       |
|                                   | in the annotation process.                       |                 |
+-----------------------------------+--------------------------------------------------+-----------------+
| | ``tov_config``                  | Path to an additional configuration file that    | ``False``       |
|                                   | may be provided for correcting custom            |                 |
|                                   | tone-of-voice issues.                            |                 |
+-----------------------------------+--------------------------------------------------+-----------------+

An overview of error codes is available `here <https://github.com/mideind/GreynirCorrect/blob/master/doc/errorcodes.rst>`__.

*************
Prerequisites
*************

GreynirCorrect runs on CPython 3.8 or newer, and on PyPy 3.8 or newer. It has
been tested on Linux, macOS and Windows. The
`PyPi package <https://pypi.org/project/reynir-correct/>`_
includes binary wheels for common environments, but if the setup on your OS
requires compilation from sources, you may need

.. code-block:: bash

   $ sudo apt-get install python3-dev

...or something to similar effect to enable this.

************
Installation
************

To install this package (assuming you have Python >= 3.8 with ``pip`` installed):

.. code-block:: bash

   $ pip install reynir-correct

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

.. code-block:: bash

   $ git clone https://github.com/mideind/GreynirCorrect
   $ cd GreynirCorrect
   $ # [ Activate your virtualenv here if you have one ]
   $ pip install -e .

The package source code is now in ``GreynirCorrect/src/reynir_correct``.

*********************
The command line tool
*********************

After installation, the corrector can be invoked directly from the command line:

.. code-block:: bash

   $ correct input.txt output.txt

...or:

.. code-block:: bash

   $ echo "Þinngið samþikkti tilöguna" | correct
   Þingið samþykkti tillöguna

Input and output files are encoded in UTF-8. If the files are not
given explicitly, ``stdin`` and ``stdout`` are used for input and output,
respectively.

Empty lines in the input are treated as sentence boundaries.

By default, the output consists of one sentence per line, where each
line ends with a single newline character (ASCII LF, ``chr(10)``, ``"\n"``).
Within each line, tokens are separated by spaces.

The following (mutually exclusive) options can be specified
on the command line:

+-------------------+---------------------------------------------------+
| | ``--csv``       | Output token objects in CSV                       |
|                   | format, one per line. Sentences are separated by  |
|                   | lines containing ``0,"",""``                      |
+-------------------+---------------------------------------------------+
| | ``--json``      | Output token objects in JSON format, one per line.|
+-------------------+---------------------------------------------------+
| | ``--normalize`` | Normalize punctuation, causing e.g. quotes to be  |
|                   | output in Icelandic form and hyphens to be        |
|                   | regularized.                                      |
+-------------------+---------------------------------------------------+
| | ``--grammar``   | Output whole-sentence annotations, including      |
|                   | corrections and suggestions for spelling and      |
|                   | grammar. Each sentence in the input is output as  |
|                   | a text line containing a JSON object, terminated  |
|                   | by a newline.                                     |
+-------------------+---------------------------------------------------+

The CSV and JSON formats of token objects are identical to those documented
for the `Tokenizer package <https://github.com/mideind/Tokenizer>`__.

The JSON format of whole-sentence annotations is identical to the one documented for
the `Yfirlestur.is HTTPS REST API <https://github.com/mideind/Yfirlestur#https-api>`__.

Type ``correct -h`` to get a short help message.


Command Line Examples
---------------------

.. code-block:: bash

   $ echo "Atvinuleysi jógst um 3%" | correct
   Atvinnuleysi jókst um 3%


.. code-block:: bash

   $ echo "Barnið vil grænann lit" | correct --csv
   6,"Barnið",""
   6,"vil",""
   6,"grænan",""
   6,"lit",""
   0,"",""


Note how *vil* is not corrected, as it is a valid and common word, and
the ``correct`` command does not perform grammar checking by default.


.. code-block:: bash

   $ echo "Pakkin er fyrir hestin" | correct --json
   {"k":"BEGIN SENT"}
   {"k":"WORD","t":"Pakkinn"}
   {"k":"WORD","t":"er"}
   {"k":"WORD","t":"fyrir"}
   {"k":"WORD","t":"hestinn"}
   {"k":"END SENT"}

To perform whole-sentence grammar checking and annotation as well as spell checking,
use the ``--grammar`` option:


.. code-block:: bash

   $ echo "Ég kláraði verkefnið þrátt fyrir að ég var þreittur." | correct --grammar
   {
      "original":"Ég kláraði verkefnið þrátt fyrir að ég var þreittur.",
      "corrected":"Ég kláraði verkefnið þrátt fyrir að ég var þreyttur.",
      "tokens":[
         {"k":6,"x":"Ég","o":"Ég"},
         {"k":6,"x":"kláraði","o":" kláraði"},
         {"k":6,"x":"verkefnið","o":" verkefnið"},
         {"k":6,"x":"þrátt fyrir","o":" þrátt fyrir"},
         {"k":6,"x":"að","o":" að"},
         {"k":6,"x":"ég","o":" ég"},
         {"k":6,"x":"var","o":" var"},
         {"k":6,"x":"þreyttur","o":" þreittur"},
         {"k":1,"x":".","o":"."}
      ],
      "annotations":[
         {
            "start":6,
            "end":6,
            "start_char":35,
            "end_char":37,
            "code":"P_MOOD_ACK",
            "text":"Hér er réttara að nota viðtengingarhátt
               sagnarinnar 'vera', þ.e. 'væri'.",
            "detail":"Í viðurkenningarsetningum á borð við 'Z'
               í dæminu 'X gerði Y þrátt fyrir að Z' á sögnin að vera
               í viðtengingarhætti fremur en framsöguhætti.",
            "suggest":"væri"
         },
         {
            "start":7,
            "end":7,
            "start_char":38,
            "end_char":41,
            "code":"S004",
            "text":"Orðið 'þreittur' var leiðrétt í 'þreyttur'",
            "detail":"",
            "suggest":"þreyttur"
         }
      ]
   }


The output has been formatted for legibility - each input sentence is actually
represented by a JSON object in a single line of text, terminated by newline.

Note that the ``corrected`` field only includes token-level spelling correction
(in this case *þreittur* ``->`` *þreyttur*), but no grammar corrections.
The grammar corrections are found in the ``annotations`` list.
To apply corrections and suggestions from the annotations,
replace source text or tokens (as identified by the ``start`` and ``end``,
or ``start_char`` and ``end_char`` properties) with the ``suggest`` field, if present.

*****
Tests
*****

To run the built-in tests, install `pytest <https://docs.pytest.org/en/latest/>`_,
``cd`` to your ``GreynirCorrect`` subdirectory (and optionally activate your
virtualenv), then run:

.. code-block:: bash

   $ python -m pytest

****************
Acknowledgements
****************

Parts of this software are developed under the auspices of the
Icelandic Government's 5-year Language Technology Programme for Icelandic,
which is managed by Almannarómur and described
`here <https://www.stjornarradid.is/lisalib/getfile.aspx?itemid=56f6368e-54f0-11e7-941a-005056bc530c>`__
(English version `here <https://clarin.is/media/uploads/mlt-en.pdf>`__).

*********************
Copyright and License
*********************

.. image:: https://github.com/mideind/GreynirPackage/raw/master/doc/_static/MideindLogoVert100.png?raw=true
   :target: https://mideind.is
   :align: right
   :alt: Miðeind ehf.

**Copyright © 2023 Miðeind ehf.**

GreynirCorrect's original author is *Vilhjálmur Þorsteinsson*.

This software is licensed under the *MIT License*:

   *Permission is hereby granted, free of charge, to any person
   obtaining a copy of this software and associated documentation
   files (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 be
   included 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 OF
   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
   IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
   CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
   TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
   SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*

----

GreynirCorrect indirectly embeds the `Database of Icelandic Morphology <https://bin.arnastofnun.is>`_
(`Beygingarlýsing íslensks nútímamáls <https://bin.arnastofnun.is>`_), abbreviated BÍN,
along with directly using
`Ritmyndir <https://bin.arnastofnun.is/DMII/LTdata/comp-format/nonstand-form/>`_,
a collection of non-standard word forms.
Miðeind does not claim any endorsement by the BÍN authors or copyright holders.

The BÍN source data are publicly available under the
`CC BY-SA 4.0 license <https://creativecommons.org/licenses/by-sa/4.0/>`_, as further
detailed `here in English <https://bin.arnastofnun.is/DMII/LTdata/conditions/>`_
and `here in Icelandic <https://bin.arnastofnun.is/gogn/mimisbrunnur/>`_.

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.*


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/mideind/GreynirCorrect",
    "name": "reynir-correct",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "nlp,parser,icelandic,spellchecker",
    "author": "Mi\u00f0eind ehf",
    "author_email": "mideind@mideind.is",
    "download_url": "https://files.pythonhosted.org/packages/f0/c8/b1246a19015a648148bea38a40b1d9b262822e4f2506a02efef0afa0d2a7/reynir-correct-4.0.0.tar.gz",
    "platform": null,
    "description": "\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.8-blue.svg\n    :target: https://www.python.org/downloads/release/python-380/\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 (>= 3.8) package and command line tool for\n**checking and correcting spelling and grammar** in Icelandic text.\n\nGreynirCorrect relies on the `Greynir <https://pypi.org/project/reynir/>`__ package,\nby the same authors, to tokenize and parse text.\n\nGreynirCorrect is documented in detail `here <https://yfirlestur.is/doc/>`__.\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 <https://yfirlestur.is>`__\nto apply the GreynirCorrect spelling and grammar engine to your text,\nas `documented here <https://github.com/mideind/Yfirlestur#https-api>`__.\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   >>> from reynir_correct import tokenize\n   >>> g = tokenize(\"Af gefnu tilefni f\u00e9kk f\u00e9kk daninn vilja s\u00fdnum \"\n   >>>     \"framgengt \u00ed auknu m\u00e6li.\")\n   >>> for tok in g:\n   >>>     print(\"{0:10} {1}\".format(tok.txt or \"\", tok.error_description))\n\nOutput::\n\n   A\u00f0         Or\u00f0asambandi\u00f0 'Af gefnu tilefni' var lei\u00f0r\u00e9tt \u00ed 'a\u00f0 gefnu tilefni'\n   gefnu\n   tilefni\n   f\u00e9kk       Endurteki\u00f0 or\u00f0 ('f\u00e9kk') var fellt burt\n   Daninn     Or\u00f0 \u00e1 a\u00f0 byrja \u00e1 h\u00e1staf: 'daninn'\n   vilja      Or\u00f0asambandi\u00f0 'vilja s\u00fdnum framgengt' var lei\u00f0r\u00e9tt \u00ed 'vilja s\u00ednum framgengt'\n   s\u00ednum\n   framgengt\n   \u00ed          Or\u00f0asambandi\u00f0 '\u00ed auknu m\u00e6li' var lei\u00f0r\u00e9tt \u00ed '\u00ed auknum m\u00e6li'\n   auknum\n   m\u00e6li\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\u00e1li, vini m\u00ednum, langa\u00f0i a\u00f0 horfa \u00e1 sj\u00f3nnvarpi\u00f0.\")\n   for annotation in sent.annotations:\n       print(\"{0}\".format(annotation))\n\nOutput::\n\n   000-004: P_WRONG_CASE_\u00fegf_\u00fef \u00c1 l\u00edklega a\u00f0 vera 'P\u00e1l, vin minn' / [P\u00e1l , vin minn]\n   009-009: S004   Or\u00f0i\u00f0 'sj\u00f3nnvarpi\u00f0' var lei\u00f0r\u00e9tt \u00ed 'sj\u00f3nvarpi\u00f0'\n\n.. code-block:: python\n\n   sent.tidy_text\n\nOutput::\n\n   'P\u00e1li, vini m\u00ednum, langa\u00f0i a\u00f0 horfa \u00e1 sj\u00f3nvarpi\u00f0.'\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_\u00fegf_\u00fef`` 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\u00e1li, vini m\u00ednum, langa\u00f0i a\u00f0 horfa \u00e1 sj\u00f3nnvarpi\u00f0.\"\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\u00e1l, vin minn, langa\u00f0i a\u00f0 horfa \u00e1 sj\u00f3nvarpi\u00f0.\n   000-004: P_WRONG_CASE_\u00fegf_\u00fef \u00c1 l\u00edklega a\u00f0 vera 'P\u00e1l, vin minn' | 'P\u00e1li, vini m\u00ednum,' -> 'P\u00e1l, vin minn' | None\n   009-009: S004   Or\u00f0i\u00f0 'sj\u00f3nnvarpi\u00f0' var lei\u00f0r\u00e9tt \u00ed 'sj\u00f3nvarpi\u00f0' | 'sj\u00f3nnvarpi\u00f0' -> 'sj\u00f3nvarpi\u00f0' | 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 <https://github.com/mideind/GreynirCorrect/blob/master/doc/errorcodes.rst>`__.\n\n*************\nPrerequisites\n*************\n\nGreynirCorrect runs on CPython 3.8 or newer, and on PyPy 3.8 or newer. It has\nbeen tested on Linux, macOS and Windows. The\n`PyPi package <https://pypi.org/project/reynir-correct/>`_\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 >= 3.8 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 \"\u00deinngi\u00f0 sam\u00feikkti til\u00f6guna\" | correct\n   \u00deingi\u00f0 sam\u00feykkti till\u00f6guna\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 <https://github.com/mideind/Tokenizer>`__.\n\nThe JSON format of whole-sentence annotations is identical to the one documented for\nthe `Yfirlestur.is HTTPS REST API <https://github.com/mideind/Yfirlestur#https-api>`__.\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\u00f3gst um 3%\" | correct\n   Atvinnuleysi j\u00f3kst um 3%\n\n\n.. code-block:: bash\n\n   $ echo \"Barni\u00f0 vil gr\u00e6nann lit\" | correct --csv\n   6,\"Barni\u00f0\",\"\"\n   6,\"vil\",\"\"\n   6,\"gr\u00e6nan\",\"\"\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 \"\u00c9g kl\u00e1ra\u00f0i verkefni\u00f0 \u00fer\u00e1tt fyrir a\u00f0 \u00e9g var \u00fereittur.\" | correct --grammar\n   {\n      \"original\":\"\u00c9g kl\u00e1ra\u00f0i verkefni\u00f0 \u00fer\u00e1tt fyrir a\u00f0 \u00e9g var \u00fereittur.\",\n      \"corrected\":\"\u00c9g kl\u00e1ra\u00f0i verkefni\u00f0 \u00fer\u00e1tt fyrir a\u00f0 \u00e9g var \u00fereyttur.\",\n      \"tokens\":[\n         {\"k\":6,\"x\":\"\u00c9g\",\"o\":\"\u00c9g\"},\n         {\"k\":6,\"x\":\"kl\u00e1ra\u00f0i\",\"o\":\" kl\u00e1ra\u00f0i\"},\n         {\"k\":6,\"x\":\"verkefni\u00f0\",\"o\":\" verkefni\u00f0\"},\n         {\"k\":6,\"x\":\"\u00fer\u00e1tt fyrir\",\"o\":\" \u00fer\u00e1tt fyrir\"},\n         {\"k\":6,\"x\":\"a\u00f0\",\"o\":\" a\u00f0\"},\n         {\"k\":6,\"x\":\"\u00e9g\",\"o\":\" \u00e9g\"},\n         {\"k\":6,\"x\":\"var\",\"o\":\" var\"},\n         {\"k\":6,\"x\":\"\u00fereyttur\",\"o\":\" \u00fereittur\"},\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\u00e9r er r\u00e9ttara a\u00f0 nota vi\u00f0tengingarh\u00e1tt\n               sagnarinnar 'vera', \u00fe.e. 'v\u00e6ri'.\",\n            \"detail\":\"\u00cd vi\u00f0urkenningarsetningum \u00e1 bor\u00f0 vi\u00f0 'Z'\n               \u00ed d\u00e6minu 'X ger\u00f0i Y \u00fer\u00e1tt fyrir a\u00f0 Z' \u00e1 s\u00f6gnin a\u00f0 vera\n               \u00ed vi\u00f0tengingarh\u00e6tti fremur en frams\u00f6guh\u00e6tti.\",\n            \"suggest\":\"v\u00e6ri\"\n         },\n         {\n            \"start\":7,\n            \"end\":7,\n            \"start_char\":38,\n            \"end_char\":41,\n            \"code\":\"S004\",\n            \"text\":\"Or\u00f0i\u00f0 '\u00fereittur' var lei\u00f0r\u00e9tt \u00ed '\u00fereyttur'\",\n            \"detail\":\"\",\n            \"suggest\":\"\u00fereyttur\"\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 *\u00fereittur* ``->`` *\u00fereyttur*), 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 <https://docs.pytest.org/en/latest/>`_,\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\u00f3mur and described\n`here <https://www.stjornarradid.is/lisalib/getfile.aspx?itemid=56f6368e-54f0-11e7-941a-005056bc530c>`__\n(English version `here <https://clarin.is/media/uploads/mlt-en.pdf>`__).\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\u00f0eind ehf.\n\n**Copyright \u00a9 2023 Mi\u00f0eind ehf.**\n\nGreynirCorrect's original author is *Vilhj\u00e1lmur \u00deorsteinsson*.\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 <https://bin.arnastofnun.is>`_\n(`Beygingarl\u00fdsing \u00edslensks n\u00fat\u00edmam\u00e1ls <https://bin.arnastofnun.is>`_), abbreviated B\u00cdN,\nalong with directly using\n`Ritmyndir <https://bin.arnastofnun.is/DMII/LTdata/comp-format/nonstand-form/>`_,\na collection of non-standard word forms.\nMi\u00f0eind does not claim any endorsement by the B\u00cdN authors or copyright holders.\n\nThe B\u00cdN source data are publicly available under the\n`CC BY-SA 4.0 license <https://creativecommons.org/licenses/by-sa/4.0/>`_, as further\ndetailed `here in English <https://bin.arnastofnun.is/DMII/LTdata/conditions/>`_\nand `here in Icelandic <https://bin.arnastofnun.is/gogn/mimisbrunnur/>`_.\n\nIn accordance with the B\u00cdN license terms, credit is hereby given as follows:\n\n*Beygingarl\u00fdsing \u00edslensks n\u00fat\u00edmam\u00e1ls. Stofnun \u00c1rna Magn\u00fassonar \u00ed \u00edslenskum fr\u00e6\u00f0um.*\n*H\u00f6fundur og ritstj\u00f3ri Krist\u00edn Bjarnad\u00f3ttir.*\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A spelling and grammar corrector for Icelandic",
    "version": "4.0.0",
    "project_urls": {
        "Homepage": "https://github.com/mideind/GreynirCorrect"
    },
    "split_keywords": [
        "nlp",
        "parser",
        "icelandic",
        "spellchecker"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "beaf806f144828aec5d5c2a28047eaf51ded2af6ac847b4b8f664b26571233d0",
                "md5": "cb1c4f233269335d6bab243df62c6e40",
                "sha256": "6d9acac38f23d1eda24b9e8c9f27c139f22f380ac163eec0d4eb1bbf07db9038"
            },
            "downloads": -1,
            "filename": "reynir_correct-4.0.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "cb1c4f233269335d6bab243df62c6e40",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 3832874,
            "upload_time": "2023-09-15T15:51:44",
            "upload_time_iso_8601": "2023-09-15T15:51:44.540555Z",
            "url": "https://files.pythonhosted.org/packages/be/af/806f144828aec5d5c2a28047eaf51ded2af6ac847b4b8f664b26571233d0/reynir_correct-4.0.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f0c8b1246a19015a648148bea38a40b1d9b262822e4f2506a02efef0afa0d2a7",
                "md5": "6cecdde2999f1df432af2d8968cc4214",
                "sha256": "726d553675a9c6514249e02935e1037800f0c59f7d813ab39ec5f18fa6b07e10"
            },
            "downloads": -1,
            "filename": "reynir-correct-4.0.0.tar.gz",
            "has_sig": false,
            "md5_digest": "6cecdde2999f1df432af2d8968cc4214",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 3832034,
            "upload_time": "2023-09-15T15:51:48",
            "upload_time_iso_8601": "2023-09-15T15:51:48.909204Z",
            "url": "https://files.pythonhosted.org/packages/f0/c8/b1246a19015a648148bea38a40b1d9b262822e4f2506a02efef0afa0d2a7/reynir-correct-4.0.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-09-15 15:51:48",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "mideind",
    "github_project": "GreynirCorrect",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "reynir-correct"
}
        
Elapsed time: 0.26392s