/**
  * If relation is lexical, return the {@link SensedWord}s that are directly related to the given
  * <lemma, synset>. If relation is semantic, return a {@link SensedWord} for each word in the
  * synsets related to the given synset, within #chainingLength steps away.
  *
  * @param lemma
  * @param synset
  * @param relation
  * @param chainingLength is the size of transitive relation chaining to be performed on the
  *     retrieved rules. E.g. if chainingLength = 3, then every hypernym/hyponym, merornym and
  *     holonym query will return rules with words related up to the 3rd degree (that's 1st, 2nd or
  *     3rd) from the original term. Queries on non transitive relations are unaffected by this
  *     parameter. Must be positive.
  * @return
  * @throws WordNetException
  */
 private Set<SensedWord> getSemanticOrLexicalNeighborSensedWords(
     String lemma, Synset synset, WordNetRelation relation, int chainingLength)
     throws WordNetException {
   Set<SensedWord> relatedSensedWords;
   if (relation.isLexical()) {
     SensedWord sensedWord = dictionary.getSensedWord(lemma, synset);
     relatedSensedWords = sensedWord.getNeighborSensedWords(relation);
   } else {
     relatedSensedWords = new LinkedHashSet<SensedWord>();
     Set<Synset> relatedSynsets =
         synset.getRelatedSynsets(relation, chainingLength); // getNeighbors(relation);
     for (Synset relatedSynset : relatedSynsets)
       relatedSensedWords.addAll(relatedSynset.getAllSensedWords());
   }
   return relatedSensedWords;
 }