Last change
on this file since 5 was
4,
checked in by sherbold, 10 years ago
|
|
-
Property svn:mime-type set to
text/plain
|
File size:
1.1 KB
|
Line | |
---|
1 | package de.ugoe.cs.cpdp.loader;
|
---|
2 |
|
---|
3 | import java.io.BufferedReader;
|
---|
4 | import java.io.File;
|
---|
5 | import java.io.FileReader;
|
---|
6 | import java.io.IOException;
|
---|
7 |
|
---|
8 | import weka.core.Instances;
|
---|
9 |
|
---|
10 | /**
|
---|
11 | * Loads ARFF files and chooses the last attribute as class attribute.
|
---|
12 | *
|
---|
13 | * @author Steffen Herbold
|
---|
14 | */
|
---|
15 | public class ARFFLoader implements SingleVersionLoader {
|
---|
16 |
|
---|
17 | /*
|
---|
18 | * (non-Javadoc)
|
---|
19 | *
|
---|
20 | * @see de.ugoe.cs.cpdp.loader.SingleVersionLoader#load(java.io.File)
|
---|
21 | */
|
---|
22 | @Override
|
---|
23 | public Instances load(File file) {
|
---|
24 | BufferedReader reader;
|
---|
25 | Instances data;
|
---|
26 | try {
|
---|
27 | reader = new BufferedReader(new FileReader(file));
|
---|
28 | data = new Instances(reader);
|
---|
29 | reader.close();
|
---|
30 | } catch (IOException e) {
|
---|
31 | // TODO Auto-generated catch block
|
---|
32 | throw new RuntimeException(e);
|
---|
33 | }
|
---|
34 |
|
---|
35 | // setting class attribute
|
---|
36 | data.setClassIndex(data.numAttributes() - 1);
|
---|
37 |
|
---|
38 | return data;
|
---|
39 | }
|
---|
40 |
|
---|
41 | /*
|
---|
42 | * (non-Javadoc)
|
---|
43 | *
|
---|
44 | * @see
|
---|
45 | * de.ugoe.cs.cpdp.loader.SingleVersionLoader#filenameFilter(java.lang.String
|
---|
46 | * )
|
---|
47 | */
|
---|
48 | @Override
|
---|
49 | public boolean filenameFilter(String filename) {
|
---|
50 | return filename.endsWith(".arff");
|
---|
51 | }
|
---|
52 |
|
---|
53 | }
|
---|
Note: See
TracBrowser
for help on using the repository browser.