fields = scrapeFields(c); } catch (Throwable e) { debug("Could not check fields for class: " + c.getName() + " (caused by " + e.getClass() + ": " + e.getMessage() + ')'); continue; String name2 = f.getDeclaringClass().getCanonicalName() + '.' + f.getName(); if (!name1.equals(name2)) { runtimeException("Multiple declarations of option " + name + ": " + name1 + " and " + name2); } else { err("Class is in classpath multiple times: " + canFill.get(name).getDeclaringClass().getCanonicalName()); warn("found @Option annotations in class " + c + ", but didn't set any of them (all options were instance variables and no instance given?)"); err("Unrecognized option: " + key); continue; clazz = ClassLoader.getSystemClassLoader().loadClass(className); } catch (Exception e) { err("Could not set option: " + entry.getKey() + "; either the option is mistyped, not defined, or the class " + className + " does not exist."); target = clazz.getField(fieldName); } catch (Exception e) { err("Could not set option: " + entry.getKey() + "; no such field: " + fieldName + " in class: " + className); log("option overrides " + target + " to '" + value + '\''); fillField(class2object.get(target.getDeclaringClass()), target, value); } else { err("Could not set option: " + entry.getKey() + "; no such field: " + fieldName + " in class: " + className);
startThreads(title); //<--this must be a blocking operation finishThread(); threadFinished = true; synchronized (iter) { if (numStillPending <= 0 && !iter.hasNext()) { endThreads(title); t.printStackTrace(); if (!threadFinished) { finishThread();
forceTrack("Training inference"); trainingData.forEach(rawExample -> { log("processed " + numExamplesProcessed + " training sentences: " + dataset.size() + " datums"); endTrack("Training inference"); forceTrack("Training"); Classifier<ClauseClassifierLabel,String> fullClassifier = factory.trainClassifier(dataset); endTrack("Training"); if (modelPath.isPresent()) { Pair<Classifier<ClauseClassifierLabel,String>, Featurizer> toSave = Pair.makePair(fullClassifier, featurizer); try { IOUtils.writeObjectToFile(toSave, modelPath.get()); log("SUCCESS: wrote model to " + modelPath.get().getPath()); } catch (IOException e) { log("ERROR: failed to save model to path: " + modelPath.get().getPath()); err(e); forceTrack("Training accuracy"); dataset.randomize(42L); Util.dumpAccuracy(fullClassifier, dataset); endTrack("Training accuracy"); forceTrack(numFolds + " fold cross-validation"); for (int fold = 0; fold < numFolds; ++fold) { forceTrack("Fold " + (fold + 1)); forceTrack("Training"); Pair<GeneralDataset<ClauseClassifierLabel, String>, GeneralDataset<ClauseClassifierLabel, String>> foldData = dataset.splitOutFold(fold, numFolds);
fields = scrapeFields(c); } catch (Throwable e) { debug("Could not check fields for class: " + c.getName() + " (caused by " + e.getClass() + ": " + e.getMessage() + ')'); continue; String name2 = f.getDeclaringClass().getCanonicalName() + '.' + f.getName(); if (!name1.equals(name2)) { runtimeException("Multiple declarations of option " + name + ": " + name1 + " and " + name2); } else { err("Class is in classpath multiple times: " + canFill.get(name).getDeclaringClass().getCanonicalName()); warn("found @Option annotations in class " + c + ", but didn't set any of them (all options were instance variables and no instance given?)"); err("Unrecognized option: " + key); continue; clazz = ClassLoader.getSystemClassLoader().loadClass(className); } catch (Exception e) { err("Could not set option: " + entry.getKey() + "; either the option is mistyped, not defined, or the class " + className + " does not exist."); target = clazz.getField(fieldName); } catch (Exception e) { err("Could not set option: " + entry.getKey() + "; no such field: " + fieldName + " in class: " + className); log("option overrides " + target + " to '" + value + '\''); fillField(class2object.get(target.getDeclaringClass()), target, value); } else { err("Could not set option: " + entry.getKey() + "; no such field: " + fieldName + " in class: " + className);
fields = scrapeFields(c); } catch (Throwable e) { debug("Could not check fields for class: " + c.getName() + " (caused by " + e.getClass() + ": " + e.getMessage() + ')'); continue; String name2 = f.getDeclaringClass().getCanonicalName() + '.' + f.getName(); if (!name1.equals(name2)) { runtimeException("Multiple declarations of option " + name + ": " + name1 + " and " + name2); } else { err("Class is in classpath multiple times: " + canFill.get(name).getDeclaringClass().getCanonicalName()); warn("found @Option annotations in class " + c + ", but didn't set any of them (all options were instance variables and no instance given?)"); err("Unrecognized option: " + key); continue; clazz = ClassLoader.getSystemClassLoader().loadClass(className); } catch (Exception e) { err("Could not set option: " + entry.getKey() + "; either the option is mistyped, not defined, or the class " + className + " does not exist."); target = clazz.getField(fieldName); } catch (Exception e) { err("Could not set option: " + entry.getKey() + "; no such field: " + fieldName + " in class: " + className); log("option overrides " + target + " to '" + value + '\''); fillField(class2object.get(target.getDeclaringClass()), target, value); } else { err("Could not set option: " + entry.getKey() + "; no such field: " + fieldName + " in class: " + className);
forceTrack("Training inference"); trainingData.forEach(rawExample -> { log("processed " + numExamplesProcessed + " training sentences: " + dataset.size() + " datums"); endTrack("Training inference"); forceTrack("Training"); Classifier<ClauseClassifierLabel,String> fullClassifier = factory.trainClassifier(dataset); endTrack("Training"); if (modelPath.isPresent()) { Pair<Classifier<ClauseClassifierLabel,String>, Featurizer> toSave = Pair.makePair(fullClassifier, featurizer); try { IOUtils.writeObjectToFile(toSave, modelPath.get()); log("SUCCESS: wrote model to " + modelPath.get().getPath()); } catch (IOException e) { log("ERROR: failed to save model to path: " + modelPath.get().getPath()); err(e); forceTrack("Training accuracy"); dataset.randomize(42L); Util.dumpAccuracy(fullClassifier, dataset); endTrack("Training accuracy"); forceTrack(numFolds + " fold cross-validation"); for (int fold = 0; fold < numFolds; ++fold) { forceTrack("Fold " + (fold + 1)); forceTrack("Training"); Pair<GeneralDataset<ClauseClassifierLabel, String>, GeneralDataset<ClauseClassifierLabel, String>> foldData = dataset.splitOutFold(fold, numFolds);
fields = c.getDeclaredFields(); } catch (Throwable e) { debug("Could not check fields for class: " + c.getName() + " (caused by " + e.getClass() + ": " + e.getMessage() + ")"); continue; String name2 = f.getDeclaringClass().getCanonicalName() + "." + f.getName(); if (!name1.equals(name2)) { fatal("Multiple declarations of option " + name + ": " + name1 + " and " + name2); } else { err("Class is in classpath multiple times: " + canFill.get(name).getDeclaringClass().getCanonicalName()); warn("found @Option annotations in class " + c + ", but didn't set any of them (all options were instance variables and no instance given?)"); fatal("Unrecognized option: " + key); clazz = ClassLoader.getSystemClassLoader().loadClass(className); } catch (Exception e) { err("Could not set option: " + rawKey + "; either the option is mistyped, not defined, or the class " + className + " does not exist."); target = clazz.getField(fieldName); } catch (Exception e) { err("Could not set option: " + rawKey + "; no such field: " + fieldName + " in class: " + className); log("option overrides " + target + " to '" + value + "'"); fillField(class2object.get(target.getDeclaringClass()), target, value); } else { err("Could not set option: " + rawKey + "; no such field: " + fieldName + " in class: " + className); Pair<Boolean, Boolean> mark = required.get(key);
err("Skipping " + file.getName() + ": output file " + finalOutputFilename + " as it already exists. Don't use the noClobber option to override this."); synchronized (totalSkipped) { totalSkipped.incValue(1); forceTrack("Processing file " + file.getAbsolutePath() + " ... writing to " + finalOutputFilename); forceTrack("Annotating file " + file.getAbsoluteFile()); try { annotate(annotation); err("Error annotating " + file.getAbsoluteFile(), ex); annotationOkay = false; synchronized (totalErrorAnnotating) { endTrack("Annotating file " + file.getAbsoluteFile()); totalProcessed.incValue(1); if (totalProcessed.intValue() % 1000 == 0) { log("Processed " + totalProcessed + " documents"); warn("Error annotating " + file.getAbsoluteFile() + " not saved to " + finalOutputFilename); endTrack("Processing file " + file.getAbsolutePath() + " ... writing to " + finalOutputFilename);
log("Checking cp " + entry); ClassLoader.getSystemClassLoader())); } catch (ClassNotFoundException ex) { warn("Could not load class in jar: " + f + " at path: " + clazz); } catch (NoClassDefFoundError ex) { debug("Could not scan class: " + clazz + " (in jar: " + f + ")"); warn("Could not open jar file: " + f + "(are you sure the file exists?)");
log(b.toString()); fatal("Option cannot be final: " + f); fatal("Setting an array to a non-array field. field: " + f + " value: " + Arrays.toString(array) + " src: " + value); fatal("Cannot assign option field: " + f + " value: " + value + "; invalid type"); err(e); fatal("Cannot assign option field: " + f.getDeclaringClass().getCanonicalName() + "." + f.getName() + " value: " + value + " cause: " + e.getMessage()); } catch (IllegalAccessException e) { err(e); fatal("Cannot access option field: " + f.getDeclaringClass().getCanonicalName() + "." + f.getName()); } catch (Exception e) { err(e); fatal("Cannot assign option field: " + f.getDeclaringClass().getCanonicalName() + "." + f.getName() + " value: " + value + " cause: " + e.getMessage());
log("Checking cp " + entry); error(ioe); ClassLoader.getSystemClassLoader())); } catch (ClassNotFoundException ex) { warn("Could not load class in jar: " + f + " at path: " + clazz); } catch (NoClassDefFoundError ex) { debug("Could not scan class: " + clazz + " (in jar: " + f + ')'); warn("Could not open jar file: " + f + "(are you sure the file exists?)");
log(b.toString()); runtimeException("Option cannot be final: " + f); runtimeException("Setting an array to a non-array field. field: " + f + " value: " + Arrays.toString(array) + " src: " + value); runtimeException("Cannot assign option field: " + f + " value: " + value + "; invalid type"); err(e); runtimeException("Cannot assign option field: " + f.getDeclaringClass().getCanonicalName() + '.' + f.getName() + " value: " + value + " cause: " + e.getMessage()); } catch (IllegalAccessException e) { err(e); runtimeException("Cannot access option field: " + f.getDeclaringClass().getCanonicalName() + '.' + f.getName()); } catch (Exception e) { err(e); runtimeException("Cannot assign option field: " + f.getDeclaringClass().getCanonicalName() + '.' + f.getName() + " value: " + value + " cause: " + e.getMessage());
log("--- " + StanfordCoreNLPServer.class.getSimpleName() + "#main() called ---"); String build = System.getenv("BUILD"); if (build != null) { log(" Build: " + build); Runtime.getRuntime().addShutdownHook(new Thread(() -> log("CoreNLP Server is shutting down."))); server.statusPort = Integer.parseInt(serverProperties.getProperty("port")); log(" Threads: " + ArgumentParser.threads); new StanfordCoreNLP(props); } catch (Throwable ignored) { err("Could not pre-load annotators in server; encountered exception:"); ignored.printStackTrace(); log("Starting server..."); if (server.ssl) { server.run(credentials, req -> true, res -> {}, homepage, true, live);
log(b.toString()); runtimeException("Option cannot be final: " + f); runtimeException("Setting an array to a non-array field. field: " + f + " value: " + Arrays.toString(array) + " src: " + value); runtimeException("Cannot assign option field: " + f + " value: " + value + "; invalid type"); err(e); runtimeException("Cannot assign option field: " + f.getDeclaringClass().getCanonicalName() + '.' + f.getName() + " value: " + value + " cause: " + e.getMessage()); } catch (IllegalAccessException e) { err(e); runtimeException("Cannot access option field: " + f.getDeclaringClass().getCanonicalName() + '.' + f.getName()); } catch (Exception e) { err(e); runtimeException("Cannot assign option field: " + f.getDeclaringClass().getCanonicalName() + '.' + f.getName() + " value: " + value + " cause: " + e.getMessage());
log("Checking cp " + entry); error(ioe); ClassLoader.getSystemClassLoader())); } catch (ClassNotFoundException ex) { warn("Could not load class in jar: " + f + " at path: " + clazz); } catch (NoClassDefFoundError ex) { debug("Could not scan class: " + clazz + " (in jar: " + f + ')'); warn("Could not open jar file: " + f + "(are you sure the file exists?)");