@Test public void randomWalk() throws JWNLException { long start = System.currentTimeMillis(); POS pos = POS.getPOSForId(r.nextInt(4) + 1); Synset s = d.getSynsetIterator(pos).next(); for (int i = 0; i < 10000; i++) { List<Pointer> ptrs = s.getPointers(); PointerTarget p = ptrs.get(r.nextInt(ptrs.size())).getTarget(); s = p.getSynset(); } for (int i = 0; i < 10000; i++) { IndexWord w = d.getRandomIndexWord(pos); } long end = System.currentTimeMillis(); System.out.println("Walk (ms):\t" + (end - start)); }
@Override public void setDictionary(Dictionary dictionary) throws JWNLException { if (dictionary != this.dictionary) { if (null != this.dictionary) { Dictionary old = this.dictionary; this.dictionary = dictionary; old.removeElement(this); } super.setDictionary(dictionary); if (null != dictionary) { dictionary.addElement(this); } } }