/** * @param synset * @param synsetNo * @param baseLemma * @param isNotCrossed * @param targetSenseNum * @return * @throws LexicalResourceException */ private Set<LexicalRule<WordnetRuleInfo>> getSynonymRules( Synset synset, int synsetNo, String baseLemma, boolean isNotCrossed, int targetSenseNum) throws LexicalResourceException { Set<LexicalRule<WordnetRuleInfo>> rules = new LinkedHashSet<LexicalRule<WordnetRuleInfo>>(); try { for (String lemma : synset.getWords()) if (!lemma.equalsIgnoreCase( baseLemma)) // filter out the one rule from the baseLemma to itself { boolean addThisRule = true; if (targetSenseNum != -1) { addThisRule = isCorrectSenseOfGivenWord(synset, lemma, synset.getPartOfSpeech(), targetSenseNum); } if (addThisRule) { BySimplerCanonicalPartOfSpeech pos = synset.getPartOfSpeech().toPartOfSpeech(); rules.add( newDirectedRule( lemma, pos, baseLemma, pos, SYNONYM, synset, synset, synsetNo, isNotCrossed)); } } } catch (WordNetException e) { throw new LexicalResourceException("wordnet error, see nested", e); } return rules; }