Clean up text fields using the processor.
(doc: dict)
| 37 | |
| 38 | |
| 39 | def normalize_fields(doc: dict) -> dict: |
| 40 | """Clean up text fields using the processor.""" |
| 41 | if "title" in doc: |
| 42 | doc["title"] = normalize_text(doc["title"]) |
| 43 | if len(doc["title"]) > MAX_TITLE_LENGTH: |
| 44 | doc["title"] = doc["title"][:MAX_TITLE_LENGTH] |
| 45 | if "paragraphs" in doc: |
| 46 | doc["paragraphs"] = [normalize_text(p) for p in doc["paragraphs"]] |
| 47 | if "sections" in doc: |
| 48 | doc["sections"] = [normalize_text(s) for s in doc["sections"]] |
| 49 | return doc |
| 50 | |
| 51 | |
| 52 | def validate_batch(docs: list) -> tuple: |
no test coverage detected