Spaces:
Sleeping
Sleeping
updating the document ai code
Browse files
extract_and_store_supabase.py
CHANGED
@@ -72,13 +72,30 @@ def extract_structure_store_message(user_id:str,message_id:str , attachment_id:s
|
|
72 |
|
73 |
print('Printing entities')
|
74 |
print(entities)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
75 |
if entities is not None:
|
76 |
for ent in entities:
|
77 |
if ent.get('type') is not None:
|
78 |
-
|
|
|
79 |
mention_text = ent.get('mentionText')
|
80 |
-
|
81 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
82 |
document_entities['email'] = email
|
83 |
print(document_entities)
|
84 |
insert_data_response = (
|
|
|
72 |
|
73 |
print('Printing entities')
|
74 |
print(entities)
|
75 |
+
# if entities is not None:
|
76 |
+
# for ent in entities:
|
77 |
+
# if ent.get('type') is not None:
|
78 |
+
# if ent.get('type') in allowed_entities:
|
79 |
+
# mention_text = ent.get('mentionText')
|
80 |
+
# normalised_values = ent.get('normalizedValue') if 'normalizedValue' in ent else None
|
81 |
+
# document_entities[ent.get('type')] = {"mention_text":mention_text,"normalizedValue":normalised_values}
|
82 |
if entities is not None:
|
83 |
for ent in entities:
|
84 |
if ent.get('type') is not None:
|
85 |
+
entity_type = ent.get('type')
|
86 |
+
if entity_type in allowed_entities:
|
87 |
mention_text = ent.get('mentionText')
|
88 |
+
normalized_values = ent.get('normalizedValue') if 'normalizedValue' in ent else None
|
89 |
+
|
90 |
+
# Initialize a list for the entity type if not already present
|
91 |
+
if entity_type not in document_entities:
|
92 |
+
document_entities[entity_type] = []
|
93 |
+
|
94 |
+
# Append the entity data to the list
|
95 |
+
document_entities[entity_type].append({
|
96 |
+
"mention_text": mention_text,
|
97 |
+
"normalizedValue": normalized_values
|
98 |
+
})
|
99 |
document_entities['email'] = email
|
100 |
print(document_entities)
|
101 |
insert_data_response = (
|