245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
|
# File 'lib/rwordnet/synset.rb', line 245
def expanded_hypernyms_depth
parents = hypernyms.map{|hypernym| [hypernym, 1]}
list = []
out = []
return list unless parents
max_depth = 1
while parents.length > 0
parent, depth = parents.pop
next if list.include? parent.pos_offset
list.push parent.pos_offset
out.push [Synset.new(@pos, parent.pos_offset), depth]
parents.push *(parent.hypernyms.map{|hypernym| [hypernym, depth + 1]})
max_depth = [max_depth, depth].max
end
return [out, max_depth]
end
|