Changeset 457
 Timestamp:
 06/18/09 12:24:03 (9 years ago)
 Files:

 1 modified
Legend:
 Unmodified
 Added
 Removed

Explorator/trunk/app/controllers/facets_controller.rb
r406 r457 189 189 #verifies if the facet is a derived type. 190 190 if computedValue.size() == 0 191 191 192 if facet.faceto::use != nil 192 193 #get the values based in the property 193 194 # qresult = QueryFactory.new.distinct(:o).where(resource, facet.faceto::use,:o).execute 194 puts facet.faceto::use.localname 195 puts facet.faceto::use 196 qresult = resource.instance_eval(facet.faceto::use.localname) 197 195 # puts facet.faceto::use.localname 196 # puts facet.faceto::use 197 qresult = resource.instance_eval(facet.faceto::use.localname) 198 198 elsif facet.faceto::useInverse != nil 199 199 puts facet.faceto::use.localname … … 210 210 end 211 211 puts qresult 212 212 puts '2 ' 213 213 #property :p occurs em :s 214 214 if qresult.size > 0 215 215 prob_p += 1 216 216 end 217 217 218 #frequence that :o occurs for each :s 218 219 qresult.each do o … … 243 244 244 245 next if condition.first == 1 && condition.last ==1 246 puts hash_object 245 247 hash_object.each_key do object 246 248 count= hash_object[object] … … 254 256 # puts prob_o 255 257 if prob_o !=1 256 objects << object 257 258 objects << object 258 259 #calculate the entropy based on the object probability 259 260 entropy = entropy + prob_o * Math.log(prob_o) / Math.log( 2 ) 260 261 end 261 262 end 263 262 264 #calculates the objects' cardinality 265 263 266 if entropy != 0 264 267 cardinalities = Array.new … … 284 287 end 285 288 @entropies = @entropies.to_a 286 #sort the facets by property occurency and by maximum entropy289 #sort the facets by property occurency and by maximum entropy 287 290 @entropies.sort! do a, b 288 291 r = b[1][0]<=>a[1][0]