Search in sources :

Example 1 with InferenceExampleStreamer

use of edu.cmu.ml.proppr.examples.InferenceExampleStreamer in project ProPPR by TeamCohen.

the class Grounder method groundExamples.

public void groundExamples(File dataFile, File groundedFile, boolean maintainOrder) {
    status.start();
    try {
        if (this.graphKeyFile != null)
            this.graphKeyWriter = new BufferedWriter(new FileWriter(this.graphKeyFile));
        this.statistics = new GroundingStatistics();
        this.empty = 0;
        Multithreading<InferenceExample, String> m = new Multithreading<InferenceExample, String>(log, this.status, maintainOrder);
        m.executeJob(this.nthreads, new InferenceExampleStreamer(dataFile).stream(), new Transformer<InferenceExample, String>() {

            @Override
            public Callable<String> transformer(InferenceExample in, int id) {
                return new Ground(in, id);
            }
        }, groundedFile, this.throttle);
        reportStatistics(empty);
        File indexFile = new File(groundedFile.getParent(), groundedFile.getName() + FEATURE_INDEX_EXTENSION);
        serializeFeatures(indexFile, featureTable);
        if (this.graphKeyFile != null)
            this.graphKeyWriter.close();
    } catch (IOException e) {
        e.printStackTrace();
    }
}
Also used : FileWriter(java.io.FileWriter) IOException(java.io.IOException) InferenceExample(edu.cmu.ml.proppr.examples.InferenceExample) Callable(java.util.concurrent.Callable) BufferedWriter(java.io.BufferedWriter) Multithreading(edu.cmu.ml.proppr.util.multithreading.Multithreading) ParamsFile(edu.cmu.ml.proppr.util.ParamsFile) File(java.io.File) InferenceExampleStreamer(edu.cmu.ml.proppr.examples.InferenceExampleStreamer)

Aggregations

InferenceExample (edu.cmu.ml.proppr.examples.InferenceExample)1 InferenceExampleStreamer (edu.cmu.ml.proppr.examples.InferenceExampleStreamer)1 ParamsFile (edu.cmu.ml.proppr.util.ParamsFile)1 Multithreading (edu.cmu.ml.proppr.util.multithreading.Multithreading)1 BufferedWriter (java.io.BufferedWriter)1 File (java.io.File)1 FileWriter (java.io.FileWriter)1 IOException (java.io.IOException)1 Callable (java.util.concurrent.Callable)1