/** * 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 writeObject(java.io.ObjectOutputStream oos) throws IOException { boolean synsetOffsetsNull = (null == synsetOffsets); synsetOffsets = getSynsetOffsets(); oos.defaultWriteObject(); if (synsetOffsetsNull) { synsetOffsets = null; } } }
protected List<Synset> indexWordToList(IndexWord indexWord) throws JWNLException { List<Synset> ret = null; if (indexWord!=null) { if (indexWord.getSenses()!=null) { ret = new ArrayList<Synset>(indexWord.getSenses().size()); for (net.sf.extjwnl.data.Synset jwnlRealSynset : indexWord.getSenses()) { ret.add(new ExtJwnlSynset(this, jwnlRealSynset)); } } } if (null==ret) ret = new ArrayList<Synset>(); return ret; }
private void renderIndexWord(IndexWord indexWord, StringBuilder result) { ArrayList<PointerType> pointerTypes = new ArrayList<>(); for (Synset synset : indexWord.getSenses()) { for (Pointer pointer : synset.getPointers()) { if ((pointer.getSource() instanceof Word) && !indexWord.getLemma().equals(((Word) pointer.getSource()).getLemma().toLowerCase())) { continue; int tagSenseCnt = indexWord.sortSenses(); result.append(indexWord.getLemma().replace(' ', '_')); result.append(' '); result.append(indexWord.getPOS().getKey()).append(' '); // pos result.append(indexWord.getSenses().size()).append(' '); // synset_cnt result.append(pointerTypes.size()).append(' '); // p_cnt for (PointerType pointerType : pointerTypes) { result.append(indexWord.getSenses().size()).append(' '); // sense_cnt for (Synset synset : indexWord.getSenses()) { formatOffset(synset.getOffset(), offsetLength, result); result.append(' '); // synset_offset
System.out.println("\nNo information available for " + pos.getLabel() + " " + key); } else { System.out.println("\nInformation available for " + iw.getPOS().getLabel() + " " + iw.getLemma()); printAvailableInfo(iw); iw = d.getIndexWord(pos, form); if (null != iw) { System.out.println("\nInformation available for " + iw.getPOS().getLabel() + " " + iw.getLemma()); printAvailableInfo(iw); final IndexWord iw = d.lookupIndexWord(p, key); if (iw != null) { System.out.println("\nAntonyms of " + (p == null ? "" : p.getLabel()) + " " + iw.getLemma()); tracePointers(iw, PointerType.ANTONYM, 1, needSense, needGloss, needLex, needOffset, needSenseNum, needSenseKeys); final IndexWord iw = d.lookupIndexWord(p, key); if (null != iw) { System.out.println("\nHypernyms of " + (p == null ? "" : p.getLabel()) + " " + iw.getLemma()); tracePointers(iw, PointerType.HYPERNYM, PointerUtils.INFINITY, needSense, needGloss, needLex, needOffset, needSenseNum, needSenseKeys); final IndexWord iw = d.lookupIndexWord(p, key); if (null != iw) { System.out.println("\nHyponyms of " + (p == null ? "" : p.getLabel()) + " " + iw.getLemma()); tracePointers(iw, PointerType.HYPONYM, 1, needSense, needGloss, needLex, needOffset, needSenseNum, needSenseKeys); final IndexWord iw = d.lookupIndexWord(p, key); if (null != iw) { System.out.println("\nHyponyms of " + (p == null ? "" : p.getLabel()) + " " + iw.getLemma()); tracePointers(iw, PointerType.HYPONYM, PointerUtils.INFINITY, needSense, needGloss, needLex, needOffset, needSenseNum, needSenseKeys);
/** * Removes <var>indexWord</var> from the dictionary. * * @param indexWord index word to remove * @throws JWNLException JWNLException */ public synchronized void removeIndexWord(IndexWord indexWord) throws JWNLException { checkEditable(); indexWord.setDictionary(null); // take care of words in synsets List<Synset> copy = new ArrayList<>(indexWord.getSenses()); for (Synset synset : copy) { List<Word> wordsCopy = new ArrayList<>(synset.getWords()); for (Word word : wordsCopy) { if (word.getLemma().equalsIgnoreCase(indexWord.getLemma())) { synset.getWords().remove(word); break; } } } }
int result = 0; if (1 < getSenses().size()) { List<Synset> ucSenses = new ArrayList<>(getSenses().size()); List<Synset> nonUCSenses = new ArrayList<>(getSenses().size()); for (Synset synset : getSenses()) { if (0 < getUseCount(synset, lemma)) { ucSenses.add(synset); } else { ucSenses.sort(Collections.reverseOrder(Comparator.comparingInt(o -> getUseCount(o, lemma)))); if (POS.ADJECTIVE == getPOS()) { int i = 0; while (i < nonUCSenses.size()) { } else if (1 == getSenses().size()) { if (0 < getUseCount(getSenses().get(0), lemma)) { result = 1;
public IndexWord next() { if (hasNext()) { IndexWord thisWord = startWord; startWord = null; while (itr.hasNext()) { IndexWord word = itr.next(); if (word.getLemma().contains(searchString)) { startWord = word; break; } } return thisWord; } else { throw new NoSuchElementException(); } }
int id = nextId(); iwStmt.setInt(1, id); iwStmt.setString(2, iw.getLemma()); iwStmt.setString(3, iw.getPOS().getKey()); iwStmt.addBatch(); idToSynsetOffset.put(id, iw.getSynsetOffsets());
/** * Adds an IndexWord to this set. * * @param word word to add */ public void add(IndexWord word) { indexWords.put(word.getPOS(), word); }
public IndexWord createIndexWord(POS pos, String lemma, Synset synset) throws JWNLException { return new IndexWord(dictionary, lemma, pos, synset); }
protected Set<Synset> indexWordToSet(IndexWord indexWord) throws JWNLException { Set<Synset> ret = new LinkedHashSet<Synset>(); if (indexWord!=null) { for (net.sf.extjwnl.data.Synset jwnlRealSynset : indexWord.getSenses()) { ret.add(new ExtJwnlSynset(this, jwnlRealSynset)); } } return ret; }
private void renderIndexWord(IndexWord indexWord, StringBuilder result) { ArrayList<PointerType> pointerTypes = new ArrayList<>(); for (Synset synset : indexWord.getSenses()) { for (Pointer pointer : synset.getPointers()) { if ((pointer.getSource() instanceof Word) && !indexWord.getLemma().equals(((Word) pointer.getSource()).getLemma().toLowerCase())) { continue; int tagSenseCnt = indexWord.sortSenses(); result.append(indexWord.getLemma().replace(' ', '_')); result.append(' '); result.append(indexWord.getPOS().getKey()).append(' '); // pos result.append(indexWord.getSenses().size()).append(' '); // synset_cnt result.append(pointerTypes.size()).append(' '); // p_cnt for (PointerType pointerType : pointerTypes) { result.append(indexWord.getSenses().size()).append(' '); // sense_cnt for (Synset synset : indexWord.getSenses()) { formatOffset(synset.getOffset(), offsetLength, result); result.append(' '); // synset_offset
System.out.println("\nNo information available for " + pos.getLabel() + " " + key); } else { System.out.println("\nInformation available for " + iw.getPOS().getLabel() + " " + iw.getLemma()); printAvailableInfo(iw); iw = d.getIndexWord(pos, form); if (null != iw) { System.out.println("\nInformation available for " + iw.getPOS().getLabel() + " " + iw.getLemma()); printAvailableInfo(iw); final IndexWord iw = d.lookupIndexWord(p, key); if (iw != null) { System.out.println("\nAntonyms of " + (p == null ? "" : p.getLabel()) + " " + iw.getLemma()); tracePointers(iw, PointerType.ANTONYM, 1, needSense, needGloss, needLex, needOffset, needSenseNum, needSenseKeys); final IndexWord iw = d.lookupIndexWord(p, key); if (null != iw) { System.out.println("\nHypernyms of " + (p == null ? "" : p.getLabel()) + " " + iw.getLemma()); tracePointers(iw, PointerType.HYPERNYM, PointerUtils.INFINITY, needSense, needGloss, needLex, needOffset, needSenseNum, needSenseKeys); final IndexWord iw = d.lookupIndexWord(p, key); if (null != iw) { System.out.println("\nHyponyms of " + (p == null ? "" : p.getLabel()) + " " + iw.getLemma()); tracePointers(iw, PointerType.HYPONYM, 1, needSense, needGloss, needLex, needOffset, needSenseNum, needSenseKeys); final IndexWord iw = d.lookupIndexWord(p, key); if (null != iw) { System.out.println("\nHyponyms of " + (p == null ? "" : p.getLabel()) + " " + iw.getLemma()); tracePointers(iw, PointerType.HYPONYM, PointerUtils.INFINITY, needSense, needGloss, needLex, needOffset, needSenseNum, needSenseKeys);
/** * Removes <var>indexWord</var> from the dictionary. * * @param indexWord index word to remove * @throws JWNLException JWNLException */ public synchronized void removeIndexWord(IndexWord indexWord) throws JWNLException { checkEditable(); indexWord.setDictionary(null); // take care of words in synsets List<Synset> copy = new ArrayList<>(indexWord.getSenses()); for (Synset synset : copy) { List<Word> wordsCopy = new ArrayList<>(synset.getWords()); for (Word word : wordsCopy) { if (word.getLemma().equalsIgnoreCase(indexWord.getLemma())) { synset.getWords().remove(word); break; } } } }
int result = 0; if (1 < getSenses().size()) { List<Synset> ucSenses = new ArrayList<>(getSenses().size()); List<Synset> nonUCSenses = new ArrayList<>(getSenses().size()); for (Synset synset : getSenses()) { if (0 < getUseCount(synset, lemma)) { ucSenses.add(synset); } else { ucSenses.sort(Collections.reverseOrder(Comparator.comparingInt(o -> getUseCount(o, lemma)))); if (POS.ADJECTIVE == getPOS()) { int i = 0; while (i < nonUCSenses.size()) { } else if (1 == getSenses().size()) { if (0 < getUseCount(getSenses().get(0), lemma)) { result = 1;
public IndexWord next() { if (hasNext()) { IndexWord thisWord = startWord; startWord = null; while (itr.hasNext()) { IndexWord word = itr.next(); if (word.getLemma().contains(searchString)) { startWord = word; break; } } return thisWord; } else { throw new NoSuchElementException(); } }
int id = nextId(); iwStmt.setInt(1, id); iwStmt.setString(2, iw.getLemma()); iwStmt.setString(3, iw.getPOS().getKey()); iwStmt.addBatch(); idToSynsetOffset.put(id, iw.getSynsetOffsets());