@Override public void finish() throws Exception { IOUtils.writeObjectToFile(mentionPairs, StatisticalCorefTrainer.datasetFile); } }
@Override public void finish() throws Exception { IOUtils.writeObjectToFile(mentionTypes, StatisticalCorefTrainer.mentionTypesFile); IOUtils.writeObjectToFile(goldClusters, StatisticalCorefTrainer.goldClustersFile); if (countWords) { IOUtils.writeObjectToFile(wordCounts, StatisticalCorefTrainer.wordCountsFile); } } }
@Override public void finish() throws Exception { IOUtils.writeObjectToFile(documents, StatisticalCorefTrainer.extractedFeaturesFile); IOUtils.writeObjectToFile(compressor, StatisticalCorefTrainer.compressorFile); } }
/** * Write an object to a specified File. The file is silently gzipped if the filename ends with .gz. * * @param o Object to be written to file * @param file The temp File * @throws IOException If File cannot be written * @return File containing the object */ public static File writeObjectToFile(Object o, File file) throws IOException { return writeObjectToFile(o, file, false); }
public void writeWeights(String fname) throws Exception { IOUtils.writeObjectToFile(weights, fname); }
public void writeToFile(String filename) throws IOException { IOUtils.writeObjectToFile(wordVectors, filename); }
/** * Write object to a file with the specified name. The file is silently gzipped if the filename ends with .gz. * * @param o Object to be written to file * @param filename Name of the temp file * @throws IOException If can't write file. * @return File containing the object */ public static File writeObjectToFile(Object o, String filename) throws IOException { return writeObjectToFile(o, new File(filename)); }
/** * Write object to temp file which is destroyed when the program exits. * * @param o Object to be written to file * @param filename Name of the temp file * @throws IOException If file cannot be written * @return File containing the object */ public static File writeObjectToTempFile(Object o, String filename) throws IOException { File file = File.createTempFile(filename, ".tmp"); file.deleteOnExit(); writeObjectToFile(o, file); return file; }
/** * Convenience wrapper for IOUtils.writeObjectToFile. */ public static void writeClassifier(LinearClassifier<?, ?> classifier, String serializePath) { try { IOUtils.writeObjectToFile(classifier, serializePath); logger.info("Serializing classifier to " + serializePath + "... done."); } catch (Exception e) { throw new RuntimeException("Serialization failed: " + e.getMessage(), e); } }
@Override public void saveIndex(String dir){ try { IOUtils.ensureDir(new File(dir)); IOUtils.writeObjectToFile(index, dir + "/map.ser"); } catch (IOException e) { throw new RuntimeException(e); } }
public void saveSerialized(String path) { try { IOUtils.writeObjectToFile(this, path); } catch (IOException e) { throw new RuntimeIOException(e); } }
public void saveModel(String path) { try { IOUtils.writeObjectToFile(this, path); } catch (IOException e) { throw new RuntimeIOException(e); } }
public static void main(String[] args) throws IOException, ClassNotFoundException { Object o = IOUtils.readObjectFromFile(args[0]); IOUtils.writeObjectToFile(o, args[1]); } }
@Override public boolean save(String dir) { try { IOUtils.ensureDir(new File(dir)); String f = dir+"/allpatterns.ser"; IOUtils.writeObjectToFile(this.patternsForEachToken, f); Redwood.log(Redwood.DBG, "Saving the patterns to " + f); } catch (IOException e) { throw new RuntimeException(e); } return true; }
public static void serializeWeights(String serializePath,double[] weights,double[] diag) { log.info("Serializing weights to " + serializePath + "..."); try { Weights out = new Weights(weights,diag); IOUtils.writeObjectToFile(out, serializePath); } catch (Exception e) { log.info("Error serializing to " + serializePath); e.printStackTrace(); } }
IOUtils.writeObjectToFile(genderNumber, output);
IOUtils.writeObjectToFile(corpusSentences,serializedSentences); MachineReadingProperties.logger.info("Done. Serialized " + AnnotationUtils.sentenceCount(corpusSentences) + " sentences.");
IOUtils.writeObjectToFile(pats, patternsWordsDir + "/" + label + "/patternsEachIter.ser");
IOUtils.writeObjectToFile(new KBPStatisticalExtractor(classifier), MODEL_FILE);
public static void test(PairwiseModel model, String predictionsName, boolean anaphoricityModel) throws Exception { Redwood.log("scoref-train", "Reading compression..."); Compressor<String> compressor = IOUtils.readObjectFromFile( StatisticalCorefTrainer.compressorFile); Redwood.log("scoref-train", "Reading test data..."); List<DocumentExamples> testDocuments = IOUtils.readObjectFromFile( StatisticalCorefTrainer.extractedFeaturesFile); Redwood.log("scoref-train", "Building test set..."); List<Pair<Example, Map<Integer, CompressedFeatureVector>>> allExamples = anaphoricityModel ? getAnaphoricityExamples(testDocuments) : getExamples(testDocuments); Redwood.log("scoref-train", "Testing..."); PrintWriter writer = new PrintWriter(model.getDefaultOutputPath() + predictionsName); Map<Integer, Counter<Pair<Integer, Integer>>> scores = new HashMap<>(); writeScores(allExamples, compressor, model, writer, scores); if (model instanceof MaxMarginMentionRanker) { writer.close(); writer = new PrintWriter(model.getDefaultOutputPath() + predictionsName + "_anaphoricity"); testDocuments = IOUtils.readObjectFromFile( StatisticalCorefTrainer.extractedFeaturesFile); allExamples = getAnaphoricityExamples(testDocuments); writeScores(allExamples, compressor, model, writer, scores); } IOUtils.writeObjectToFile(scores, model.getDefaultOutputPath() + predictionsName + ".ser"); writer.close(); }