medkit.core.text.operation#

Classes#

ContextOperation

Abstract operation for context detection.

NEROperation

Abstract operation for detecting entities.

SegmentationOperation

Abstract operation for segmenting text.

CustomTextOpType

Supported function types for creating custom text operations.

Functions#

create_text_operation(→ _CustomTextOperation)

Instantiate a custom text operation from a user-defined function.

Module Contents#

class medkit.core.text.operation.ContextOperation(uid: str | None = None, name: str | None = None, **kwargs)#

Bases: medkit.core.operation.Operation

Abstract operation for context detection.

It uses a list of segments as input for running the operation and creates attributes that are directly appended to these segments.

abstract run(segments: list[medkit.core.text.annotation.Segment]) None#
class medkit.core.text.operation.NEROperation(uid: str | None = None, name: str | None = None, **kwargs)#

Bases: medkit.core.operation.Operation

Abstract operation for detecting entities.

It uses a list of segments as input and produces a list of detected entities.

abstract run(segments: list[medkit.core.text.annotation.Segment]) list[medkit.core.text.annotation.Entity]#
class medkit.core.text.operation.SegmentationOperation(uid: str | None = None, name: str | None = None, **kwargs)#

Bases: medkit.core.operation.Operation

Abstract operation for segmenting text.

It uses a list of segments as input and produces a list of new segments.

abstract run(segments: list[medkit.core.text.annotation.Segment]) list[medkit.core.text.annotation.Segment]#
class medkit.core.text.operation.CustomTextOpType#

Bases: enum.IntEnum

Supported function types for creating custom text operations.

CREATE_ONE_TO_N = 1#

Take 1 data item, return N new data items.

EXTRACT_ONE_TO_N = 2#

Take 1 data item, return N existing data items

FILTER = 3#

Take 1 data item, return True or False.

medkit.core.text.operation.create_text_operation(function: Callable, function_type: CustomTextOpType, name: str | None = None, args: dict | None = None) _CustomTextOperation#

Instantiate a custom text operation from a user-defined function.

Parameters:
functionCallable

User-defined function

function_typeCustomTextOpType

Type of function. Supported values are defined in CustomTextOpType

namestr, optional

Name of the operation used for provenance info (default: function name)

argsstr, optional

Dictionary containing the arguments of the function if any.

Returns:
_CustomTextOperation

An instance of a custom text operation