| 305 | |
| 306 | |
| 307 | def candidate_map( |
| 308 | *, |
| 309 | abstract: str, |
| 310 | intro_text: str, |
| 311 | method_text: str, |
| 312 | experiment_text: str, |
| 313 | conclusion_text: str, |
| 314 | data_text: str, |
| 315 | section_sources: dict[str, str], |
| 316 | max_chunks_per_section: int, |
| 317 | ) -> dict[str, list[dict]]: |
| 318 | combined_general = " ".join( |
| 319 | part |
| 320 | for part in [abstract, intro_text, method_text, experiment_text, conclusion_text] |
| 321 | if part |
| 322 | ) |
| 323 | return { |
| 324 | "abstract": text_chunks( |
| 325 | abstract, |
| 326 | section="abstract", |
| 327 | kind_hint="abstract", |
| 328 | actual_source_section="abstract", |
| 329 | max_chunks=max_chunks_per_section, |
| 330 | ), |
| 331 | "introduction": text_chunks( |
| 332 | intro_text, |
| 333 | section="introduction", |
| 334 | kind_hint="problem", |
| 335 | actual_source_section=section_sources.get("introduction", "introduction"), |
| 336 | is_abstract_fallback=section_sources.get("introduction") == "abstract", |
| 337 | max_chunks=max_chunks_per_section, |
| 338 | ), |
| 339 | "method": text_chunks( |
| 340 | method_text, |
| 341 | section="method", |
| 342 | kind_hint="method", |
| 343 | actual_source_section=section_sources.get("method", "method"), |
| 344 | is_abstract_fallback=section_sources.get("method") == "abstract", |
| 345 | max_chunks=max_chunks_per_section, |
| 346 | ), |
| 347 | "experiment": text_chunks( |
| 348 | experiment_text, |
| 349 | section="experiment", |
| 350 | kind_hint="results", |
| 351 | actual_source_section=section_sources.get("experiment", "experiment"), |
| 352 | is_abstract_fallback=section_sources.get("experiment") == "abstract", |
| 353 | max_chunks=max_chunks_per_section, |
| 354 | ), |
| 355 | "conclusion": text_chunks( |
| 356 | conclusion_text, |
| 357 | section="conclusion", |
| 358 | kind_hint="limitations", |
| 359 | actual_source_section=section_sources.get("conclusion", "conclusion"), |
| 360 | is_abstract_fallback=section_sources.get("conclusion") == "abstract", |
| 361 | max_chunks=max_chunks_per_section, |
| 362 | ), |
| 363 | "data": text_chunks( |
| 364 | data_text, |