medkit.io.medkit_json.text
medkit.io.medkit_json.text#
Functions:
|
Return an iterator on text annotations loaded from a medkit-json file generated with |
|
Load a text document from a medkit-json file generated with |
|
Returns an iterator on text documents loaded from a medkit-json file generated with |
|
Save text annotations into a medkit-json file. |
|
Save a text document into a medkit-json file. |
|
Save text documents into a medkit-json file. |
- load_text_document(input_file, anns_input_file=None, encoding='utf-8')[source]#
Load a text document from a medkit-json file generated with
save_text_document()
.- Parameters
input_file (
Union
[str
,Path
]) – Path to the medkit-json file containing the documentanns_input_file (
Union
[str
,Path
,None
]) – Optional medkit-json file containing separate annotations of the document.encoding (
Optional
[str
]) – Optional encoding of input_file and anns_input_file
- Return type
- Returns
TextDocument – The text document in the file
- load_text_documents(input_file, encoding='utf-8')[source]#
Returns an iterator on text documents loaded from a medkit-json file generated with
save_text_documents()
- Parameters
input_file (
Union
[str
,Path
]) – Path to the medkit-json file containing the documentsencoding (
Optional
[str
]) – Optional encoding of input_file
- Return type
Iterator
[TextDocument
]- Returns
Iterator[TextDocument] – An iterator to the text documents in the file
- load_text_anns(input_file, encoding='utf-8')[source]#
Return an iterator on text annotations loaded from a medkit-json file generated with
save_text_anns()
- Parameters
input_file (
Union
[str
,Path
]) – Path to the medkit-json file containing the annotationsencoding (
Optional
[str
]) – Optional encoding of input_file
- Return type
Iterator
[TextAnnotation
]- Returns
Iterator[TextAnnotation] – An iterator to the text annotations in the file
- save_text_document(doc, output_file, split_anns=False, anns_output_file=None, encoding='utf-8')[source]#
Save a text document into a medkit-json file.
- Parameters
doc (
TextDocument
) – The text document to saveoutput_file (
Union
[str
,Path
]) – Path of the generated medkit-json filesplit_anns (
bool
) – If True, the annotations will be saved in a separate medkit-json file instead of being included in the main document fileanns_output_file (
Union
[str
,Path
,None
]) – 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 (
Optional
[str
]) – Optional encoding of output_file and anns_output_file
- save_text_documents(docs, output_file, encoding='utf-8')[source]#
Save text documents into a medkit-json file.
- Parameters
docs (
Iterable
[TextDocument
]) – The text documents to saveoutput_file (
Union
[str
,Path
]) – Path of the generated medkit-json fileencoding (
Optional
[str
]) – Optional encoding of output_file