:py:mod:`medkit.io.medkit_json.text`
====================================

.. py:module:: medkit.io.medkit_json.text


Module Contents
---------------


Functions
~~~~~~~~~

.. autoapisummary::

   medkit.io.medkit_json.text.load_text_document
   medkit.io.medkit_json.text.load_text_documents
   medkit.io.medkit_json.text.load_text_anns
   medkit.io.medkit_json.text.save_text_document
   medkit.io.medkit_json.text.save_text_documents
   medkit.io.medkit_json.text.save_text_anns



.. py:function:: load_text_document(input_file: str | pathlib.Path, anns_input_file: str | pathlib.Path | None = None, encoding: str | None = 'utf-8') -> medkit.core.text.TextDocument

   
   Load a text document from JSON.


   :Parameters:

       **input_file** : str or Path
           Path to the medkit-json file containing the document

       **anns_input_file** : str or Path, optional
           Optional medkit-json file containing separate annotations of the
           document.

       **encoding** : str, default="utf-8"
           Optional encoding of `input_file` and `anns_input_file`

   :Returns:

       TextDocument
           The text document in the file







   .. seealso::

       
       :obj:`save_text_document`
           Save a text document to JSON.
       
       





   ..
       !! processed by numpydoc !!

.. py:function:: load_text_documents(input_file: str | pathlib.Path, encoding: str | None = 'utf-8') -> Iterator[medkit.core.text.TextDocument]

   
   Load multiple text documents from JSON.


   :Parameters:

       **input_file** : str or Path
           Path to the medkit-json file containing the documents

       **encoding** : str, default="utf-8"
           Optional encoding of `input_file`

   :Returns:

       iterator of TextDocument
           An iterator to the text documents in the file







   .. seealso::

       
       :obj:`save_text_documents`
           Save multiple text documents to JSON.
       
       





   ..
       !! processed by numpydoc !!

.. py:function:: load_text_anns(input_file: str | pathlib.Path, encoding: str | None = 'utf-8') -> Iterator[medkit.core.text.TextAnnotation]

   
   Load text annotations from JSON.


   :Parameters:

       **input_file** : str or Path
           Path to the medkit-json file containing the annotations

       **encoding** : str, default="utf-8"
           Optional encoding of `input_file`

   :Returns:

       iterator of TextAnnotation
           An iterator to the text annotations in the file







   .. seealso::

       
       :obj:`save_text_anns`
           Save text annotations to JSON.
       
       





   ..
       !! processed by numpydoc !!

.. py:function:: save_text_document(doc: medkit.core.text.TextDocument, output_file: str | pathlib.Path, split_anns: bool = False, anns_output_file: str | pathlib.Path | None = None, encoding: str | None = 'utf-8')

   
   Save a text document to JSON.


   :Parameters:

       **doc** : TextDocument
           The text document to save

       **output_file** : str or Path
           Path of the generated medkit-json file

       **split_anns** : bool, default=False
           If True, the annotations will be saved in a separate medkit-json file
           instead of being included in the main document file

       **anns_output_file** : str or Path, optional
           Path of the medkit-json file storing the annotations if `split_anns` is True.
           If not provided, `output_file` will be used with an extra "_anns" suffix.

       **encoding** : str, default="utf-8"
           Optional encoding of `output_file` and `anns_output_file`








   .. seealso::

       
       :obj:`load_text_document`
           Load a text document from JSON.
       
       





   ..
       !! processed by numpydoc !!

.. py:function:: save_text_documents(docs: Iterable[medkit.core.text.TextDocument], output_file: str | pathlib.Path, encoding: str | None = 'utf-8')

   
   Save multiple text documents to JSON.


   :Parameters:

       **docs** : iterable of TextDocument
           The text documents to save

       **output_file** : str or Path
           Path of the generated medkit-json file

       **encoding** : str, default="utf-8"
           Optional encoding of `output_file`








   .. seealso::

       
       :obj:`load_text_documents`
           Load multiple text documents from JSON.
       
       





   ..
       !! processed by numpydoc !!

.. py:function:: save_text_anns(anns: Iterable[medkit.core.text.TextAnnotation], output_file: str | pathlib.Path, encoding: str | None = 'utf-8')

   
   Save text annotations to JSON.


   :Parameters:

       **anns** : iterable of TextAnnotation
           The text annotations to save

       **output_file** : str or Path
           Path of the generated medkit-json file

       **encoding** : str, default="utf-8"
           Optional encoding of `output_file`








   .. seealso::

       
       :obj:`load_text_anns`
           Load text annotations from JSON.
       
       





   ..
       !! processed by numpydoc !!

