Method: WordNet::Synset#|

Defined in:
lib/wordnet/synset.rb

#|(othersyn) ⇒ Object

Union: Return the least general synset that the receiver and othersyn have in common as a hypernym, or nil if it doesn’t share any.



583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
# File 'lib/wordnet/synset.rb', line 583

def |( othersyn )

  # Find all of this syn's hypernyms
  hypersyns = self.traverse( :hypernyms ).to_a
  commonsyn = nil

  # Now traverse the other synset's hypernyms looking for one of our
  # own hypernyms.
  othersyn.traverse( :hypernyms ) do |syn|
    if hypersyns.include?( syn )
      commonsyn = syn
      throw :stop_traversal
    end
  end

  return commonsyn
end