Spaces:
Sleeping
Sleeping
Upload 6 files
Browse filesFiles changed (3)
49 unmodified lines50515253545549 unmodified linesitem[key] = float(normalized) if "." in normalized else int(normalized)elif cleaned:warnings.append(f"Row {index}: {key} is not an unambiguous number: {value!r}")result.append(item)return result, warnings49 unmodified lines5051525354555657585960616263646566676869707149 unmodified linesitem[key] = float(normalized) if "." in normalized else int(normalized)elif cleaned:warnings.append(f"Row {index}: {key} is not an unambiguous number: {value!r}")# Separate class designations that were embedded in a standard range.# This is a purely textual rearrangement: no thresholds or signs are inferred.rng = item.get("standard_range")if isinstance(rng, str):m = re.fullmatch(r"\s*(.*?)\s+(Class\s+(?:I|II|III|IV|V))\s*", rng, re.I)if m and m.group(1).strip():extracted_range = m.group(1).strip()extracted_class = "Class " + m.group(2).split()[-1].upper()existing_class = item.get("class_label")if not existing_class:item["class_label"] = extracted_classitem["standard_range"] = extracted_rangeelif re.sub(r"\s+", " ", str(existing_class)).strip().lower() == extracted_class.lower():item["standard_range"] = extracted_rangeelse:warnings.append(f"Row {index}: conflicting class_label and standard_range; preserved original")result.append(item)return result, warnings
157 unmodified lines158159160161162163164165166167168169157 unmodified linesrecords, normalization_warnings = normalize_records(records)result["structured_data"] = recordsresult["normalization_warnings"] = normalization_warningsfrom .record_checks import validate_extractionrecords, validation_warnings, coverage = validate_extraction(records, items if evidence_mode != "vision" else [])result["structured_data"] = recordsresult["validation_warnings"] = validation_warningsresult["extraction_coverage"] = coverageresult["csv_attachment"] = csv_attachment(records, result.get("sources") or [])if warning:result["export_warning"] = warning157 unmodified lines158159160161162163157 unmodified linesrecords, normalization_warnings = normalize_records(records)result["structured_data"] = recordsresult["normalization_warnings"] = normalization_warningsresult["csv_attachment"] = csv_attachment(records, result.get("sources") or [])if warning:result["export_warning"] = warning
124 unmodified lines125126127128129130131132133134124 unmodified lines"Use stable field names: parameter, unit, minimum, maximum, mean, std, ""standard_range, class_label, classification, percent_samples, references, ""estimated (boolean), extraction_method (printed_table|positioned_text|visual_estimate), ""and source_quality. Keep source_quality brief (e.g., image_checked, ambiguous, unverified). ""For class labels (Class I, II, III), populate class_label separately and ""exclude the class name from standard_range. Never guess blank percentages as zero. ""Preserve original printed parameter names, units, inequality ""signs, and numeric precision. Numeric values must be JSON numbers (no thousands ""separators); use *_printed fields if preservation of original formatting matters. ""For ambiguous OCR signs, compare against image; if still unclear use null and "124 unmodified lines125126127128129130131124 unmodified lines"Use stable field names: parameter, unit, minimum, maximum, mean, std, ""standard_range, class_label, classification, percent_samples, references, ""estimated (boolean), extraction_method (printed_table|positioned_text|visual_estimate), ""and source_quality. Preserve original printed parameter names, units, inequality ""signs, and numeric precision. Numeric values must be JSON numbers (no thousands ""separators); use *_printed fields if preservation of original formatting matters. ""For ambiguous OCR signs, compare against image; if still unclear use null and "
backend/media_analysis/data_export.py+16
backend/media_analysis/figure_analysis.py-6
backend/media_analysis/vision_client.py+1-4