Skip to content
Snippets Groups Projects
interface.py 848 B
Newer Older
Michał Pogoda's avatar
Michał Pogoda committed
"""Module for input parser interface."""

from abc import ABC, abstractmethod
from typing import Any, List, Tuple
class InputParser(ABC):
Michał Pogoda's avatar
Michał Pogoda committed
    """Input parser interface.

    Input parser is used to parse input standarized set of into text and annotations.
    """

    @abstractmethod
    def parse(self, content: str) -> Tuple[str, List[Tuple[int, int, Any]]]:
Michał Pogoda's avatar
Michał Pogoda committed
        """Parse input string into text and annotations.

Michał Pogoda's avatar
Michał Pogoda committed
        Annotations are returned as a dictionary with channel name as a key and list of
        tuples. Eg.:
        Input
        "She has a cat"
        Output:
        ("She has a cat", {"entities": [(0, 3, "She"), (8, 11, "cat")]})
            content (str): Input in raw form.
Michał Pogoda's avatar
Michał Pogoda committed

        Returns:
            Tuple[str, Dict[str, List[Tuple[int, int, Any]]]]: Text and annotations.
Michał Pogoda's avatar
Michał Pogoda committed

Michał Pogoda's avatar
Michał Pogoda committed
        """
Michał Pogoda's avatar
Michał Pogoda committed
        pass