feat(parser): support // as multi-person separator in parseReceivers
Pre-splits input on "//" before existing logic so each segment is processed independently through the full pipeline (und/u splitting, last-name distribution, etc.). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package org.raddatz.familienarchiv.service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
@@ -20,6 +21,7 @@ public class PersonNameParser {
|
||||
private static final Pattern GEB_PATTERN = Pattern.compile("\\s+geb\\.\\s+\\S+");
|
||||
private static final Pattern PAREN_LAST_NAME = Pattern.compile("\\(([^)]+)\\)\\s*$");
|
||||
private static final Pattern MULTI_SEPARATOR = Pattern.compile("\\s+(?:und|u)\\s+");
|
||||
private static final Pattern SLASH_SEPARATOR = Pattern.compile("//");
|
||||
|
||||
public record SplitName(String firstName, String lastName) {}
|
||||
|
||||
@@ -38,6 +40,16 @@ public class PersonNameParser {
|
||||
public static List<String> parseReceivers(String raw) {
|
||||
if (raw == null || raw.isBlank()) return List.of();
|
||||
|
||||
// 0. Pre-split on "//" — each segment is an independent name entry
|
||||
String[] slashParts = SLASH_SEPARATOR.split(raw, -1);
|
||||
if (slashParts.length > 1) {
|
||||
return Arrays.stream(slashParts)
|
||||
.map(String::trim)
|
||||
.filter(s -> !s.isBlank())
|
||||
.flatMap(segment -> parseReceivers(segment).stream())
|
||||
.toList();
|
||||
}
|
||||
|
||||
// 1. Strip "geb. Xxx" maiden-name annotations
|
||||
String cleaned = GEB_PATTERN.matcher(raw).replaceAll("").trim();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user