diff options
author | mguetlein <martin.guetlein@gmail.com> | 2010-08-11 08:46:45 +0200 |
---|---|---|
committer | mguetlein <martin.guetlein@gmail.com> | 2010-08-11 08:46:45 +0200 |
commit | 2806bfff8a01f75351f31c5bd676b25b2fb36017 (patch) | |
tree | 4399d62868335449ba2a4a1af6cb554ecffb458b | |
parent | abe51eed641a8cb3532eb7f7c4addfadeb77eb0f (diff) |
add generic algorithm object
-rw-r--r-- | lib/algorithm.rb | 19 | ||||
-rw-r--r-- | lib/model.rb | 5 | ||||
-rw-r--r-- | lib/owl.rb | 4 |
3 files changed, 23 insertions, 5 deletions
diff --git a/lib/algorithm.rb b/lib/algorithm.rb index cc06032..30a41e0 100644 --- a/lib/algorithm.rb +++ b/lib/algorithm.rb @@ -2,6 +2,25 @@ LOGGER.progname = File.expand_path(__FILE__) module OpenTox module Algorithm + + + class Generic + + attr_accessor :uri, :title, :date + + def self.find(uri) + owl = OpenTox::Owl.from_uri(uri, "Algorithm") + return self.new(owl) + end + + protected + def initialize(owl) + @title = owl.get("title") + @date = owl.get("date") + @uri = owl.uri + end + + end class Fminer diff --git a/lib/model.rb b/lib/model.rb index b6cef46..25266e3 100644 --- a/lib/model.rb +++ b/lib/model.rb @@ -21,9 +21,8 @@ module OpenTox protected def initialize(owl) - [:date, :creator, :title, :format, :algorithm, :dependentVariables, - :independentVariables, :predictedVariables, :trainingDataset].each do |a| - self.send("#{a.to_s}=".to_sym, owl.get(a.to_s)) + MODEL_ATTRIBS.each do |a| + self.send("#{a.to_s}=".to_sym, owl.get(a.to_s)) unless a==:uri end @uri = owl.uri if ENV['RACK_ENV'] =~ /test|debug/ @@ -233,7 +233,7 @@ module OpenTox unless owl.root_node types = [] owl.model.find(nil, RDF_TYPE, nil){ |s,p,o| types << o.to_s } - raise "root node for class '"+ot_class+"' not found (available type nodes: "+types.inspect+")" + raise "root node for class '"+owl.node(ot_class).to_s+"' not found (available type nodes: "+types.inspect+")" end raise "no uri in rdf: '"+owl.uri+"'" unless owl.uri and Utils.is_uri?(owl.uri) owl.ot_class = ot_class @@ -244,7 +244,7 @@ module OpenTox end def self.from_uri(uri, ot_class) - return from_data(RestClientWrapper.get(uri,:accept => "application/rdf+xml").to_s, uri, ot_class) + return from_data(RestClientWrapper.get(uri,:accept => "application/rdf+xml").to_s, uri, ot_class) end def rdf |