|
11 | 11 | import java.util.stream.Stream; |
12 | 12 | import org.variantsync.diffdetective.AnalysisRunner; |
13 | 13 | import org.variantsync.diffdetective.analysis.Analysis; |
| 14 | +import org.variantsync.diffdetective.datasets.DatasetDescription; |
| 15 | +import org.variantsync.diffdetective.datasets.DefaultDatasets; |
14 | 16 | import org.variantsync.diffdetective.datasets.PatchDiffParseOptions; |
15 | 17 | import org.variantsync.diffdetective.datasets.PatchDiffParseOptions.DiffStoragePolicy; |
16 | 18 | import org.variantsync.diffdetective.datasets.Repository; |
|
19 | 21 |
|
20 | 22 | public class Main { |
21 | 23 |
|
22 | | - public static String dataSetPath = ""; |
23 | | - |
24 | 24 | public static void main(String[] args) throws IOException { |
25 | 25 | startAnalysis(); |
26 | | - // evaluationAnalysis(Path.of("docs","datasets","eugen-bachelor-thesis.md")); |
| 26 | + evaluationAnalysis(Path.of("docs", "datasets", "eugen-bachelor-thesis.md")); |
27 | 27 |
|
28 | 28 | } |
29 | 29 |
|
@@ -54,24 +54,32 @@ protected static BiConsumer<Repository, Path> extractionRunner() { |
54 | 54 | }; |
55 | 55 | } |
56 | 56 |
|
| 57 | + /** |
| 58 | + * Verarbeitet die Ergebnisse der Analyse um aus einzelnen |
| 59 | + * Angaben eine gesamt Übersicht zu bekommen |
| 60 | + * |
| 61 | + * @param path Pfad zu der markdown datei, aus der die repositories für die |
| 62 | + * Analyse stammen |
| 63 | + * @throws IOException |
| 64 | + */ |
57 | 65 | private static void evaluationAnalysis(Path path) throws IOException { |
58 | 66 | int count = 0; |
59 | | - int error = 0; |
60 | 67 | int[] diffTest = { 0, 0, 0, 0, 0, 0, 0, 0 }; |
61 | 68 | int[] diffSemEqTest = { 0, 0, 0, 0, }; |
62 | 69 | int[] treeTest = { 0, 0, 0, 0, 0, 0, 0, 0 }; |
63 | | - List<String> errorList = new ArrayList<>(); |
64 | | - String data = Files.readString(path); |
65 | | - String[] splitPathData = data.split("\n"); |
66 | | - for (int i = 2; i < splitPathData.length; i++) { |
67 | | - String name = splitPathData[i].split("|")[0].replaceAll("\\s+", ""); |
| 70 | + final List<DatasetDescription> datasets = DefaultDatasets.loadDatasets(path); |
| 71 | + |
| 72 | + for (DatasetDescription description : datasets) { |
68 | 73 | Stream<Path> files = Files |
69 | | - .list(Path.of("results", "thesis_es", name)) |
| 74 | + .list(Path.of("results", "thesis_es", description.name())) |
70 | 75 | .filter(filename -> filename.getFileName().toString().endsWith(".thesis_es.csv")); |
71 | 76 | for (Path tempPath : files.toList()) { |
72 | 77 | String[] splitFileData = Files.readString(tempPath).split("\n"); |
73 | 78 | for (int j = 1; j < splitFileData.length; j++) { |
74 | 79 | String[] splitLineData = splitFileData[j].split(";"); |
| 80 | + for (int i = 0; i < splitLineData.length; i++) { |
| 81 | + splitLineData[i] = parseNumberStringToIntWithLengthGreaterOne(splitLineData[i]); |
| 82 | + } |
75 | 83 | count = count + 1; |
76 | 84 | diffTest[0] = diffTest[0] + Integer.parseInt(splitLineData[8]); |
77 | 85 | diffTest[1] = diffTest[1] + Integer.parseInt(splitLineData[9]); |
@@ -101,55 +109,77 @@ private static void evaluationAnalysis(Path path) throws IOException { |
101 | 109 | treeTest[5] = treeTest[5] + Integer.parseInt(splitLineData[33]); |
102 | 110 | treeTest[6] = treeTest[6] + Integer.parseInt(splitLineData[34]); |
103 | 111 | treeTest[7] = treeTest[7] + Integer.parseInt(splitLineData[35]); |
104 | | - int errorCode = Integer.parseInt(splitLineData[36]); |
105 | | - if (errorCode != 1) { |
106 | | - if (errorCode % 2 == 0) { |
107 | | - errorList.add(splitLineData[37]); |
108 | | - error = error + 1; |
109 | | - } |
110 | | - if (errorCode % 3 == 0) { |
111 | | - errorList.add(splitLineData[38]); |
112 | | - error = error + 1; |
113 | | - } |
114 | | - if (errorCode % 5 == 0) { |
115 | | - errorList.add(splitLineData[39]); |
116 | | - error = error + 1; |
117 | | - } |
118 | | - } |
| 112 | + |
119 | 113 | } |
120 | 114 | } |
121 | 115 | } |
122 | 116 | List<String> result = new ArrayList<>(); |
123 | | - result.add("Anzahl geprüfter Diffs : " + count); |
124 | | - result.add("Anzahl syntaktisch korrekter Diffs mit MultiLine0 und EmptyLine0 : " + diffTest[0]); |
125 | | - result.add("Anzahl syntaktisch korrekter Diffs mit MultiLine1 und EmptyLine0 : " + diffTest[1]); |
126 | | - result.add("Anzahl syntaktisch korrekter Diffs mit MultiLine0 und EmptyLine1 : " + diffTest[2]); |
127 | | - result.add("Anzahl syntaktisch korrekter Diffs mit MultiLine1 und EmptyLine1 : " + diffTest[3]); |
128 | | - result.add("Anzahl syntaktisch korrekter Diffs ohne Whitespace mit MultiLine0 und EmptyLine0 : " + diffTest[4]); |
129 | | - result.add("Anzahl syntaktisch korrekter Diffs ohne Whitespace mit MultiLine1 und EmptyLine0 : " + diffTest[5]); |
130 | | - result.add("Anzahl syntaktisch korrekter Diffs ohne Whitespace mit MultiLine0 und EmptyLine1 : " + diffTest[6]); |
131 | | - result.add("Anzahl syntaktisch korrekter Diffs ohne Whitespace mit MultiLine1 und EmptyLine1 : " + diffTest[7]); |
132 | | - result.add("Anzahl semantisch korrekter Diffs mit MultiLine0 und EmptyLine0 : " + diffSemEqTest[0]); |
133 | | - result.add("Anzahl semantisch korrekter Diffs mit MultiLine1 und EmptyLine0 : " + diffSemEqTest[1]); |
134 | | - result.add("Anzahl semantisch korrekter Diffs mit MultiLine0 und EmptyLine1 : " + diffSemEqTest[2]); |
135 | | - result.add("Anzahl semantisch korrekter Diffs mit MultiLine1 und EmptyLine1 : " + diffSemEqTest[3]); |
136 | | - result.add("Anzahl syntaktisch korrekter Trees mit MultiLine0 und EmptyLine0 : " + treeTest[0]); |
137 | | - result.add("Anzahl syntaktisch korrekter Trees mit MultiLine1 und EmptyLine0 : " + treeTest[1]); |
138 | | - result.add("Anzahl syntaktisch korrekter Trees mit MultiLine0 und EmptyLine1 : " + treeTest[2]); |
139 | | - result.add("Anzahl syntaktisch korrekter Trees mit MultiLine1 und EmptyLine1 : " + treeTest[3]); |
140 | | - result.add("Anzahl syntaktisch korrekter Trees ohne Whitespace mit MultiLine0 und EmptyLine0 : " + treeTest[4]); |
141 | | - result.add("Anzahl syntaktisch korrekter Trees ohne Whitespace mit MultiLine1 und EmptyLine0 : " + treeTest[5]); |
142 | | - result.add("Anzahl syntaktisch korrekter Trees ohne Whitespace mit MultiLine0 und EmptyLine1 : " + treeTest[6]); |
143 | | - result.add("Anzahl syntaktisch korrekter Trees ohne Whitespace mit MultiLine1 und EmptyLine1 : " + treeTest[7]); |
144 | | - result.add("Anzahl Fehler : " + error); |
| 117 | + result.add("Anzahl geprüfter Diffs : " + count + "\n"); |
| 118 | + result.add("Anzahl syntaktisch korrekter Diffs mit MultiLine0 und EmptyLine0 : " + diffTest[0] + "\n"); |
| 119 | + result.add("Anzahl syntaktisch korrekter Diffs ohne Whitespace mit MultiLine0 und EmptyLine0 : " + diffTest[4] |
| 120 | + + "\n"); |
| 121 | + result.add("Anzahl semantisch korrekter Diffs mit MultiLine0 und EmptyLine0 : " + diffSemEqTest[0] + "\n"); |
| 122 | + result.add("Anzahl von Diffs mit MultiLine0 und EmptyLine0, welche keine Korrektheitskriterium erfühlt haben : " |
| 123 | + + (count - diffSemEqTest[0]) + "\n"); |
| 124 | + |
| 125 | + result.add("Anzahl syntaktisch korrekter Diffs mit MultiLine1 und EmptyLine0 : " + diffTest[1] + "\n"); |
| 126 | + result.add("Anzahl syntaktisch korrekter Diffs ohne Whitespace mit MultiLine1 und EmptyLine0 : " + diffTest[5] |
| 127 | + + "\n"); |
| 128 | + result.add("Anzahl semantisch korrekter Diffs mit MultiLine1 und EmptyLine0 : " + diffSemEqTest[1] + "\n"); |
| 129 | + result.add("Anzahl von Diffs mit MultiLine1 und EmptyLine0, welche keine Korrektheitskriterium erfühlt haben : " |
| 130 | + + (count - diffSemEqTest[1]) + "\n"); |
| 131 | + |
| 132 | + result.add("Anzahl syntaktisch korrekter Diffs mit MultiLine0 und EmptyLine1 : " + diffTest[2] + "\n"); |
| 133 | + result.add("Anzahl syntaktisch korrekter Diffs ohne Whitespace mit MultiLine0 und EmptyLine1 : " + diffTest[6] |
| 134 | + + "\n"); |
| 135 | + result.add("Anzahl semantisch korrekter Diffs mit MultiLine0 und EmptyLine1 : " + diffSemEqTest[2] + "\n"); |
| 136 | + result.add("Anzahl von Diffs mit MultiLine0 und EmptyLine1, welche keine Korrektheitskriterium erfühlt haben : " |
| 137 | + + (count - diffSemEqTest[2]) + "\n"); |
| 138 | + |
| 139 | + result.add("Anzahl syntaktisch korrekter Diffs mit MultiLine1 und EmptyLine1 : " + diffTest[3] + "\n"); |
| 140 | + result.add("Anzahl syntaktisch korrekter Diffs ohne Whitespace mit MultiLine1 und EmptyLine1 : " + diffTest[7] |
| 141 | + + "\n"); |
| 142 | + result.add("Anzahl semantisch korrekter Diffs mit MultiLine1 und EmptyLine1 : " + diffSemEqTest[3] + "\n"); |
| 143 | + result.add("Anzahl von Diffs mit MultiLine1 und EmptyLine1, welche keine Korrektheitskriterium erfühlt haben : " |
| 144 | + + (count - diffSemEqTest[3]) + "\n"); |
| 145 | + |
| 146 | + result.add("-------------------------------------------------------------------------------------------"); |
| 147 | + result.add("Anzahl geprüfter Trees : " + count * 2 + "\n"); |
| 148 | + result.add("Anzahl syntaktisch korrekter Trees mit MultiLine0 und EmptyLine0 : " + treeTest[0] + "\n"); |
| 149 | + result.add("Anzahl syntaktisch korrekter Trees ohne Whitespace mit MultiLine0 und EmptyLine0 : " + treeTest[4] |
| 150 | + + "\n"); |
| 151 | + result.add("Anzahl von Trees mit MultiLine0 und EmptyLine0, welche keine Korrektheitskriterium erfühlt haben : " |
| 152 | + + (2 * count - treeTest[4]) + "\n"); |
| 153 | + |
| 154 | + result.add("Anzahl syntaktisch korrekter Trees mit MultiLine1 und EmptyLine0 : " + treeTest[1] + "\n"); |
| 155 | + result.add("Anzahl syntaktisch korrekter Trees ohne Whitespace mit MultiLine1 und EmptyLine0 : " + treeTest[5] |
| 156 | + + "\n"); |
| 157 | + result.add("Anzahl von Trees mit MultiLine1 und EmptyLine0, welche keine Korrektheitskriterium erfühlt haben : " |
| 158 | + + (2 * count - treeTest[5]) + "\n"); |
| 159 | + |
| 160 | + result.add("Anzahl syntaktisch korrekter Trees mit MultiLine0 und EmptyLine1 : " + treeTest[2] + "\n"); |
| 161 | + result.add("Anzahl syntaktisch korrekter Trees ohne Whitespace mit MultiLine0 und EmptyLine1 : " + treeTest[6] |
| 162 | + + "\n"); |
| 163 | + result.add("Anzahl von Trees mit MultiLine0 und EmptyLine1, welche keine Korrektheitskriterium erfühlt haben : " |
| 164 | + + (2 * count - treeTest[6]) + "\n"); |
| 165 | + |
| 166 | + result.add("Anzahl syntaktisch korrekter Trees mit MultiLine1 und EmptyLine1 : " + treeTest[3] + "\n"); |
| 167 | + result.add("Anzahl syntaktisch korrekter Trees ohne Whitespace mit MultiLine1 und EmptyLine1 : " + treeTest[7] |
| 168 | + + "\n"); |
| 169 | + result.add("Anzahl von Trees mit MultiLine1 und EmptyLine1, welche keine Korrektheitskriterium erfühlt haben : " |
| 170 | + + (2 * count - treeTest[7]) + "\n"); |
145 | 171 |
|
146 | 172 | Files.write(Path.of("results", "thesis_es", "resultOfAnalysis.txt"), result); |
147 | | - int c = 1; |
148 | | - for (String line : errorList) { |
149 | | - Files.writeString(Path.of("results", "thesis_es", "errors", c + "error.txt"), line); |
150 | | - c = c + 1; |
151 | | - } |
152 | 173 |
|
153 | 174 | } |
154 | 175 |
|
| 176 | + private static String parseNumberStringToIntWithLengthGreaterOne(String string) { |
| 177 | + string = string.trim(); |
| 178 | + for (char c : string.toCharArray()) { |
| 179 | + if (Character.isDigit(c)) { |
| 180 | + return Character.toString(c); |
| 181 | + } |
| 182 | + } |
| 183 | + return ""; |
| 184 | + } |
155 | 185 | } |
0 commit comments