-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExamples.java
More file actions
59 lines (51 loc) · 1.28 KB
/
Copy pathExamples.java
File metadata and controls
59 lines (51 loc) · 1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import java.util.Scanner;
public class Examples extends java.util.ArrayList<Example>{
private Attributes attributeset = new Attributes();
Examples(Attributes attributes)
{
attributeset = attributes;
}
Examples(Attributes attributes, Scanner scan)
{
Double attributeindex;
this.attributeset = attributes;
scan.useDelimiter("\n");
while(scan.hasNext())
{
Example ex = new Example();
String forparse = scan.next();
//System.out.println(forparse);
String parse[]=forparse.split(" ");
for(int k=0;k<parse.length;k++)
{
//System.out.print(parse[k]+"."); //
attributeindex=attributeset.get(k).getIndex(parse[k]);
ex.add(attributeindex);
//System.out.println(attributeindex); // value's index
}
//
//System.out.println(ex);
this.add(ex);
}
}
public String toString()
{
String output="@examples \n\n";
for( int i=0;i<this.size();i++ )
{
for(int j=0;j<this.attributeset.getSize();j++)
{
if(this.attributeset.get(j).whatAttribute()=="Numeric")
output+=this.get(i).get(j).toString()+" ";
else
{
Double temp=this.get(i).get(j);
int index = temp.intValue();
output+=this.attributeset.get(j).getValue(index)+" ";
}
}
output+="\n";
}
return output;
}
}