new output format
Browse files- README.md +11 -0
- handler.py +5 -5
README.md
CHANGED
@@ -1,3 +1,14 @@
|
|
1 |
---
|
|
|
2 |
license: mit
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
---
|
|
|
|
|
|
1 |
---
|
2 |
+
language: en
|
3 |
license: mit
|
4 |
+
tags:
|
5 |
+
- spacy
|
6 |
+
- token-classification
|
7 |
+
widgets:
|
8 |
+
- example_title: "Example 1"
|
9 |
+
text: "My name is Sarah and I live in London."
|
10 |
+
- example_title: "Example 2"
|
11 |
+
text: "Who is John Doe?"
|
12 |
---
|
13 |
+
|
14 |
+
English pipeline optimized for CPU. Components: ner.
|
handler.py
CHANGED
@@ -25,7 +25,7 @@ class EndpointHandler:
|
|
25 |
print(f"EndpointHandler(path='{path}')")
|
26 |
self._nlp: spacy.Language = _load_spacy_model(name="en_core_web_lg")
|
27 |
|
28 |
-
def __call__(self, data: dict[str, Any]) -> dict[str, Any]:
|
29 |
inputs: str = data.pop("inputs", "")
|
30 |
if not inputs:
|
31 |
return {}
|
@@ -38,12 +38,12 @@ class EndpointHandler:
|
|
38 |
continue
|
39 |
|
40 |
entity: dict = {
|
41 |
-
"
|
42 |
-
"
|
43 |
-
"
|
44 |
"start": ent.start_char,
|
45 |
"end": ent.end_char}
|
46 |
|
47 |
outputs.append(entity)
|
48 |
|
49 |
-
return
|
|
|
25 |
print(f"EndpointHandler(path='{path}')")
|
26 |
self._nlp: spacy.Language = _load_spacy_model(name="en_core_web_lg")
|
27 |
|
28 |
+
def __call__(self, data: dict[str, Any]) -> list[dict[str, Any]]:
|
29 |
inputs: str = data.pop("inputs", "")
|
30 |
if not inputs:
|
31 |
return {}
|
|
|
38 |
continue
|
39 |
|
40 |
entity: dict = {
|
41 |
+
"entity_group": ent.label_,
|
42 |
+
"score": 1,
|
43 |
+
"word": ent.text,
|
44 |
"start": ent.start_char,
|
45 |
"end": ent.end_char}
|
46 |
|
47 |
outputs.append(entity)
|
48 |
|
49 |
+
return outputs
|