Update modules/database.py
Browse files- modules/database.py +7 -1
modules/database.py
CHANGED
@@ -224,11 +224,17 @@ def store_morphosyntax_result(username, text, repeated_words, arc_diagrams):
|
|
224 |
################################################################################################################
|
225 |
def store_semantic_result(username, text, network_diagram):
|
226 |
try:
|
|
|
|
|
|
|
|
|
|
|
|
|
227 |
analysis_document = {
|
228 |
'username': username,
|
229 |
'timestamp': datetime.utcnow(),
|
230 |
'text': text,
|
231 |
-
'network_diagram':
|
232 |
'analysis_type': 'semantic'
|
233 |
}
|
234 |
|
|
|
224 |
################################################################################################################
|
225 |
def store_semantic_result(username, text, network_diagram):
|
226 |
try:
|
227 |
+
# Convertir la figura a una imagen base64
|
228 |
+
buf = io.BytesIO()
|
229 |
+
network_diagram.savefig(buf, format='png')
|
230 |
+
buf.seek(0)
|
231 |
+
img_str = base64.b64encode(buf.getvalue()).decode('utf-8')
|
232 |
+
|
233 |
analysis_document = {
|
234 |
'username': username,
|
235 |
'timestamp': datetime.utcnow(),
|
236 |
'text': text,
|
237 |
+
'network_diagram': img_str, # Guardar la imagen como string base64
|
238 |
'analysis_type': 'semantic'
|
239 |
}
|
240 |
|