(String text)
| 14 | private static final Pattern PATTERN_YEAR = Pattern.compile("^(.*)(19|20)\\d{2}$"); |
| 15 | |
| 16 | public static List<String> split(String text) { |
| 17 | Set<String> items = new LinkedHashSet<>(); |
| 18 | String[] rawSplits; |
| 19 | if (text.contains(":")) rawSplits = text.split(":"); |
| 20 | else if (text.contains("第") && text.contains("季")) rawSplits = extractSeason(text); |
| 21 | else if (text.contains("(")) rawSplits = new String[]{text.split(Pattern.quote("("))[0]}; |
| 22 | else if (text.contains(" ")) rawSplits = text.split(" "); |
| 23 | else rawSplits = extractYear(text); |
| 24 | items.add(text); |
| 25 | Arrays.stream(rawSplits).map(String::trim).map(s -> s.contains(" ") ? s.split(" ")[0].trim() : s).filter(s -> !s.isEmpty()).forEach(items::add); |
| 26 | return new ArrayList<>(items); |
| 27 | } |
| 28 | |
| 29 | private static String[] extractSeason(String text) { |
| 30 | Matcher matcher = PATTERN_SEASON.matcher(text); |
no test coverage detected