medkit.io.medkit_json.text#
Functions#
|
Load a text document from JSON. |
|
Load multiple text documents from JSON. |
|
Load text annotations from JSON. |
|
Save a text document to JSON. |
|
Save multiple text documents to JSON. |
|
Save text annotations to JSON. |
Module Contents#
- medkit.io.medkit_json.text.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_filestr or Path
Path to the medkit-json file containing the document
- anns_input_filestr or Path, optional
Optional medkit-json file containing separate annotations of the document.
- encodingstr, default=”utf-8”
Optional encoding of input_file and anns_input_file
- Returns:
- TextDocument
The text document in the file
See also
save_text_document
Save a text document to JSON.
- medkit.io.medkit_json.text.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_filestr or Path
Path to the medkit-json file containing the documents
- encodingstr, default=”utf-8”
Optional encoding of input_file
- Returns:
- iterator of TextDocument
An iterator to the text documents in the file
See also
save_text_documents
Save multiple text documents to JSON.
- medkit.io.medkit_json.text.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_filestr or Path
Path to the medkit-json file containing the annotations
- encodingstr, default=”utf-8”
Optional encoding of input_file
- Returns:
- iterator of TextAnnotation
An iterator to the text annotations in the file
See also
save_text_anns
Save text annotations to JSON.
- medkit.io.medkit_json.text.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:
- docTextDocument
The text document to save
- output_filestr or Path
Path of the generated medkit-json file
- split_annsbool, 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_filestr 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.
- encodingstr, default=”utf-8”
Optional encoding of output_file and anns_output_file
See also
load_text_document
Load a text document from JSON.
- medkit.io.medkit_json.text.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:
- docsiterable of TextDocument
The text documents to save
- output_filestr or Path
Path of the generated medkit-json file
- encodingstr, default=”utf-8”
Optional encoding of output_file
See also
load_text_documents
Load multiple text documents from JSON.
- medkit.io.medkit_json.text.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:
- annsiterable of TextAnnotation
The text annotations to save
- output_filestr or Path
Path of the generated medkit-json file
- encodingstr, default=”utf-8”
Optional encoding of output_file
See also
load_text_anns
Load text annotations from JSON.