rafmacalaba commited on
Commit
94bf6c6
Β·
1 Parent(s): b8f5da1

color coding

Browse files
Files changed (1) hide show
  1. app.py +8 -9
app.py CHANGED
@@ -213,20 +213,20 @@ def create_demo() -> gr.Blocks:
213
  empirical_context = rec.get("empirical_context", "β€”")
214
  explanation = rec.get("explanation", "β€”")
215
  is_mixed = rec.get("is_mixed_type", False)
 
216
 
217
- # Highlight term in empirical context
218
- if rec.get("ner_text") and rec.get("text"):
219
  try:
220
- # Get the term from the full text
221
  start, end = rec["ner_text"][0][0], rec["ner_text"][0][1]
222
  term = rec["text"][start:end]
223
-
224
- # Highlight it in the empirical context if present
225
- # We use HTML styling for better visibility
 
226
  if term and term in empirical_context:
227
- highlight_style = 'background-color: #ffd700; color: black; padding: 2px 4px; border-radius: 4px; font-weight: bold; border: 1px solid #e6c200;'
228
  empirical_context = empirical_context.replace(term, f'<span style="{highlight_style}">{term}</span>')
229
- except:
230
  pass
231
 
232
  # Build HTML
@@ -247,7 +247,6 @@ def create_demo() -> gr.Blocks:
247
  """
248
 
249
  # Add LLM contextual analysis section if available
250
- llm_is_dataset = rec.get("llm_is_dataset_contextual")
251
  llm_reasons = rec.get("llm_contextual_reason", [])
252
  llm_thinking = rec.get("llm_thinking_contextual", "")
253
 
 
213
  empirical_context = rec.get("empirical_context", "β€”")
214
  explanation = rec.get("explanation", "β€”")
215
  is_mixed = rec.get("is_mixed_type", False)
216
+ llm_is_dataset = rec.get("llm_is_dataset_contextual")
217
 
218
+ # Apply conditional highlighting based on LLM assessment
219
+ if rec.get("ner_text") and rec.get("text") and llm_is_dataset is not None:
220
  try:
 
221
  start, end = rec["ner_text"][0][0], rec["ner_text"][0][1]
222
  term = rec["text"][start:end]
223
+ if llm_is_dataset:
224
+ highlight_style = 'background-color: #90ee90; color: black; padding: 2px 4px; border-radius: 4px; font-weight: bold; border: 1px solid #5cb85c;'
225
+ else:
226
+ highlight_style = 'background-color: #ff7f7f; color: black; padding: 2px 4px; border-radius: 4px; font-weight: bold; border: 1px solid #d9534f;'
227
  if term and term in empirical_context:
 
228
  empirical_context = empirical_context.replace(term, f'<span style="{highlight_style}">{term}</span>')
229
+ except Exception:
230
  pass
231
 
232
  # Build HTML
 
247
  """
248
 
249
  # Add LLM contextual analysis section if available
 
250
  llm_reasons = rec.get("llm_contextual_reason", [])
251
  llm_thinking = rec.get("llm_thinking_contextual", "")
252