def smush(pred)
identifying_hash = {}
canonical = {}
mapme = []
transactions = []
self.find(nil,pred,nil){|sub,pred,obj|
if not identifying_hash.has_key?(obj.to_s)
identifying_hash[obj.to_s] = sub
elsif identifying_hash[obj.to_s] != sub
subject_string = sub.to_s
if not canonical.has_key?(subject_string)
canonical[subject_string] = identifying_hash[obj.to_s]
mapme << Node.new(sub)
end
end
}
self.triples(){ |sub,pred,obj|
ss = sub.to_s
os = obj.to_s
new_statement = nil
replace = false
if canonical.has_key?(ss)
if not replace
new_statement = Statement.new(sub,pred,obj)
replace = 1
end
new_statement.subject = canonical[ss]
end
if canonical.has_key?(os)
if not replace
new_statement = Statement.new(sub,pred,obj)
replace = 1
new_statement.object = canonical[os]
end
end
if replace
transactions << [Statement.new(sub,pred,obj),new_statement]
end
}
transactions.each{ |pair|
self.delete_statement(pair[0])
self.add_statement(pair[1])
}
end