(paper: Dict[str, Any])
| 1179 | |
| 1180 | def _normalize_paper(paper: Dict[str, Any]) -> Dict[str, Any]: |
| 1181 | normalized = dict(paper or {}) |
| 1182 | normalized["authors"] = _parse_jsonish_list(normalized.get("authors")) |
| 1183 | |
| 1184 | metadata = normalized.get("metadata") |
| 1185 | if isinstance(metadata, str): |
| 1186 | try: |
| 1187 | metadata = json.loads(metadata) |
| 1188 | except json.JSONDecodeError: |
| 1189 | metadata = {} |
| 1190 | if not isinstance(metadata, dict): |
| 1191 | metadata = {} |
| 1192 | normalized["metadata"] = metadata |
| 1193 | |
| 1194 | for field in ( |
| 1195 | "title", |
| 1196 | "institution", |
| 1197 | "venue", |
| 1198 | "publish_date", |
| 1199 | "arxiv_id", |
| 1200 | "doi", |
| 1201 | "pdf_url", |
| 1202 | "url", |
| 1203 | "paper_url", |
| 1204 | "doi_url", |
| 1205 | "openreview_url", |
| 1206 | "cvf_url", |
| 1207 | "ecva_url", |
| 1208 | "dblp_url", |
| 1209 | "journal", |
| 1210 | "source", |
| 1211 | "category", |
| 1212 | ): |
| 1213 | if field in normalized: |
| 1214 | normalized[field] = _clean_text(normalized.get(field)) |
| 1215 | |
| 1216 | if "abstract" in normalized: |
| 1217 | normalized["abstract"] = _clean_abstract_text(normalized.get("abstract")) |
| 1218 | |
| 1219 | score = normalized.get("score") |
| 1220 | try: |
| 1221 | normalized["score"] = float(score) |
| 1222 | except (TypeError, ValueError): |
| 1223 | normalized["score"] = 0.0 |
| 1224 | |
| 1225 | return normalized |
| 1226 | |
| 1227 | |
| 1228 | def _is_direct_upload_request(request_metadata: Dict[str, Any]) -> bool: |
| 1229 | source_type = _clean_text((request_metadata or {}).get("report_source_type")) |
no test coverage detected