All Downloads are FREE. Search and download functionalities are using the official Maven repository.

fr.inria.prophet4j.P4J Maven / Gradle / Ivy

The newest version!
package fr.inria.prophet4j;

import fr.inria.prophet4j.utility.CodeDiffer;
import fr.inria.prophet4j.utility.Option;
import fr.inria.prophet4j.utility.Option.DataOption;
import fr.inria.prophet4j.utility.Option.FeatureOption;
import fr.inria.prophet4j.utility.Option.PatchOption;
import fr.inria.prophet4j.utility.Option.LearnerOption;
import fr.inria.prophet4j.utility.Structure;

import java.io.File;
import java.util.List;

// this is the API class of Prophet4J
public class P4J {
    private CodeDiffer codeDiffer;
    private Structure.ParameterVector parameterVector;

    public P4J() {
        Option option = new Option();
        option.dataOption = DataOption.BUG_DOT_JAR_MINUS_MATH;
        option.patchOption = PatchOption.BUG_DOT_JAR_MINUS_MATH;
        option.featureOption = FeatureOption.ORIGINAL;
        option.learnerOption = LearnerOption.CROSS_ENTROPY;

        this.codeDiffer = new CodeDiffer(false, option);
        this.parameterVector = new Structure.ParameterVector(option.featureOption);
    }

    public double computeOverfittingScore(File buggyFile, File patchedFile) {
        List featureMatrices = codeDiffer.runByGenerator(buggyFile, patchedFile);
        if (featureMatrices.size() == 1) {
            return featureMatrices.get(0).score(parameterVector);
        }
        return 0;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy