Dodaj normalize_author_name — normalizacja autora z JSON-ów PBN#2
Merged
Conversation
PBN podaje dane osobowe autora niespójnie zależnie od endpointu: nazwisko jako lastName albo familyName, imię jako firstName, givenNames albo name. Nowa czysta funkcja normalize_author_name scala oba warianty spotykane w hostach (unia łańcuchów fallbacków): - lastName: familyName → lastName → None - firstName: firstName → givenNames → name → None Puste stringi traktowane jak brak wartości; wejście nie-dict (np. goły PBN UID jako string) daje oba pola None. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Co i po co
PBN zwraca dane osobowe autora niespójnie, zależnie od endpointu: nazwisko raz jako
lastName, raz jakofamilyName; imię jakofirstName,givenNamesalboname. Czasem zamiast słownika przychodzi goły PBN UID (string).Nowa czysta funkcja
pbn_client.normalize_author_namesprowadza wszystkie warianty do jednego kształtu{"lastName": <str|None>, "firstName": <str|None>}. To semantyczne scalenie dwóch wariantów z hostów (unia łańcuchów fallbacków):lastName:familyName→lastName→NonefirstName:firstName→givenNames→name→NonePuste stringi traktowane jak brak wartości; wejście nie-dict daje oba pola
None.Testy
tests/test_authors.py— payloady firstName/lastName, familyName/givenNames, name-only, lastName-only, pusty dict, klucze nieistotne, wejścia nie-dict (None/string-UID/int/lista), priorytety unii (familyName>lastName;firstName>givenNames>name), puste stringi.uv run --isolated pytest -q→ 57 passed. Ruff clean.🤖 Generated with Claude Code