earlalvarado-pi commited on
Commit
8d90324
1 Parent(s): 83fa20d

Update handler.py

Browse files
Files changed (1) hide show
  1. handler.py +6 -2
handler.py CHANGED
@@ -11,18 +11,22 @@ except ImportError:
11
  import spacy
12
  from typing import Dict, Any
13
 
 
 
 
14
  class EndpointHandler:
15
- def __init__(self, path="./"):
16
  self.nlp = spacy.load(path)
17
 
18
  def __call__(self, data: Dict[str, Any]) -> Dict[str, Any]:
19
  text = data.get("text", "")
20
  doc = self.nlp(text)
21
  entities = [
22
- {"word": ent.text, "entity_group": ent.label_, "score": 1.0}
23
  for ent in doc.ents
24
  ]
25
  return entities
 
26
  """
27
  handler = EndpointHandler()
28
  data = {"text": "Apple is looking at buying U.K. startup for $1 billion"}
 
11
  import spacy
12
  from typing import Dict, Any
13
 
14
+ import spacy
15
+ from typing import Dict, Any
16
+
17
  class EndpointHandler:
18
+ def __init__(self, path):
19
  self.nlp = spacy.load(path)
20
 
21
  def __call__(self, data: Dict[str, Any]) -> Dict[str, Any]:
22
  text = data.get("text", "")
23
  doc = self.nlp(text)
24
  entities = [
25
+ {"word": ent.text, "entity_group": ent.label_, "score": 1.0}
26
  for ent in doc.ents
27
  ]
28
  return entities
29
+
30
  """
31
  handler = EndpointHandler()
32
  data = {"text": "Apple is looking at buying U.K. startup for $1 billion"}