medkit.text.segmentation.syntagma_tokenizer
medkit.text.segmentation.syntagma_tokenizer#
Classes:
|
Syntagma segmentation annotator based on provided separators |
- class SyntagmaTokenizer(separators=None, output_label='syntagma', strip_chars='.;,?! \n\r\t', attrs_to_copy=None, uid=None)[source]#
Syntagma segmentation annotator based on provided separators
Instantiate the syntagma tokenizer
- Parameters
separators (Tuple[str, ...]) – The tuple of regular expressions corresponding to separators. If None provided, the rules in “default_syntagma_definitiion.yml” will be used.
output_label (str, Optional) – The output label of the created annotations.
strip_chars (
str
) – The list of characters to strip at the beginning of the returned segment.attrs_to_copy (
Optional
[List
[str
]]) – Labels of the attributes that should be copied from the input segment to the derived segment. For example, useful for propagating section name.uid (str, Optional) – Identifier of the tokenizer
Methods:
load_syntagma_definition
(filepath[, encoding])Load the syntagma definition stored in yml file
run
(segments)Return syntagmes detected in segments.
save_syntagma_definition
(syntagma_seps, filepath)Save syntagma yaml definition file
set_prov_tracer
(prov_tracer)Enable provenance tracing.
Attributes:
Contains all the operation init parameters.
- static load_syntagma_definition(filepath, encoding=None)[source]#
Load the syntagma definition stored in yml file
- Parameters
filepath (
Path
) – Path to a yml file containing the syntagma separatorsencoding (
Optional
[str
]) – Encoding of the file to open
- Return type
Tuple
[str
, …]- Returns
Tuple[str, …] – Tuple containing the separators
- property description: medkit.core.operation_desc.OperationDescription#
Contains all the operation init parameters.
- Return type
- static save_syntagma_definition(syntagma_seps, filepath, encoding=None)[source]#
Save syntagma yaml definition file
- Parameters
syntagma_seps (
Tuple
[str
, …]) – The tuple of regular expressions corresponding to separatorsfilepath (
Path
) – The path of the file to saveencoding (
Optional
[str
]) – The encoding of the file. Default: None
- set_prov_tracer(prov_tracer)#
Enable provenance tracing.
- Parameters
prov_tracer (
ProvTracer
) – The provenance tracer used to trace the provenance.