Search in sources :

Example 1 with Classification

use of de.dagere.peass.analysis.groups.Classification in project peass by DaGeRe.

the class ClassifyByRules method classifyProject.

private void classifyProject(final Set<String> allFeatures, final String project) throws IOException, JsonParseException, JsonMappingException {
    final RepoFolders repos = new RepoFolders();
    final File learnFile = new File(repos.getClassificationFolder(), project + ".json");
    final File learnPropertyFile = repos.getProjectPropertyFile(project);
    final Classification learn = Constants.OBJECTMAPPER.readValue(learnFile, Classification.class);
    final VersionChangeProperties changes = Constants.OBJECTMAPPER.readValue(learnPropertyFile, VersionChangeProperties.class);
    final File methodFileFolder = new File(learnPropertyFile.getParentFile(), "methods");
    try (BufferedWriter csvWriter = new BufferedWriter(new FileWriter(new File(project + ".csv")))) {
        for (final Entry<String, ChangeProperties> version : changes.getVersions().entrySet()) {
            final File versionFolder = new File(methodFileFolder, version.getKey());
            for (final Entry<String, List<ChangeProperty>> testcase : version.getValue().getProperties().entrySet()) {
                for (final ChangeProperty property : testcase.getValue()) {
                    final VersionClass versionClass = learn.getVersions().get(version.getKey());
                    final ChangedEntity entity = new ChangedEntity(testcase.getKey(), "", property.getMethod());
                    final TestcaseClass testcaseClass = versionClass.getTestcases().get(entity);
                    final GuessDecider guesser = new GuessDecider(versionFolder);
                    final Set<String> types = testcaseClass.getTypes();
                    writeFeatures(allFeatures, csvWriter, property, guesser);
                    writeType(csvWriter, types);
                    csvWriter.write("\n");
                    csvWriter.flush();
                }
            }
        }
    }
}
Also used : VersionClass(de.dagere.peass.analysis.groups.VersionClass) FileWriter(java.io.FileWriter) ChangeProperty(de.dagere.peass.analysis.properties.ChangeProperty) ChangedEntity(de.dagere.peass.dependency.analysis.data.ChangedEntity) VersionChangeProperties(de.dagere.peass.analysis.properties.VersionChangeProperties) BufferedWriter(java.io.BufferedWriter) Classification(de.dagere.peass.analysis.groups.Classification) ChangeProperties(de.dagere.peass.analysis.properties.ChangeProperties) VersionChangeProperties(de.dagere.peass.analysis.properties.VersionChangeProperties) LinkedList(java.util.LinkedList) List(java.util.List) File(java.io.File) GuessDecider(de.dagere.peass.analysis.guessing.GuessDecider) RepoFolders(de.dagere.peass.analysis.all.RepoFolders) TestcaseClass(de.dagere.peass.analysis.groups.TestcaseClass)

Example 2 with Classification

use of de.dagere.peass.analysis.groups.Classification in project peass by DaGeRe.

the class ClassifyByRules method getAllFeatures.

private Set<String> getAllFeatures() throws IOException, JsonParseException, JsonMappingException {
    final Set<String> allFeatures = new HashSet<>();
    for (final String project : new String[] { learnproject, classifyproject }) {
        final RepoFolders repos = new RepoFolders();
        final File learnFile = new File(repos.getClassificationFolder(), project + ".json");
        final File learnPropertyFile = repos.getProjectPropertyFile(project);
        final Classification learn = Constants.OBJECTMAPPER.readValue(learnFile, Classification.class);
        final VersionChangeProperties changes = Constants.OBJECTMAPPER.readValue(learnPropertyFile, VersionChangeProperties.class);
        final File methodFileFolder = new File(learnPropertyFile.getParentFile(), "methods");
        getAllWords(learn, changes, methodFileFolder, allFeatures);
    }
    return allFeatures;
}
Also used : Classification(de.dagere.peass.analysis.groups.Classification) VersionChangeProperties(de.dagere.peass.analysis.properties.VersionChangeProperties) File(java.io.File) HashSet(java.util.HashSet) RepoFolders(de.dagere.peass.analysis.all.RepoFolders)

Example 3 with Classification

use of de.dagere.peass.analysis.groups.Classification in project peass by DaGeRe.

the class FindWrong method main.

public static void main(final String[] args) throws JsonParseException, JsonMappingException, IOException {
    final File executeCommands = new File("execute-wrong.sh");
    final PrintStream goal = new PrintStream(new FileOutputStream(executeCommands));
    final File folder = new File("/home/reichelt/daten3/diss/repos/properties/classification");
    int index = 0;
    for (final File project : folder.listFiles()) {
        if (project.getName().endsWith(".json")) {
            final String projectName = project.getName().substring(0, project.getName().indexOf('.'));
            final String url = Constants.defaultUrls.get(projectName);
            RunCommandWriter writer = new RunCommandWriterSlurm(goal, "wrong_rerun", projectName, url);
            if (url != null) {
                final Classification data = Constants.OBJECTMAPPER.readValue(project, Classification.class);
                for (final Map.Entry<String, VersionClass> version : data.getVersions().entrySet()) {
                    for (final Map.Entry<ChangedEntity, TestcaseClass> method : version.getValue().getTestcases().entrySet()) {
                        if (method.getValue().getTypes().contains("WRONG") || method.getValue().getTypes().contains("WRONGTEST")) {
                            // System.out.println(version.getKey() + " " + method.getKey());
                            writer.createSingleMethodCommand(index, version.getKey(), method.getKey().toString());
                            index++;
                        }
                    }
                }
            } else {
                System.err.println("Missing url: " + projectName);
            }
        }
    }
}
Also used : PrintStream(java.io.PrintStream) VersionClass(de.dagere.peass.analysis.groups.VersionClass) RunCommandWriterSlurm(de.dagere.peass.measurement.utils.RunCommandWriterSlurm) ChangedEntity(de.dagere.peass.dependency.analysis.data.ChangedEntity) FileOutputStream(java.io.FileOutputStream) Classification(de.dagere.peass.analysis.groups.Classification) RunCommandWriter(de.dagere.peass.measurement.utils.RunCommandWriter) File(java.io.File) Map(java.util.Map) TestcaseClass(de.dagere.peass.analysis.groups.TestcaseClass)

Example 4 with Classification

use of de.dagere.peass.analysis.groups.Classification in project peass by DaGeRe.

the class GuessClassificationsByRules method call.

@Override
public Void call() throws Exception {
    RepoFolders repos = new RepoFolders();
    File propertyFile = new File(methodFileFolder.getParentFile(), project + ".json");
    File classificationFile = new File(repos.getClassificationFolder(), project + ".json");
    Classification manual = Constants.OBJECTMAPPER.readValue(classificationFile, Classification.class);
    final VersionChangeProperties changes = Constants.OBJECTMAPPER.readValue(propertyFile, VersionChangeProperties.class);
    for (Entry<String, ChangeProperties> version : changes.getVersions().entrySet()) {
        guessVersion(manual, version);
    }
    System.out.println("Correct: " + correct + " Wrong " + wrong + " All: " + all);
    return null;
}
Also used : Classification(de.dagere.peass.analysis.groups.Classification) ChangeProperties(de.dagere.peass.analysis.properties.ChangeProperties) VersionChangeProperties(de.dagere.peass.analysis.properties.VersionChangeProperties) VersionChangeProperties(de.dagere.peass.analysis.properties.VersionChangeProperties) File(java.io.File) RepoFolders(de.dagere.peass.analysis.all.RepoFolders)

Aggregations

Classification (de.dagere.peass.analysis.groups.Classification)4 File (java.io.File)4 RepoFolders (de.dagere.peass.analysis.all.RepoFolders)3 VersionChangeProperties (de.dagere.peass.analysis.properties.VersionChangeProperties)3 TestcaseClass (de.dagere.peass.analysis.groups.TestcaseClass)2 VersionClass (de.dagere.peass.analysis.groups.VersionClass)2 ChangeProperties (de.dagere.peass.analysis.properties.ChangeProperties)2 ChangedEntity (de.dagere.peass.dependency.analysis.data.ChangedEntity)2 GuessDecider (de.dagere.peass.analysis.guessing.GuessDecider)1 ChangeProperty (de.dagere.peass.analysis.properties.ChangeProperty)1 RunCommandWriter (de.dagere.peass.measurement.utils.RunCommandWriter)1 RunCommandWriterSlurm (de.dagere.peass.measurement.utils.RunCommandWriterSlurm)1 BufferedWriter (java.io.BufferedWriter)1 FileOutputStream (java.io.FileOutputStream)1 FileWriter (java.io.FileWriter)1 PrintStream (java.io.PrintStream)1 HashSet (java.util.HashSet)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 Map (java.util.Map)1