Method: WordNet::Synset#expanded_hypernyms
- Defined in:
- lib/rwordnet/synset.rb
#expanded_hypernyms ⇒ Object
Get the entire hypernym tree (from this synset all the way up to entity) as an array.
229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 |
# File 'lib/rwordnet/synset.rb', line 229 def parents = hypernyms list = [] return list unless parents while parents.length > 0 parent = parents.pop next if list.include? parent.pos_offset list.push parent.pos_offset parents.push *parent.hypernyms end list.flatten! list.map! { |offset| Synset.new(@pos, offset)} end |