IpcClassification extends PatentClassification { @Override public void parseText(final String classificationStr) throws ParseException { Matcher matcher = REGEX_OLD.matcher(classificationStr); if (matcher.matches()) { String section = matcher.group(1); String mainClass = matcher.group(2); String subClass = matcher.group(3); String mainGroup = matcher.group(4).replace(' ', '0'); String subGroup = matcher.group(5); setSection(section); setMainClass(mainClass); setSubClass(subClass); setMainGroup(mainGroup); setSubGroup(subGroup); return; } Matcher fullMatch = REGEX.matcher(classificationStr); if (fullMatch.matches()) { String section = fullMatch.group(1); String mainClass = fullMatch.group(2); String subClass = fullMatch.group(3); String mainGroup = fullMatch.group(4); String subGroup = fullMatch.group(5); setSection(section); setMainClass(mainClass); setSubClass(subClass); setMainGroup(mainGroup); setSubGroup(subGroup); return; } Matcher matchL3 = REGEX_LEN3.matcher(classificationStr); if (classificationStr.length() >= 3 && matchL3.matches()) { String section = matchL3.group(1); String mainClass = matchL3.group(2); setSection(section); setMainClass(mainClass); return; } Matcher matchL4 = REGEX_LEN4.matcher(classificationStr); if (classificationStr.length() >= 4 && matchL4.matches()) { String section = matchL4.group(1); String mainClass = matchL4.group(2); String subClass = matchL4.group(3); System.out.println("4" + classificationStr + classificationStr.length()); setSection(section); setMainClass(mainClass); setSubClass(subClass); return; } else { parseFailed = true; LOGGER.warn("IPC parse failed '{}'", classificationStr); throw new ParseException("Failed to regex parse IPC Classification: " + classificationStr, 0); } } IpcClassification(String originalText, boolean mainOrInventive); boolean isParseFailed(); @Override ClassificationType getType(); String getSection(); void setSection(String section); String getMainClass(); void setMainClass(String mainClass); String getSubClass(); void setSubClass(String subClass); String getMainGroup(); void setMainGroup(String mainGroup); String getSubGroup(); void setSubGroup(String subGroup); String[] getParts(); @Override Tree getTree(); @Override String getTextNormalized(); String standardize(); @Override List<String> getSearchTokens(); int getDepth(); @Override boolean isContained(PatentClassification check); @Override boolean equals(Object obj); @Override void parseText(final String classificationStr); @Override boolean validate(); @Override String toString(); static Map<String, List<IpcClassification>> filterIpc(
			Collection<T> classes);  }
@Test(expected = ParseException.class) public void failBlank() throws ParseException { IpcClassification ipc = new IpcClassification("", false); ipc.parseText(""); }
@Test(expected = ParseException.class) public void failParseCheck() throws ParseException { IpcClassification ipc = new IpcClassification("A61F BAD", false); ipc.parseText("A61F BAD"); }