feat: PersonNameParser enhancements and Person model refactor (#209-#213) #215

Merged
marcel merged 25 commits from feat/issues-209-213-person-parser-enhancements into main 2026-04-08 18:48:00 +02:00
2 changed files with 20 additions and 6 deletions
Showing only changes of commit e49ae5de29 - Show all commits

View File

@@ -59,7 +59,14 @@ public class PersonNameParser {
// 1. Strip "geb. Xxx" maiden-name annotations
String cleaned = GEB_PATTERN.matcher(raw).replaceAll("").trim();
// 2. Extract parenthesised last name override, e.g. "(Gruber)"
// 2. If no multi-separator present, this is a single person — leave parens
// intact for split()'s annotation extraction
if (!MULTI_SEPARATOR.matcher(cleaned).find()) {
return List.of(cleaned);
}
// 3. Extract parenthesised last name override, e.g. "(Gruber)"
// Only applies to multi-person entries like "Hedi und Tutu (Gruber)"
String sharedLastName = null;
Matcher parenMatcher = PAREN_LAST_NAME.matcher(cleaned);
if (parenMatcher.find()) {
@@ -67,11 +74,6 @@ public class PersonNameParser {
cleaned = cleaned.substring(0, parenMatcher.start()).trim();
}
// 3. If no multi-separator present, this is a single person
if (!MULTI_SEPARATOR.matcher(cleaned).find()) {
return List.of(cleaned);
}
// 4. Split on " und " / " u "
String[] parts = MULTI_SEPARATOR.split(cleaned);

View File

@@ -24,6 +24,18 @@ class PersonNameParserTest {
.containsExactly("Eugenie de Gruyter");
}
@Test
void singlePerson_annotationParenPreserved() {
assertThat(PersonNameParser.parseReceivers("Clara de Gruyter(*1871)"))
.containsExactly("Clara de Gruyter(*1871)");
}
@Test
void singlePerson_nicknameParenPreserved() {
assertThat(PersonNameParser.parseReceivers("Gertrud D.(Tuttu)"))
.containsExactly("Gertrud D.(Tuttu)");
}
@Test
void gebAnnotation_noDot_multiWord_stripped() {
assertThat(PersonNameParser.parseReceivers("Ella Dieckmann, geb de Gruyter"))