Spaces:
Sleeping
Sleeping
update
Browse files
app.py
CHANGED
|
@@ -15,15 +15,18 @@ class InputText(BaseModel):
|
|
| 15 |
async def segment_text(payload: InputText):
|
| 16 |
text = payload.text
|
| 17 |
result = nlp(text)
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
|
|
|
|
|
|
|
|
|
| 27 |
|
| 28 |
@app.get("/")
|
| 29 |
def greet_json():
|
|
|
|
| 15 |
async def segment_text(payload: InputText):
|
| 16 |
text = payload.text
|
| 17 |
result = nlp(text)
|
| 18 |
+
# Convert numpy values to native Python types
|
| 19 |
+
processed_result = []
|
| 20 |
+
for item in result:
|
| 21 |
+
processed_item = {
|
| 22 |
+
'entity': str(item['entity']),
|
| 23 |
+
'score': float(item['score']),
|
| 24 |
+
'word': str(item['word']),
|
| 25 |
+
'start': int(item['start']),
|
| 26 |
+
'end': int(item['end'])
|
| 27 |
+
}
|
| 28 |
+
processed_result.append(processed_item)
|
| 29 |
+
return processed_result
|
| 30 |
|
| 31 |
@app.get("/")
|
| 32 |
def greet_json():
|