source: trunk/CrossPare/decent/epsilon/libraries/arff/common.eol @ 135

Last change on this file since 135 was 32, checked in by ftrautsch, 10 years ago

integrating decent into crosspare

File size: 1.3 KB
RevLine 
[32]1operation ARFFx!Instance addValue(content : String, attribute : String) {
2        var value = new ARFFx!Value();
3        value.ofAttribute = attribute.getARFFAttribute(self.eContainer());
4        value.content = content;
5        self.values.add(value);         
6}
7
8
9operation ARFFx!Instance updateValue(content : String, attribute : String) {
10        var value = self.values.select(v|v.ofAttribute.name = attribute).first();
11        if (value.isUndefined()) {
12                value = new ARFFx!Value();
13                value.ofAttribute = attribute.getARFFAttribute(self.eContainer());
14                self.values.add(value);         
15        }
16        value.content = content;
17}
18
19
20@cached
21operation String getARFFAttribute(arffx : ARFFx!Model) : ARFFx!Attribute {
22        var attribute = arffx.attributes.select(a|a.name = self).first();
23        if (attribute.isUndefined()) {
24                attribute = new ARFFx!Attribute();
25                attribute.name = self;
26                arffx.attributes.add(attribute);
27        }
28        return attribute;
29}
30
31operation String getSelectedAttributes() : Sequence {
32        var file = new Native("java.io.File")(self);
33        var content = new Native("org.apache.commons.io.FileUtils").readLines(file);
34       
35       
36        content = content.select(x|not x.startsWith("#")).closure(x|x.trim());
37        return content;
38}
39
40@cached
41operation ARFFx!Instance getValue(attribute : ARFFx!Attribute) : String {
42        return self.values.select(v|v.ofAttribute = attribute).first().content;
43}
Note: See TracBrowser for help on using the repository browser.