Class: OpenTox::Feature
Instance Attribute Summary collapse
-
#subjectid ⇒ Object
Returns the value of attribute subjectid.
Attributes included from OpenTox
Class Method Summary collapse
-
.find(uri, subjectid = nil) ⇒ OpenTox::Task
Find a feature.
Instance Method Summary collapse
-
#feature_type ⇒ String
provides feature type, possible types are “regression” or “classification”.
Methods included from OpenTox
#add_metadata, all, #delete, #initialize, #load_metadata, sign_in, text_to_html, #to_rdfxml
Instance Attribute Details
#subjectid ⇒ Object
Returns the value of attribute subjectid.
5 6 7 |
# File 'lib/feature.rb', line 5 def subjectid @subjectid end |
Class Method Details
.find(uri, subjectid = nil) ⇒ OpenTox::Task
Find a feature
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/feature.rb', line 10 def self.find(uri, subjectid=nil) return nil unless uri feature = Feature.new uri if (CONFIG[:json_hosts].include?(URI.parse(uri).host)) feature. YAML.load(RestClientWrapper.get(uri,{:accept => "application/x-yaml", :subjectid => subjectid})) else feature. Parser::Owl::Dataset.new(uri). end feature.subjectid = subjectid feature end |
Instance Method Details
#feature_type ⇒ String
provides feature type, possible types are “regression” or “classification”
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/feature.rb', line 24 def feature_type raise OpenTox::BadRequestError.new("rdf type of feature '"+uri.to_s+"' not set") unless [RDF.type] if [RDF.type].to_a.flatten.include?(OT.NominalFeature) "classification" elsif [RDF.type].to_a.flatten.include?(OT.NumericFeature) "regression" elsif [OWL.sameAs] [OWL.sameAs].each do |f| begin type = Feature.find(f, subjectid).feature_type return type unless type=="unknown" rescue => ex LOGGER.warn "could not load same-as-feature '"+f.to_s+"' for feature '"+uri.to_s+"' : "+ex..to_s end end "unknown" else "unknown" end end |