Spaces:
Sleeping
Sleeping
Shunfeng Zheng
commited on
Update app.py
Browse files
app.py
CHANGED
|
@@ -225,7 +225,22 @@ def extract_spatial_entities(text):
|
|
| 225 |
final_doc.ents[i]._.rse_id = sent_rse_id[i]
|
| 226 |
|
| 227 |
doc = final_doc
|
| 228 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 229 |
|
| 230 |
|
| 231 |
|
|
|
|
| 225 |
final_doc.ents[i]._.rse_id = sent_rse_id[i]
|
| 226 |
|
| 227 |
doc = final_doc
|
| 228 |
+
|
| 229 |
+
ents_ext = []
|
| 230 |
+
for ent in doc.ents:
|
| 231 |
+
ents_ext.append({
|
| 232 |
+
"start": ent.start_char,
|
| 233 |
+
"end": ent.end_char,
|
| 234 |
+
"label": ent.label_,
|
| 235 |
+
"rse_id": ent._.rse_id # ✅ 加入扩展字段
|
| 236 |
+
})
|
| 237 |
+
|
| 238 |
+
return {
|
| 239 |
+
"text": doc.text,
|
| 240 |
+
"ents": [{"start": ent.start_char, "end": ent.end_char, "label": ent.label_} for ent in doc.ents],
|
| 241 |
+
"tokens": [{"id": i, "start": token.idx, "end": token.idx + len(token)} for i, token in enumerate(doc)],
|
| 242 |
+
"ents_ext": ents_ext # ✅ 添加扩展字段
|
| 243 |
+
}
|
| 244 |
|
| 245 |
|
| 246 |
|