generated from iai-group/template-project
/
annotator.py
34 lines (25 loc) · 1012 Bytes
/
annotator.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
"""Class for annotating a natural language query.
The main purpose is to return the intent (ADD | GET | DELETE) and to
annotate the triple (subject, predicate, object) and the preference (1 |
-1) in the query.
"""
from abc import ABC, abstractmethod
from typing import Tuple
from pkg_api.core.intents import Intent
from pkg_api.core.pkg_types import PKGData
from pkg_api.nl_to_pkg.llm.prompt import Prompt
class StatementAnnotator(ABC):
def __init__(self) -> None:
"""Initializes the statement annotator."""
self._prompt = Prompt()
@abstractmethod
def get_annotations(self, statement: str) -> Tuple[Intent, PKGData]:
"""Returns a tuple of the intent and the annotated statement.
Args:
statement: The statement to be annotated.
Raises:
NotImplementedError: If the method is not implemented.
Returns:
A tuple of the intent and the annotated statement as PKGData.
"""
raise NotImplementedError