Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -23,6 +23,10 @@ def count_entities(entities):
|
|
23 |
count += 1
|
24 |
return count
|
25 |
|
|
|
|
|
|
|
|
|
26 |
# Function to export entities as a JSON or CSV file
|
27 |
def export_entities(entities):
|
28 |
entity_list = []
|
@@ -31,7 +35,7 @@ def export_entities(entities):
|
|
31 |
"Name": entity.name,
|
32 |
"Type": language_v1.Entity.Type(entity.type_).name,
|
33 |
"Salience Score": entity.salience,
|
34 |
-
"Metadata": entity.metadata,
|
35 |
"Mentions": [mention.text.content for mention in entity.mentions]
|
36 |
}
|
37 |
entity_list.append(entity_info)
|
|
|
23 |
count += 1
|
24 |
return count
|
25 |
|
26 |
+
# Function to serialize entity metadata
|
27 |
+
def serialize_entity_metadata(metadata):
|
28 |
+
return {k: str(v) for k, v in metadata.items()}
|
29 |
+
|
30 |
# Function to export entities as a JSON or CSV file
|
31 |
def export_entities(entities):
|
32 |
entity_list = []
|
|
|
35 |
"Name": entity.name,
|
36 |
"Type": language_v1.Entity.Type(entity.type_).name,
|
37 |
"Salience Score": entity.salience,
|
38 |
+
"Metadata": serialize_entity_metadata(entity.metadata),
|
39 |
"Mentions": [mention.text.content for mention in entity.mentions]
|
40 |
}
|
41 |
entity_list.append(entity_info)
|