/** * Looks whether the target word is one of the words in one of the synsets * of the source word. * * @param sourceWord source word * @param targetWord target word * @return int the sense of the source word that contains the target word */ public static int getImmediateRelationship(IndexWord sourceWord, IndexWord targetWord) { List<Synset> senses = sourceWord.getSenses(); String lemma = targetWord.getLemma(); for (int i = 0; i < senses.size(); i++) { if (senses.get(i).containsWord(lemma)) { return i + 1; } } return -1; }
/** * Looks whether the target word is one of the words in one of the synsets * of the source word. * * @param sourceWord source word * @param targetWord target word * @return int the sense of the source word that contains the target word */ public static int getImmediateRelationship(IndexWord sourceWord, IndexWord targetWord) { List<Synset> senses = sourceWord.getSenses(); String lemma = targetWord.getLemma(); for (int i = 0; i < senses.size(); i++) { if (senses.get(i).containsWord(lemma)) { return i + 1; } } return -1; }
private void addWord(Synset synset, String lemma) { if (null != synset.getDictionary() && synset.getDictionary().isEditable()) { if (!synset.containsWord(lemma)) { synset.getWords().add(new Word(synset.getDictionary(), synset, lemma)); } } }
private void addWord(Synset synset, String lemma) { if (null != synset.getDictionary() && synset.getDictionary().isEditable()) { if (!synset.containsWord(lemma)) { synset.getWords().add(new Word(synset.getDictionary(), synset, lemma)); } } }