Sha256: 9f1836b4e46df444e83dba486388460728e6a9c02fbc155601344106b97fb8ed
Contents?: true
Size: 898 Bytes
Versions: 17
Compression:
Stored size: 898 Bytes
Contents
class Qa::MeshTree < ActiveRecord::Base belongs_to :subject_mesh_term , :foreign_key => "term_id" def self.classify_all_trees MeshTreeStructure.find_each do |mts| mts.classify_tree! end end def eval_tree_path trees = read_attribute(:eval_tree_path) || write_attribute(:eval_tree_path, "") if trees trees.split("|") else [] end end def classify_tree tree_levels = initial_segements_of(tree_structure) tree_levels.map &method(:lookup_tree_term) end def classify_tree! unless classify_tree.empty? tree_path = classify_tree.join('|') puts "After Join #{tree_path.inspect}" update_attribute(:eval_tree_path, tree_path) end end # given a tree id, return the main subject term # e.g. 'C03.752.530' returns 'Malaria' def lookup_tree_term(tree_id) self.class.get_term(tree_id).first.term end end
Version data entries
17 entries across 17 versions & 1 rubygems