annikwag commited on
Commit
3922556
·
verified ·
1 Parent(s): 34e5e83

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -22
app.py CHANGED
@@ -183,6 +183,7 @@ def filter_results(results, country_filter, region_filter, end_year_range, crs_f
183
  crs_key = metadata.get("crs_key", "").strip()
184
  # Use lookup value instead of stored crs_value.
185
  new_crs_value = lookup_crs_value(crs_key)
 
186
  crs_combined = f"{crs_key}: {new_crs_value}" if crs_key else ""
187
 
188
  # Enforce CRS filter only if specified.
@@ -315,7 +316,7 @@ with col5:
315
  show_exact_matches = st.checkbox("Show only exact matches", value=False)
316
 
317
  if not var.strip():
318
- st.info("Please enter a query to see results.")
319
  else:
320
 
321
  ###########################################
@@ -379,10 +380,10 @@ else:
379
  # Create two columns: left for full description and right for additional details.
380
  col_left, col_right = st.columns(2)
381
  with col_left:
382
- # Combine preview and remainder into one full description block.
383
- full_description = preview_text + (" " + remainder_text if remainder_text else "")
384
- st.markdown(highlight_query(full_description, var), unsafe_allow_html=True)
385
-
386
  with col_right:
387
  # Format additional text with line breaks using <br>
388
  start_year = metadata.get('start_year', None)
@@ -405,20 +406,21 @@ else:
405
  matched_countries.append(resolved_name)
406
  crs_key = metadata.get("crs_key", "").strip()
407
  new_crs_value = lookup_crs_value(crs_key)
 
408
  crs_combined = f"{crs_key}: {new_crs_value}" if crs_key else "Unknown"
409
  client_name = metadata.get('client', 'Unknown Client')
410
  contact = metadata.get("contact", "").strip()
 
411
  additional_text = (
412
- f"Objective: **{objective}**<br>"
413
- f"Commissioned by **{client_name}**<br>"
414
- f"Projekt duration **{start_year_str}-{end_year_str}**<br>"
415
- f"Budget: Project: **{formatted_project_budget}**, Total volume: **{formatted_total_volume}**<br>"
416
- f"Country: **{', '.join(matched_countries)}**<br>"
417
- f"Sector: **{crs_combined}**"
418
  )
419
- if contact and contact.lower() != "[email protected]":
420
- additional_text += f"<br>Contact: **{contact}**"
421
- st.markdown(additional_text, unsafe_allow_html=True)
422
  st.divider()
423
 
424
  # --- Semantic Results Branch ---
@@ -473,18 +475,19 @@ else:
473
  matched_countries.append(resolved_name)
474
  crs_key = metadata.get("crs_key", "").strip()
475
  new_crs_value = lookup_crs_value(crs_key)
 
476
  crs_combined = f"{crs_key}: {new_crs_value}" if crs_key else "Unknown"
477
  client_name = metadata.get('client', 'Unknown Client')
478
  contact = metadata.get("contact", "").strip()
479
  additional_text = (
480
- f"Objective: **{objective}**<br>"
481
- f"Commissioned by **{client_name}**<br>"
482
- f"Projekt duration **{start_year_str}-{end_year_str}**<br>"
483
- f"Budget: Project: **{formatted_project_budget}**, Total volume: **{formatted_total_volume}**<br>"
484
- f"Country: **{', '.join(matched_countries)}**<br>"
485
- f"Sector: **{crs_combined}**"
486
  )
487
- if contact and contact.lower() != "[email protected]":
488
- additional_text += f"<br>Contact: **{contact}**"
489
  st.markdown(additional_text, unsafe_allow_html=True)
490
  st.divider()
 
183
  crs_key = metadata.get("crs_key", "").strip()
184
  # Use lookup value instead of stored crs_value.
185
  new_crs_value = lookup_crs_value(crs_key)
186
+ new_crs_value = lookup_crs_value(crs_key).replace('.0', '')
187
  crs_combined = f"{crs_key}: {new_crs_value}" if crs_key else ""
188
 
189
  # Enforce CRS filter only if specified.
 
316
  show_exact_matches = st.checkbox("Show only exact matches", value=False)
317
 
318
  if not var.strip():
319
+ st.info("Please enter a question to see results.")
320
  else:
321
 
322
  ###########################################
 
380
  # Create two columns: left for full description and right for additional details.
381
  col_left, col_right = st.columns(2)
382
  with col_left:
383
+ st.markdown(highlight_query(preview_text, var), unsafe_allow_html=True)
384
+ if remainder_text:
385
+ with st.expander("Show more"):
386
+ st.markdown(highlight_query(remainder_text, var), unsafe_allow_html=True)
387
  with col_right:
388
  # Format additional text with line breaks using <br>
389
  start_year = metadata.get('start_year', None)
 
406
  matched_countries.append(resolved_name)
407
  crs_key = metadata.get("crs_key", "").strip()
408
  new_crs_value = lookup_crs_value(crs_key)
409
+ new_crs_value = lookup_crs_value(crs_key).replace('.0', '')
410
  crs_combined = f"{crs_key}: {new_crs_value}" if crs_key else "Unknown"
411
  client_name = metadata.get('client', 'Unknown Client')
412
  contact = metadata.get("contact", "").strip()
413
+ objective_highlighted = highlight_query(objective, var) if var.strip() else objective
414
  additional_text = (
415
+ f"**Objective:** {objective_highlighted}<br>"
416
+ f"**Commissioned by:** {client_name}<br>"
417
+ f"**Projekt duration:** {start_year_str}-{end_year_str}<br>"
418
+ f"**Budget:** Project: {formatted_project_budget}, Total volume: {formatted_total_volume}<br>"
419
+ f"**Country:** {', '.join(matched_countries)}<br>"
420
+ f"**Sector:** {crs_combined}"
421
  )
422
+ #if contact and contact.lower() != "[email protected]":
423
+ # additional_text += f"<br>**Contact:** {contact}"
 
424
  st.divider()
425
 
426
  # --- Semantic Results Branch ---
 
475
  matched_countries.append(resolved_name)
476
  crs_key = metadata.get("crs_key", "").strip()
477
  new_crs_value = lookup_crs_value(crs_key)
478
+ new_crs_value = lookup_crs_value(crs_key).replace('.0', '')
479
  crs_combined = f"{crs_key}: {new_crs_value}" if crs_key else "Unknown"
480
  client_name = metadata.get('client', 'Unknown Client')
481
  contact = metadata.get("contact", "").strip()
482
  additional_text = (
483
+ f"**Objective:** {objective}<br>"
484
+ f"**Commissioned by:** {client_name}<br>"
485
+ f"**Projekt duration:** {start_year_str}-{end_year_str}<br>"
486
+ f"**Budget:** Project: {formatted_project_budget}, Total volume: {formatted_total_volume}<br>"
487
+ f"**Country:** {', '.join(matched_countries)}<br>"
488
+ f"**Sector:** {crs_combined}"
489
  )
490
+ #if contact and contact.lower() != "[email protected]":
491
+ # additional_text += f"<br>Contact: **{contact}**"
492
  st.markdown(additional_text, unsafe_allow_html=True)
493
  st.divider()