starfriend commited on
Commit
4977aa4
·
verified ·
1 Parent(s): 0ea5698

Upload 6 files

Browse files
backend/media_analysis/data_export.py CHANGED
@@ -50,6 +50,22 @@ def normalize_records(records: list[dict]) -> tuple[list[dict], list[str]]:
50
  item[key] = float(normalized) if "." in normalized else int(normalized)
51
  elif cleaned:
52
  warnings.append(f"Row {index}: {key} is not an unambiguous number: {value!r}")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
53
  result.append(item)
54
  return result, warnings
55
 
 
50
  item[key] = float(normalized) if "." in normalized else int(normalized)
51
  elif cleaned:
52
  warnings.append(f"Row {index}: {key} is not an unambiguous number: {value!r}")
53
+ # Separate class designations that were embedded in a standard range.
54
+ # This is a purely textual rearrangement: no thresholds or signs are inferred.
55
+ rng = item.get("standard_range")
56
+ if isinstance(rng, str):
57
+ m = re.fullmatch(r"\s*(.*?)\s+(Class\s+(?:I|II|III|IV|V))\s*", rng, re.I)
58
+ if m and m.group(1).strip():
59
+ extracted_range = m.group(1).strip()
60
+ extracted_class = "Class " + m.group(2).split()[-1].upper()
61
+ existing_class = item.get("class_label")
62
+ if not existing_class:
63
+ item["class_label"] = extracted_class
64
+ item["standard_range"] = extracted_range
65
+ elif re.sub(r"\s+", " ", str(existing_class)).strip().lower() == extracted_class.lower():
66
+ item["standard_range"] = extracted_range
67
+ else:
68
+ warnings.append(f"Row {index}: conflicting class_label and standard_range; preserved original")
69
  result.append(item)
70
  return result, warnings
71
 
backend/media_analysis/figure_analysis.py CHANGED
@@ -158,12 +158,6 @@ def analyze_media_question(question: str, selected_papers: list[dict], *, enable
158
  records, normalization_warnings = normalize_records(records)
159
  result["structured_data"] = records
160
  result["normalization_warnings"] = normalization_warnings
161
- from .record_checks import validate_extraction
162
- records, validation_warnings, coverage = validate_extraction(records, items if evidence_mode != "vision" else [])
163
- result["structured_data"] = records
164
- result["validation_warnings"] = validation_warnings
165
- result["extraction_coverage"] = coverage
166
-
167
  result["csv_attachment"] = csv_attachment(records, result.get("sources") or [])
168
  if warning:
169
  result["export_warning"] = warning
 
158
  records, normalization_warnings = normalize_records(records)
159
  result["structured_data"] = records
160
  result["normalization_warnings"] = normalization_warnings
 
 
 
 
 
 
161
  result["csv_attachment"] = csv_attachment(records, result.get("sources") or [])
162
  if warning:
163
  result["export_warning"] = warning
backend/media_analysis/vision_client.py CHANGED
@@ -125,10 +125,7 @@ def analyze_images(question: str, evidence: list[dict], *, model: str | None = N
125
  "Use stable field names: parameter, unit, minimum, maximum, mean, std, "
126
  "standard_range, class_label, classification, percent_samples, references, "
127
  "estimated (boolean), extraction_method (printed_table|positioned_text|visual_estimate), "
128
- "and source_quality. Keep source_quality brief (e.g., image_checked, ambiguous, unverified). "
129
- "For class labels (Class I, II, III), populate class_label separately and "
130
- "exclude the class name from standard_range. Never guess blank percentages as zero. "
131
- "Preserve original printed parameter names, units, inequality "
132
  "signs, and numeric precision. Numeric values must be JSON numbers (no thousands "
133
  "separators); use *_printed fields if preservation of original formatting matters. "
134
  "For ambiguous OCR signs, compare against image; if still unclear use null and "
 
125
  "Use stable field names: parameter, unit, minimum, maximum, mean, std, "
126
  "standard_range, class_label, classification, percent_samples, references, "
127
  "estimated (boolean), extraction_method (printed_table|positioned_text|visual_estimate), "
128
+ "and source_quality. Preserve original printed parameter names, units, inequality "
 
 
 
129
  "signs, and numeric precision. Numeric values must be JSON numbers (no thousands "
130
  "separators); use *_printed fields if preservation of original formatting matters. "
131
  "For ambiguous OCR signs, compare against image; if still unclear use null and "