in opennlp-models-test/src/main/java/org/apache/opennlp/ModelValidator.java [35:69]
public static void main(String[] args) {
if (args.length != 1) {
throw new IllegalArgumentException("This tool expects at least one argument");
}
System.err.println("Executing basic model validation checks.");
final Path testBaseDir = Path.of(args[0]);
final Path projectDir = testBaseDir.getParent();
final List<String> expectedModels = getExpectedModels();
final String pattern = "opennlp-models.*\\.jar";
final List<Path> availableModelJars = getAvailableModelJars(pattern, testBaseDir, projectDir);
if (expectedModels.size() != availableModelJars.size()) {
throw new IllegalArgumentException("Detected a mismatch between " +
"expected and available models! " +
"Expected: " + expectedModels.size() +
"; Actual: " + availableModelJars.size());
}
for (String model : expectedModels) {
boolean found;
for (Path availableJar : availableModelJars) {
found = isModelInJar(availableJar, model);
if (found) {
return;
}
}
throw new IllegalArgumentException(
"Expected model '" + model + "' could not be found inside the generated JAR files!");
}
}