|
|
@@ -178,8 +178,6 @@ def process_json_text(input_text):
|
|
|
|
|
|
def parse_transport_context(context_data):
|
|
|
context_data = clean_json_markers(context_data)
|
|
|
- context_data = process_json_text(context_data)
|
|
|
- print(context_data)
|
|
|
"""Parsi transpordikonteksti JSON-ist loetavaks"""
|
|
|
if isinstance(context_data, str):
|
|
|
# Proovi parsida string JSON-iks
|
|
|
@@ -484,11 +482,54 @@ def create_pdf_from_articles(articles, output_filename):
|
|
|
|
|
|
# Transpordi kontekst
|
|
|
if article['transport_context']:
|
|
|
+ # Debugimiseks
|
|
|
+ debugger_data = str(article['transport_context'])
|
|
|
+ print("----------- \"" + article['title'] + "\" -----------")
|
|
|
+ print("----------- article['transport_context'] -------------")
|
|
|
+ print(debugger_data)
|
|
|
elements.append(Paragraph("<b>TRANSFORDIPLANEERIMISE KONTEKST:</b>", section_style))
|
|
|
- context_text = format_context_for_pdf(article['transport_context'])
|
|
|
+ context_text = format_context_for_pdf(article['transport_context']['relevance_score'])
|
|
|
if context_text:
|
|
|
- elements.append(Paragraph(context_text, normal_style))
|
|
|
- elements.append(Spacer(1, 12))
|
|
|
+ elements.append(Paragraph("RELEVANTSUSE SKOOR: " + context_text, normal_style))
|
|
|
+ elements.append(Spacer(1, 1))
|
|
|
+
|
|
|
+ elements.append(Paragraph("<b>ANALÜÜS:</b>", normal_style))
|
|
|
+ analysis_text = article['transport_context']['analysis']
|
|
|
+ # Proovi leida theoretical_contribution regex'iga
|
|
|
+ match = re.search(r'"theoretical_contribution":\s*"([^"]*(?:\\"[^"]*)*)"', analysis_text)
|
|
|
+ if match:
|
|
|
+ context_text = match.group(1)
|
|
|
+ if context_text:
|
|
|
+ elements.append(Paragraph("<b>TEOREETILINE PANUS:</b>", normal_style))
|
|
|
+ elements.append(Paragraph(context_text, normal_style))
|
|
|
+ # Proovi leida practical_applicability regex'iga
|
|
|
+ match = re.search(r'"practical_applicability":\s*"([^"]*(?:\\"[^"]*)*)"', analysis_text)
|
|
|
+ if match:
|
|
|
+ context_text = match.group(1)
|
|
|
+ if context_text:
|
|
|
+ elements.append(Paragraph("<b>PRAKTILINE RAKENDATAVUS:</b>", normal_style))
|
|
|
+ elements.append(Paragraph(context_text, normal_style))
|
|
|
+ # Proovi leida problem_solving regex'iga
|
|
|
+ match = re.search(r'"problem_solving":\s*"([^"]*(?:\\"[^"]*)*)"', analysis_text)
|
|
|
+ if match:
|
|
|
+ context_text = match.group(1)
|
|
|
+ if context_text:
|
|
|
+ elements.append(Paragraph("<b>PROBLEEMILAHENDUS:</b>", normal_style))
|
|
|
+ elements.append(Paragraph(context_text, normal_style))
|
|
|
+ # Proovi leida limitations regex'iga
|
|
|
+ match = re.search(r'"limitations":\s*"([^"]*(?:\\"[^"]*)*)"', analysis_text)
|
|
|
+ if match:
|
|
|
+ context_text = match.group(1)
|
|
|
+ if context_text:
|
|
|
+ elements.append(Paragraph("<b>PIIRANGUD:</b>", normal_style))
|
|
|
+ elements.append(Paragraph(context_text, normal_style))
|
|
|
+ # Proovi leida relevance_score regex'iga
|
|
|
+ match = re.search(r'"relevance_score":\s*"([^"]*(?:\\"[^"]*)*)"', analysis_text)
|
|
|
+ if match:
|
|
|
+ context_text = match.group(1)
|
|
|
+ if context_text:
|
|
|
+ elements.append(Paragraph("<b>RELEVANTSUSE SKOOR:</b>", normal_style))
|
|
|
+ elements.append(Paragraph(context_text, normal_style))
|
|
|
|
|
|
# Allikfail ja töötlemise info
|
|
|
footer_info = []
|