forked from DS4SD/deepsearch-toolkit
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: make Model API interface more explicit (DS4SD#86)
Signed-off-by: Panos Vagenas <35837085+vagenas@users.noreply.github.com>
- Loading branch information
1 parent
3effcfc
commit 2aefb2c
Showing
12 changed files
with
252 additions
and
217 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
from abc import abstractmethod | ||
from typing import List, Optional | ||
|
||
from deepsearch.model.base.base_annotator import BaseAnnotator | ||
|
||
|
||
class BaseNLPAnnotator(BaseAnnotator): | ||
|
||
kind: str = "NLPModel" | ||
|
||
@abstractmethod | ||
def annotate_batched_entities( | ||
self, | ||
object_type: str, | ||
items: List[str], | ||
entity_names: Optional[List[str]], | ||
) -> List[dict]: | ||
"""Annotate entities in given items batch. | ||
Args: | ||
object_type (str): type of objects to annotate, e.g. "text"; must be included | ||
in `supports` property | ||
items (List[str]): batch of input items to annotate | ||
entity_names (Optional[List[str]]): entities to annotate | ||
Returns: | ||
List[dict]: a list, which, for each item in `items`, contains a dict with keys | ||
being the various entity names each mapped to a list of its annotations | ||
(can be empty) in the item, each annotation being a dict like: | ||
{ | ||
"type": <entity_name>, | ||
"match": <match>, | ||
"original": <original>, | ||
"range": [<range_start>, <range_end>] | ||
} | ||
""" | ||
return [] | ||
|
||
@abstractmethod | ||
def annotate_batched_relationships( | ||
self, | ||
object_type: str, | ||
items: List[str], | ||
entities: List[dict], | ||
relationship_names: Optional[List[str]], | ||
) -> List[dict]: | ||
return [] | ||
|
||
@abstractmethod | ||
def annotate_batched_properties( | ||
self, | ||
object_type: str, | ||
items: List[str], | ||
entities: List[dict], | ||
property_names: Optional[List[str]], | ||
) -> List[dict]: | ||
return [] |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
from deepsearch.model.examples.minimal_annotator.minimal_annotator import ( | ||
MinimalAnnotator, | ||
) | ||
from deepsearch.model.server.deepsearch_annotator_app import DeepSearchAnnotatorApp | ||
|
||
|
||
def run(): | ||
app = DeepSearchAnnotatorApp() | ||
app.register_annotator(MinimalAnnotator()) | ||
app.run() | ||
|
||
|
||
if __name__ == "__main__": | ||
run() |
Oops, something went wrong.