Skip to content

Commit cd26dbc

Browse files
committed
Refactor ARFF dataset preparation
1 parent 6c60497 commit cd26dbc

File tree

2 files changed

+7
-18
lines changed

2 files changed

+7
-18
lines changed

swan-cmd/src/main/java/de/fraunhofer/iem/swan/cli/SwanCli.java

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -44,27 +44,13 @@ public Integer run(SwanOptions options) throws Exception {
4444

4545
List<String> instances = new ArrayList<>();
4646

47-
String toolkit = "";
48-
49-
switch (ModelEvaluator.Toolkit.valueOf(options.getToolkit().toUpperCase())) {
50-
51-
case MEKA:
52-
case ML2PLAN:
53-
toolkit = "meka";
54-
break;
55-
case WEKA:
56-
toolkit = options.getToolkit();
57-
break;
58-
}
59-
6047
for (String feature : options.getFeatureSet()) {
6148

62-
String filepath = File.separator + "dataset" + File.separator + toolkit
49+
String filepath = File.separator + "dataset" + File.separator + options.getToolkit().toLowerCase()
6350
+ File.separator;
6451

65-
if (toolkit.contentEquals("meka")) {
66-
67-
instances.add(fileUtility.getResourceFile(filepath + toolkit + "-" + feature + ".arff",
52+
if (options.getToolkit().toLowerCase().contentEquals("meka")) {
53+
instances.add(fileUtility.getResourceFile(filepath + options.getToolkit().toLowerCase() + "-" + feature + ".arff",
6854
null).getAbsolutePath());
6955
} else {
7056
for (String srm : options.getAllClasses()) {

swan-cmd/src/main/java/de/fraunhofer/iem/swan/util/Util.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,11 @@ public static String buildCP(String[] dirs) {
143143

144144
File folder = new File(dir);
145145

146+
if (dir.isEmpty() || !folder.exists() || !Files.isDirectory(folder.toPath()))
147+
continue;
148+
146149
//If folder contains .class files, add path to classpath
147-
if (FileUtils.listFiles(folder, new String[]{"class"}, true).size() > 0)
150+
if (!FileUtils.listFiles(folder, new String[]{"class"}, true).isEmpty())
148151
paths.add(dir);
149152
else {
150153
for (File file : FileUtils.listFiles(folder, new String[]{"jar", "apk"}, true)) {

0 commit comments

Comments
 (0)