Spaces:
Sleeping
Sleeping
update
Browse files
app.py
CHANGED
|
@@ -15,7 +15,15 @@ class InputText(BaseModel):
|
|
| 15 |
async def segment_text(payload: InputText):
|
| 16 |
text = payload.text
|
| 17 |
result = nlp(text)
|
| 18 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
|
| 20 |
@app.get("/")
|
| 21 |
def greet_json():
|
|
|
|
| 15 |
async def segment_text(payload: InputText):
|
| 16 |
text = payload.text
|
| 17 |
result = nlp(text)
|
| 18 |
+
output = ""
|
| 19 |
+
for e in result:
|
| 20 |
+
if "##" in e["word"]:
|
| 21 |
+
output += e["word"].replace("##", "")
|
| 22 |
+
elif e["entity"] == "I":
|
| 23 |
+
output += "_" + e["word"]
|
| 24 |
+
else:
|
| 25 |
+
output += " " + e["word"]
|
| 26 |
+
return {"segmented_text": output.strip()}
|
| 27 |
|
| 28 |
@app.get("/")
|
| 29 |
def greet_json():
|