Skip to content

Commit 9745035

Browse files
committed
Refactor ARFF files loading from file system
1 parent 8ad3db8 commit 9745035

File tree

1 file changed

+19
-11
lines changed
  • swan-cmd/src/main/java/de/fraunhofer/iem/swan/cli

1 file changed

+19
-11
lines changed

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

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -44,28 +44,34 @@ public Integer run(SwanOptions options) throws Exception {
4444

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

47-
String dataset = "";
47+
String toolkit = "";
4848

4949
switch (ModelEvaluator.Toolkit.valueOf(options.getToolkit().toUpperCase())) {
5050

5151
case MEKA:
5252
case ML2PLAN:
53-
dataset = "meka";
53+
toolkit = "meka";
5454
break;
5555
case WEKA:
56-
dataset = options.getToolkit();
56+
toolkit = options.getToolkit();
5757
break;
5858
}
5959

6060
for (String feature : options.getFeatureSet()) {
61-
String filepath = File.separator + "dataset" + File.separator + dataset
62-
+ File.separator + feature + File.separator;
6361

64-
ArrayList<String> files = new ArrayList<>();
65-
for (File f : Objects.requireNonNull(fileUtility.getResourceDirectory(filepath).listFiles())) {
66-
files.add(f.getAbsolutePath());
62+
String filepath = File.separator + "dataset" + File.separator + toolkit
63+
+ File.separator;
64+
65+
if (toolkit.contentEquals("meka")) {
66+
67+
instances.add(fileUtility.getResourceFile(filepath + toolkit + "-" + feature + ".arff",
68+
null).getAbsolutePath());
69+
} else {
70+
for (String srm : options.getAllClasses()) {
71+
instances.add(fileUtility.getResourceFile(filepath + feature + File.separator + srm + ".arff",
72+
null).getAbsolutePath());
73+
}
6774
}
68-
instances.addAll(files);
6975
}
7076
options.setInstances(instances);
7177
}
@@ -77,10 +83,12 @@ public Integer run(SwanOptions options) throws Exception {
7783
swanPipeline.run();
7884

7985
return 0;
80-
} catch (CancellationException e) {
86+
} catch (
87+
CancellationException e) {
8188
logger.warn("Analysis run was cancelled");
8289
return 66;
83-
} catch (Exception e) {
90+
} catch (
91+
Exception e) {
8492
logger.error("Analysis run terminated with error", e);
8593
return 500;
8694
} finally {

0 commit comments

Comments
 (0)