Spaces:
Running
Running
Update extract_and_store_supabase.py
Browse files
extract_and_store_supabase.py
CHANGED
@@ -82,12 +82,12 @@ def extract_structure_store_message(user_id:str,message_id:str , attachment_id:s
|
|
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 |
|
87 |
# Check if the entity type is in the allowed list
|
88 |
if entity_type in allowed_entities:
|
89 |
-
mention_text = ent.get('mentionText')
|
90 |
-
normalized_values = ent.get('normalizedValue')
|
91 |
|
92 |
# Initialize a list for the entity type if not already present
|
93 |
if entity_type not in document_entities:
|
@@ -102,10 +102,10 @@ def extract_structure_store_message(user_id:str,message_id:str , attachment_id:s
|
|
102 |
# Handling 'line_item' and its properties (line_item/description, line_item/quantity, etc.)
|
103 |
if entity_type == 'line_item' and 'properties' in ent:
|
104 |
for prop in ent['properties']:
|
105 |
-
prop_type = prop.get('type')
|
106 |
if prop_type in allowed_entities:
|
107 |
-
mention_text = prop.get('mentionText')
|
108 |
-
normalized_values = prop.get('normalizedValue')
|
109 |
|
110 |
# Initialize a list for the property type if not already present
|
111 |
if prop_type not in document_entities:
|
|
|
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') or ""
|
86 |
|
87 |
# Check if the entity type is in the allowed list
|
88 |
if entity_type in allowed_entities:
|
89 |
+
mention_text = ent.get('mentionText') or ""
|
90 |
+
normalized_values = ent.get('normalizedValue') or ""
|
91 |
|
92 |
# Initialize a list for the entity type if not already present
|
93 |
if entity_type not in document_entities:
|
|
|
102 |
# Handling 'line_item' and its properties (line_item/description, line_item/quantity, etc.)
|
103 |
if entity_type == 'line_item' and 'properties' in ent:
|
104 |
for prop in ent['properties']:
|
105 |
+
prop_type = prop.get('type') or ""
|
106 |
if prop_type in allowed_entities:
|
107 |
+
mention_text = prop.get('mentionText') or ""
|
108 |
+
normalized_values = prop.get('normalizedValue') or ""
|
109 |
|
110 |
# Initialize a list for the property type if not already present
|
111 |
if prop_type not in document_entities:
|