enrich_affiliations_openalex¶
src.enrichers.enrich_affiliations_openalex
¶
Paper-based affiliation enrichment using OpenAlex, Semantic Scholar, CrossRef, and DBLP.
Disambiguation strategy: instead of searching by author name alone (which returns wrong matches for common names), we look up the author's known papers by title, then extract the affiliation from the matching author entry on that specific paper.
Sources queried (in priority order): 1. CrossRef – DOI lookup → author → affiliation (highest precision) 2. OpenAlex – works search by title → authorships → institutions 3. Semantic Scholar – paper title match → authors → affiliations 4. CrossRef – works search by title → author → affiliation
Usage
python -m src.enrichers.enrich_affiliations_openalex --authors_file ../_data/authors.yml --papers_file ../assets/data/paper_authors_map.json --output_file ../_data/authors.yml [--max_authors 100][--verbose]
find_affiliation_for_author(session: requests.Session, author_name: str, papers: list[dict], verbose: bool = False) -> tuple[Optional[str], str]
¶
Try to find affiliation using paper-based disambiguation.
Strategy (two passes): Pass 1 – papers with real DOIs (highest confidence): CrossRef DOI lookup for exact author match. Pass 2 – title-based search across papers (up to 5): OpenAlex, Semantic Scholar, then CrossRef title search. Papers are tried newest-first for the most current affiliation. Note: DBLP affiliations are already applied in step 0 (generate_author_stats).
Source code in src/enrichers/enrich_affiliations_openalex.py
315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 | |
enrich(authors_file: str, papers_file: str, output_file: Optional[str] = None, max_authors: Optional[int] = None, verbose: bool = False, dry_run: bool = False, recheck: bool = False, data_dir: Optional[str] = None) -> dict
¶
Main entry point. Reads authors.yml and paper_authors_map.json, enriches missing affiliations, writes back.
Returns stats dict.
Source code in src/enrichers/enrich_affiliations_openalex.py
475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 | |