hexwrench 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README +22 -0
- data/TODO +11 -4
- data/lib/hexwrench.rb +1 -1
- data/lib/hexwrench/weka/explorer.rb +22 -7
- metadata +4 -4
data/README
CHANGED
@@ -7,6 +7,28 @@ by using the Weka wrapper, you agree to use Weka and HexWrench in a GNU GPL comp
|
|
7
7
|
HexWrench comes with a Weka layer, which goal is to turn Welo::Resources in
|
8
8
|
weka.core.Instances.
|
9
9
|
|
10
|
+
=== Requirements
|
11
|
+
|
10
12
|
To use it, you need:
|
11
13
|
- JRuby
|
12
14
|
- A recent Weka JAR on your $LOAD_PATH
|
15
|
+
|
16
|
+
=== Usage
|
17
|
+
|
18
|
+
See example/extended.jar to have a usage sample.
|
19
|
+
|
20
|
+
=== Important
|
21
|
+
Weka supports "related" relationships.
|
22
|
+
Current HexWrench implementation partially works:
|
23
|
+
- it works as expected for one level of relationship
|
24
|
+
- in the case of 2nd and more levels of relationship,
|
25
|
+
it will create a new header (i.e., Attribute from Instances)
|
26
|
+
per related object. Although this might be the expected behaviour in some
|
27
|
+
cases, it is not the "least-surprise" behaviour, future versions may change
|
28
|
+
this
|
29
|
+
- it breaks when there are "loops" in the relationship graph
|
30
|
+
As a conclusion, DO NOT use more than one level of relationships unless you know
|
31
|
+
Weka very well and had a look at the source.
|
32
|
+
|
33
|
+
== R
|
34
|
+
Upcoming.
|
data/TODO
CHANGED
@@ -1,6 +1,13 @@
|
|
1
|
-
* related feature:
|
2
1
|
* explorer:
|
3
|
-
- rename
|
2
|
+
- rename to something more correct
|
4
3
|
* weka-explorer:
|
5
|
-
-
|
6
|
-
-
|
4
|
+
- get sizes of relationships
|
5
|
+
- when there are more than one relationship pointing to one kind of resources,
|
6
|
+
an header for each of them is created, not sure it's what we want, example:
|
7
|
+
class Foo
|
8
|
+
relationship :bar_1, :Bar, ...
|
9
|
+
relationship :bar_2, :Bar, ...
|
10
|
+
relationship :foo, :Foo, ... #similar for looping relationships
|
11
|
+
end
|
12
|
+
- when following relationships recursively, there may be loops in the relationships graphs,
|
13
|
+
we do not check this, not sure if it feasible in an efficient, general purpose, way
|
data/lib/hexwrench.rb
CHANGED
@@ -97,11 +97,11 @@ module HexWrench
|
|
97
97
|
end
|
98
98
|
|
99
99
|
def create_instances
|
100
|
-
|
100
|
+
Weka::Instances.new(relation_name, fast_vector, resources_cnt)
|
101
101
|
end
|
102
102
|
|
103
|
-
def
|
104
|
-
|
103
|
+
def values_for_resources(resource)
|
104
|
+
features.map do |feat|
|
105
105
|
rb_val = resource.send(feat.sym)
|
106
106
|
attribute = attribute(feat.sym)
|
107
107
|
val = case feat
|
@@ -118,23 +118,38 @@ module HexWrench
|
|
118
118
|
when StringFeature
|
119
119
|
attribute.addStringValue(rb_val.to_java)
|
120
120
|
when RelationFeature
|
121
|
-
header = header(feat.sym)
|
121
|
+
header = header(feat.sym)
|
122
122
|
raise NotImplementedError, "no header built for #{feat} yet" unless header
|
123
|
+
data_instances = Weka::Instances.new(attribute.relation, 0)
|
123
124
|
if feat.relationship.many?
|
124
125
|
rb_val.each do |rb_val_|
|
125
|
-
header.
|
126
|
+
header.add_resource_to_instances(rb_val_, data_instances)
|
126
127
|
end
|
127
128
|
else
|
128
|
-
header.
|
129
|
+
header.add_resource_to_instances(rb_val, data_instances)
|
129
130
|
end
|
130
|
-
attribute.addRelation(
|
131
|
+
attribute.addRelation(data_instances)
|
131
132
|
else
|
132
133
|
rb_val
|
133
134
|
end
|
134
135
|
val
|
135
136
|
end
|
137
|
+
end
|
138
|
+
|
139
|
+
def new_data_instances
|
140
|
+
end
|
141
|
+
|
142
|
+
def add_values_to_instances(values, instances)
|
136
143
|
instances.add(Weka::Instance.new(1.0, values.to_java(Java::double)))
|
137
144
|
end
|
145
|
+
|
146
|
+
def add_resource_to_instances(resource, instances)
|
147
|
+
add_values_to_instances(values_for_resources(resource), instances)
|
148
|
+
end
|
149
|
+
|
150
|
+
def add_resource(resource)
|
151
|
+
add_resource_to_instances(resource, instances)
|
152
|
+
end
|
138
153
|
end
|
139
154
|
|
140
155
|
attr_reader :headers
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hexwrench
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 27
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 2
|
10
|
+
version: 0.0.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- crapooze
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-02-
|
18
|
+
date: 2011-02-25 00:00:00 +01:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|