|
@@ -1,5 +1,6 @@
|
|
|
from fastapi import FastAPI, Body
|
|
|
|
|
|
+from spacy import displacy
|
|
|
from .models import get_model
|
|
|
from .clean_text import text_cleaner, text_formatter
|
|
|
|
|
@@ -47,4 +48,18 @@ def get_all_names(data: dict = Body(...)):
|
|
|
response = {
|
|
|
'names': names
|
|
|
}
|
|
|
- return response
|
|
|
+ return response
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+@app.post('/displacy/google')
|
|
|
+def get_html_entity(data: dict = Body(...)):
|
|
|
+
|
|
|
+ reviews = data.get('reviews')
|
|
|
+
|
|
|
+ for rev in reviews:
|
|
|
+ doc = model(text_formatter(rev['comment']))
|
|
|
+ options = {"ents": ["ORG", "PERSON", "GPE", "PRODUCT", "DATE", "TIME", "MONEY"]}
|
|
|
+ html = displacy.render(doc, options=options, style='ent')
|
|
|
+ rev['comment'] = html
|
|
|
+ return reviews
|