nlu.annotation.semantic_annotation

Semantic annotation is annotation that stores certain insight from text. Some text can have many such annotations.

Module Contents

Classes

AnnotationType

Types of annotations

EntityType

Types of entities. These are subcategories for NAMED_ENTITY annotation

SemanticAnnotation

class nlu.annotation.semantic_annotation.AnnotationType

Bases: enum.Enum

Types of annotations

NAMED_ENTITY = 0
TEMPORAL = 1
KEYWORD = 2
class nlu.annotation.semantic_annotation.EntityType

Bases: enum.Enum

Types of entities. These are subcategories for NAMED_ENTITY annotation type.

TITLE = 0
GENRES = 1
PERSON = 2
class nlu.annotation.semantic_annotation.SemanticAnnotation(annotation_type: AnnotationType, entity_type: EntityType | None = None, **kwargs)

Bases: moviebot.nlu.text_processing.Span

get_type() str

Returns semantic annotation type as string.

classmethod from_span(span: moviebot.nlu.text_processing.Span, annotation_type: AnnotationType, entity_type: EntityType | None = None) SemanticAnnotation

Creates semantic annotation from already existing span or token. This is the most common way to create new annotation.

Parameters:
  • span – Span with text, start and end.

  • annotation_type – Type of annotation.

  • entity_type – Type of entity for AnnotationType.NAMED_ENTITY. Defaults to None.

Returns:

New semantic annotation retaining span information.