Revision: 17496
          http://sourceforge.net/p/gate/code/17496
Author:   markagreenwood
Date:     2014-03-01 14:20:35 +0000 (Sat, 01 Mar 2014)
Log Message:
-----------
the WordNet impl classes not have all the correct generics info, but more 
importantly the implement equals hand hashCode to make life easier when using 
the classes in anger

Modified Paths:
--------------
    gate/trunk/plugins/WordNet/src/gate/wordnet/AdjectiveImpl.java
    gate/trunk/plugins/WordNet/src/gate/wordnet/LexicalRelationImpl.java
    gate/trunk/plugins/WordNet/src/gate/wordnet/RelationImpl.java
    gate/trunk/plugins/WordNet/src/gate/wordnet/SemanticRelationImpl.java
    gate/trunk/plugins/WordNet/src/gate/wordnet/SynsetImpl.java
    gate/trunk/plugins/WordNet/src/gate/wordnet/VerbFrameImpl.java
    gate/trunk/plugins/WordNet/src/gate/wordnet/VerbImpl.java
    gate/trunk/plugins/WordNet/src/gate/wordnet/WordImpl.java
    gate/trunk/plugins/WordNet/src/gate/wordnet/WordSenseImpl.java
    gate/trunk/plugins/WordNet/src/gate/wordnet/test/TestWordNet.java
    gate/trunk/src/main/gate/wordnet/Synset.java

Modified: gate/trunk/plugins/WordNet/src/gate/wordnet/AdjectiveImpl.java
===================================================================
--- gate/trunk/plugins/WordNet/src/gate/wordnet/AdjectiveImpl.java      
2014-03-01 10:28:15 UTC (rev 17495)
+++ gate/trunk/plugins/WordNet/src/gate/wordnet/AdjectiveImpl.java      
2014-03-01 14:20:35 UTC (rev 17496)
@@ -1,45 +1,61 @@
 /*
- *  AdjectiveImpl.java
- *
- *  Copyright (c) 1995-2012, The University of Sheffield. See the file
- *  COPYRIGHT.txt in the software or at http://gate.ac.uk/gate/COPYRIGHT.txt
- *
- *  This file is part of GATE (see http://gate.ac.uk/), and is free
- *  software, licenced under the GNU Library General Public License,
- *  Version 2, June 1991 (in the distribution as file licence.html,
- *  and also available at http://gate.ac.uk/gate/licence.html).
- *
- *  Marin Dimitrov, 20/May/2002
- *
- *  $Id$
+ * AdjectiveImpl.java
+ * 
+ * Copyright (c) 1995-2012, The University of Sheffield. See the file
+ * COPYRIGHT.txt in the software or at http://gate.ac.uk/gate/COPYRIGHT.txt
+ * 
+ * This file is part of GATE (see http://gate.ac.uk/), and is free software,
+ * licenced under the GNU Library General Public License, Version 2, June 1991
+ * (in the distribution as file licence.html, and also available at
+ * http://gate.ac.uk/gate/licence.html).
+ * 
+ * Marin Dimitrov, 20/May/2002
+ * 
+ * $Id$
  */
 
 package gate.wordnet;
 
 import net.didion.jwnl.dictionary.Dictionary;
 
-/** Represents WordNet adjective
- *  implements interface Adjective
+/**
+ * Represents WordNet adjective implements interface Adjective
  */
-public class AdjectiveImpl extends WordSenseImpl
-                          implements Adjective {
+public class AdjectiveImpl extends WordSenseImpl implements Adjective {
 
   private int adjPosition;
 
-  public AdjectiveImpl(Word _word,
-                      Synset _synset,
-                      int _senseNumber,
-                      int _orderInSynset,
-                      boolean _isSemcor,
-                      int _adjPosition,
-                      Dictionary _wnDict) {
+  public AdjectiveImpl(WordImpl _word, SynsetImpl _synset, int _senseNumber,
+                       int _orderInSynset, boolean _isSemcor, int _adjPosition,
+                       Dictionary _wnDict) {
 
-    super(_word,_synset,_senseNumber,_orderInSynset,_isSemcor, _wnDict);
+    super(_word, _synset, _senseNumber, _orderInSynset, _isSemcor, _wnDict);
     this.adjPosition = _adjPosition;
   }
 
-  /** returns the syntactic position of the adjective in relation to noun that 
it modifies */
+  /**
+   * returns the syntactic position of the adjective in relation to noun that 
it
+   * modifies
+   */
   public int getAdjectivePosition() {
     return this.adjPosition;
   }
+
+  @Override
+  public int hashCode() {
+    final int prime = 31;
+    int result = super.hashCode();
+    result = prime * result + adjPosition;
+    return result;
+  }
+
+  @Override
+  public boolean equals(Object obj) {
+    if(this == obj) return true;
+    if(!super.equals(obj)) return false;
+    if(getClass() != obj.getClass()) return false;
+    AdjectiveImpl other = (AdjectiveImpl)obj;
+    if(adjPosition != other.adjPosition) return false;
+    return true;
+  }
 }
\ No newline at end of file

Modified: gate/trunk/plugins/WordNet/src/gate/wordnet/LexicalRelationImpl.java
===================================================================
--- gate/trunk/plugins/WordNet/src/gate/wordnet/LexicalRelationImpl.java        
2014-03-01 10:28:15 UTC (rev 17495)
+++ gate/trunk/plugins/WordNet/src/gate/wordnet/LexicalRelationImpl.java        
2014-03-01 14:20:35 UTC (rev 17496)
@@ -1,36 +1,38 @@
 /*
- *  LexicalRelation.java
- *
- *  Copyright (c) 1995-2012, The University of Sheffield. See the file
- *  COPYRIGHT.txt in the software or at http://gate.ac.uk/gate/COPYRIGHT.txt
- *
- *  This file is part of GATE (see http://gate.ac.uk/), and is free
- *  software, licenced under the GNU Library General Public License,
- *  Version 2, June 1991 (in the distribution as file licence.html,
- *  and also available at http://gate.ac.uk/gate/licence.html).
- *
- *  Marin Dimitrov, 16/May/2002
- *
- *  $Id$
+ * LexicalRelation.java
+ * 
+ * Copyright (c) 1995-2012, The University of Sheffield. See the file
+ * COPYRIGHT.txt in the software or at http://gate.ac.uk/gate/COPYRIGHT.txt
+ * 
+ * This file is part of GATE (see http://gate.ac.uk/), and is free software,
+ * licenced under the GNU Library General Public License, Version 2, June 1991
+ * (in the distribution as file licence.html, and also available at
+ * http://gate.ac.uk/gate/licence.html).
+ * 
+ * Marin Dimitrov, 16/May/2002
+ * 
+ * $Id$
  */
 
 package gate.wordnet;
 
 import junit.framework.Assert;
 
-/** Represents WordNet lexical relation.
- *  implrments LexicalRelation
+/**
+ * Represents WordNet lexical relation. implrments LexicalRelation
  */
 
-public class LexicalRelationImpl extends RelationImpl
-                                  implements LexicalRelation {
+public class LexicalRelationImpl extends RelationImpl implements
+  LexicalRelation {
 
   /** relation source */
-  private WordSense source;
+  private WordSenseImpl source;
+
   /** relation target */
-  private WordSense target;
+  private WordSenseImpl target;
 
-  public LexicalRelationImpl(int _type, WordSense _src, WordSense _target) {
+  public LexicalRelationImpl(int _type, WordSenseImpl _src,
+                             WordSenseImpl _target) {
 
     super(_type);
 
@@ -42,16 +44,37 @@
     this.target = _target;
   }
 
-
   /** returns the source (WordSense) of this lexical relation */
   public WordSense getSource() {
     return this.source;
   }
 
-
   /** returns the target (WordSense) of this lexical relation */
   public WordSense getTarget() {
     return this.target;
   }
 
+  @Override
+  public int hashCode() {
+    final int prime = 31;
+    int result = super.hashCode();
+    result = prime * result + ((source == null) ? 0 : source.hashCode());
+    result = prime * result + ((target == null) ? 0 : target.hashCode());
+    return result;
+  }
+
+  @Override
+  public boolean equals(Object obj) {
+    if(this == obj) return true;
+    if(!super.equals(obj)) return false;
+    if(getClass() != obj.getClass()) return false;
+    LexicalRelationImpl other = (LexicalRelationImpl)obj;
+    if(source == null) {
+      if(other.source != null) return false;
+    } else if(!source.equals(other.source)) return false;
+    if(target == null) {
+      if(other.target != null) return false;
+    } else if(!target.equals(other.target)) return false;
+    return true;
+  }
 }
\ No newline at end of file

Modified: gate/trunk/plugins/WordNet/src/gate/wordnet/RelationImpl.java
===================================================================
--- gate/trunk/plugins/WordNet/src/gate/wordnet/RelationImpl.java       
2014-03-01 10:28:15 UTC (rev 17495)
+++ gate/trunk/plugins/WordNet/src/gate/wordnet/RelationImpl.java       
2014-03-01 14:20:35 UTC (rev 17496)
@@ -1,22 +1,21 @@
 /*
- *  Synset.java
- *
- *  Copyright (c) 1995-2012, The University of Sheffield. See the file
- *  COPYRIGHT.txt in the software or at http://gate.ac.uk/gate/COPYRIGHT.txt
- *
- *  This file is part of GATE (see http://gate.ac.uk/), and is free
- *  software, licenced under the GNU Library General Public License,
- *  Version 2, June 1991 (in the distribution as file licence.html,
- *  and also available at http://gate.ac.uk/gate/licence.html).
- *
- *  Marin Dimitrov, 16/May/2002
- *
- *  $Id$
+ * Synset.java
+ * 
+ * Copyright (c) 1995-2012, The University of Sheffield. See the file
+ * COPYRIGHT.txt in the software or at http://gate.ac.uk/gate/COPYRIGHT.txt
+ * 
+ * This file is part of GATE (see http://gate.ac.uk/), and is free software,
+ * licenced under the GNU Library General Public License, Version 2, June 1991
+ * (in the distribution as file licence.html, and also available at
+ * http://gate.ac.uk/gate/licence.html).
+ * 
+ * Marin Dimitrov, 16/May/2002
+ * 
+ * $Id$
  */
 
 package gate.wordnet;
 
-
 class RelationImpl implements Relation {
 
   private int type;
@@ -26,29 +25,25 @@
     this.type = _type;
   }
 
-
-  /** returns the type of the relation - one of REL_XXX*/
+  /** returns the type of the relation - one of REL_XXX */
   public int getType() {
     return this.type;
   }
 
-
   /** returns a symbol for the relation, e.g. "@" */
   public String getSymbol() {
     return WNHelper.int2PointerType(this.type).getKey();
   }
 
-
   /** returns a label for the relation, e.g. "HYPERNYM" */
   public String getLabel() {
     return WNHelper.int2PointerType(this.type).getLabel();
   }
 
-
-  /** returns the inverse relation (Hyponym  <-> Hypernym, etc)*/
+  /** returns the inverse relation (Hyponym <-> Hypernym, etc) */
   public int getInverseType() {
 
-    switch(this.type) {
+    switch(this.type){
 
       case Relation.REL_ANTONYM:
         return Relation.REL_ANTONYM;
@@ -79,10 +74,29 @@
     }
   }
 
-
-  /** checks if the relation is applicab;le to specific POS - see REL_XXX 
comments */
+  /**
+   * checks if the relation is applicab;le to specific POS - see REL_XXX
+   * comments
+   */
   public boolean isApplicableTo(int pos) {
     return 
WNHelper.int2PointerType(this.type).appliesTo(WNHelper.int2POS(pos));
   }
 
+  @Override
+  public int hashCode() {
+    final int prime = 31;
+    int result = 1;
+    result = prime * result + type;
+    return result;
+  }
+
+  @Override
+  public boolean equals(Object obj) {
+    if(this == obj) return true;
+    if(obj == null) return false;
+    if(getClass() != obj.getClass()) return false;
+    RelationImpl other = (RelationImpl)obj;
+    if(type != other.type) return false;
+    return true;
+  }
 }
\ No newline at end of file

Modified: gate/trunk/plugins/WordNet/src/gate/wordnet/SemanticRelationImpl.java
===================================================================
--- gate/trunk/plugins/WordNet/src/gate/wordnet/SemanticRelationImpl.java       
2014-03-01 10:28:15 UTC (rev 17495)
+++ gate/trunk/plugins/WordNet/src/gate/wordnet/SemanticRelationImpl.java       
2014-03-01 14:20:35 UTC (rev 17496)
@@ -1,31 +1,32 @@
 /*
- *  SemanticRelation.java
- *
- *  Copyright (c) 1995-2012, The University of Sheffield. See the file
- *  COPYRIGHT.txt in the software or at http://gate.ac.uk/gate/COPYRIGHT.txt
- *
- *  This file is part of GATE (see http://gate.ac.uk/), and is free
- *  software, licenced under the GNU Library General Public License,
- *  Version 2, June 1991 (in the distribution as file licence.html,
- *  and also available at http://gate.ac.uk/gate/licence.html).
- *
- *  Marin Dimitrov, 16/May/2002
- *
- *  $Id$
+ * SemanticRelation.java
+ * 
+ * Copyright (c) 1995-2012, The University of Sheffield. See the file
+ * COPYRIGHT.txt in the software or at http://gate.ac.uk/gate/COPYRIGHT.txt
+ * 
+ * This file is part of GATE (see http://gate.ac.uk/), and is free software,
+ * licenced under the GNU Library General Public License, Version 2, June 1991
+ * (in the distribution as file licence.html, and also available at
+ * http://gate.ac.uk/gate/licence.html).
+ * 
+ * Marin Dimitrov, 16/May/2002
+ * 
+ * $Id$
  */
 
 package gate.wordnet;
 
 import junit.framework.Assert;
 
-public class SemanticRelationImpl extends RelationImpl
-                                  implements SemanticRelation {
+public class SemanticRelationImpl extends RelationImpl implements
+  SemanticRelation {
 
-  private Synset source;
-  private Synset target;
+  private SynsetImpl source;
 
-  public SemanticRelationImpl(int _type, Synset _src, Synset _target) {
+  private SynsetImpl target;
 
+  public SemanticRelationImpl(int _type, SynsetImpl _src, SynsetImpl _target) {
+
     super(_type);
 
     Assert.assertNotNull(_src);
@@ -36,7 +37,6 @@
     this.target = _target;
   }
 
-
   /** returns the source (Synset) of this lexical relation */
   public Synset getSource() {
     return this.source;
@@ -47,4 +47,27 @@
     return this.target;
   }
 
+  @Override
+  public int hashCode() {
+    final int prime = 31;
+    int result = super.hashCode();
+    result = prime * result + ((source == null) ? 0 : source.hashCode());
+    result = prime * result + ((target == null) ? 0 : target.hashCode());
+    return result;
+  }
+
+  @Override
+  public boolean equals(Object obj) {
+    if(this == obj) return true;
+    if(!super.equals(obj)) return false;
+    if(getClass() != obj.getClass()) return false;
+    SemanticRelationImpl other = (SemanticRelationImpl)obj;
+    if(source == null) {
+      if(other.source != null) return false;
+    } else if(!source.equals(other.source)) return false;
+    if(target == null) {
+      if(other.target != null) return false;
+    } else if(!target.equals(other.target)) return false;
+    return true;
+  }
 }
\ No newline at end of file

Modified: gate/trunk/plugins/WordNet/src/gate/wordnet/SynsetImpl.java
===================================================================
--- gate/trunk/plugins/WordNet/src/gate/wordnet/SynsetImpl.java 2014-03-01 
10:28:15 UTC (rev 17495)
+++ gate/trunk/plugins/WordNet/src/gate/wordnet/SynsetImpl.java 2014-03-01 
14:20:35 UTC (rev 17496)
@@ -1,17 +1,17 @@
 /*
- *  Relation.java
- *
- *  Copyright (c) 1995-2012, The University of Sheffield. See the file
- *  COPYRIGHT.txt in the software or at http://gate.ac.uk/gate/COPYRIGHT.txt
- *
- *  This file is part of GATE (see http://gate.ac.uk/), and is free
- *  software, licenced under the GNU Library General Public License,
- *  Version 2, June 1991 (in the distribution as file licence.html,
- *  and also available at http://gate.ac.uk/gate/licence.html).
- *
- *  Marin Dimitrov, 16/May/2002
- *
- *  $Id$
+ * Relation.java
+ * 
+ * Copyright (c) 1995-2012, The University of Sheffield. See the file
+ * COPYRIGHT.txt in the software or at http://gate.ac.uk/gate/COPYRIGHT.txt
+ * 
+ * This file is part of GATE (see http://gate.ac.uk/), and is free software,
+ * licenced under the GNU Library General Public License, Version 2, June 1991
+ * (in the distribution as file licence.html, and also available at
+ * http://gate.ac.uk/gate/licence.html).
+ * 
+ * Marin Dimitrov, 16/May/2002
+ * 
+ * $Id$
  */
 
 package gate.wordnet;
@@ -25,92 +25,87 @@
 
 import gate.util.GateRuntimeException;
 
-
 public class SynsetImpl implements Synset {
 
   private List<WordSense> wordSenses;
+
   private List<SemanticRelation> semRelations;
+
   private String gloss;
+
   private int synsetPOS;
+
   Dictionary wnDictionary;
+
   private long synsetOffset;
 
-  public SynsetImpl(net.didion.jwnl.data.Synset jwSynset, Dictionary 
_wnDictionary) throws GateRuntimeException {
+  public SynsetImpl(net.didion.jwnl.data.Synset jwSynset,
+                    Dictionary _wnDictionary) throws GateRuntimeException {
 
-    //0.
+    // 0.
     Assert.assertNotNull(jwSynset);
 
-    //dictionary
+    // dictionary
     this.wnDictionary = _wnDictionary;
 
-    //offset
+    // offset
     this.synsetOffset = jwSynset.getOffset();
 
-    //pos
+    // pos
     this.synsetPOS = WNHelper.POS2int(jwSynset.getPOS());
 
-    //gloss
+    // gloss
     this.gloss = jwSynset.getGloss();
 
-    //word senses
+    // word senses
     net.didion.jwnl.data.Word[] synsetWords = jwSynset.getWords();
     this.wordSenses = new ArrayList<WordSense>(synsetWords.length);
 
-    for (int i= 0; i< synsetWords.length; i++) {
+    for(int i = 0; i < synsetWords.length; i++) {
 
       net.didion.jwnl.data.Word jwWord = synsetWords[i];
       IndexWord jwIndexWord = null;
 
       try {
-        jwIndexWord = 
this.wnDictionary.lookupIndexWord(jwWord.getPOS(),jwWord.getLemma());
-      }
-      catch(JWNLException jwe) {
+        jwIndexWord =
+          this.wnDictionary.lookupIndexWord(jwWord.getPOS(), 
jwWord.getLemma());
+      } catch(JWNLException jwe) {
         throw new GateRuntimeException(jwe.getMessage());
       }
 
-      Word gateWord = new WordImpl(jwWord.getLemma(),
-                                   jwIndexWord.getSenseCount(),
-                                   this.wnDictionary);
+      WordImpl gateWord =
+        new WordImpl(jwWord.getLemma(), jwIndexWord.getSenseCount(),
+          this.wnDictionary);
 
-      //construct the proper word form
+      // construct the proper word form
       WordSense gateWordSense = null;
 
-     /* if (this.synsetPOS == WordNet.POS_ADJECTIVE) {
+      /*
+       * if (this.synsetPOS == WordNet.POS_ADJECTIVE) {
+       * 
+       * //Assert.assertTrue(jwWord instanceof net.didion.jwnl.data.Adjective);
+       * net.didion.jwnl.data.Adjective jwAdjective =
+       * (net.didion.jwnl.data.Adjective)jwWord;
+       * 
+       * gateWordSense = new AdjectiveImpl(gateWord, this, 0, 
jwWord.getIndex(),
+       * false, WNHelper.AdjPosition2int(jwAdjective), this.wnDictionary); }
+       * 
+       * else
+       */
+      if(this.synsetPOS == WordNet.POS_VERB) {
 
-        //Assert.assertTrue(jwWord instanceof net.didion.jwnl.data.Adjective);
-        net.didion.jwnl.data.Adjective jwAdjective = 
(net.didion.jwnl.data.Adjective)jwWord;
-
-        gateWordSense = new AdjectiveImpl(gateWord,
-                                          this,
-                                          0,
-                                          jwWord.getIndex(),
-                                          false,
-                                          
WNHelper.AdjPosition2int(jwAdjective),
-                                          this.wnDictionary);
-      }
-
-      else*/ 
-        if (this.synsetPOS == WordNet.POS_VERB) {
-
         Assert.assertTrue(jwWord instanceof net.didion.jwnl.data.Verb);
         net.didion.jwnl.data.Verb jwVerb = (net.didion.jwnl.data.Verb)jwWord;
 
-        gateWordSense = new VerbImpl(gateWord,
-                                      this,
-                                      0,
-                                      jwWord.getIndex(),
-                                      false,
-                                      jwVerb,
-                                      this.wnDictionary);
+        gateWordSense =
+          new VerbImpl(gateWord, this, 0, jwWord.getIndex(), false, jwVerb,
+            this.wnDictionary);
       }
 
       else {
-        gateWordSense = new WordSenseImpl(gateWord,
-                                          this,
-                                          0,
-                                          jwWord.getIndex(),
-                                          false,
-                                          this.wnDictionary);
+        gateWordSense =
+          new WordSenseImpl(gateWord, this, 0, jwWord.getIndex(), false,
+            this.wnDictionary);
       }
 
       this.wordSenses.add(gateWordSense);
@@ -118,40 +113,40 @@
 
   }
 
-
   /** returns the part-of-speech for this synset, see WordNet::POS_XXX 
constants */
-  public int getPOS(){
+  public int getPOS() {
     return this.synsetPOS;
   }
 
   /** is this synset a UB - i.e. has no hypernym */
   public boolean isUniqueBeginner() throws WordNetException {
-    List<SemanticRelation> parents = 
getSemanticRelations(Relation.REL_HYPERNYM);
+    List<SemanticRelation> parents =
+      getSemanticRelations(Relation.REL_HYPERNYM);
     return parents.isEmpty();
   }
 
   /** textual description of the synset */
-  public String getGloss(){
+  public String getGloss() {
     return this.gloss;
   }
 
-
   /** WordSenses contained in this synset */
-  public List<WordSense> getWordSenses(){
+  public List<WordSense> getWordSenses() {
     return this.wordSenses;
   }
 
-
-  /** get specific WordSense according to its order in the synset - most 
important senses come first  */
-  public WordSense getWordSense(int offset){
+  /**
+   * get specific WordSense according to its order in the synset - most
+   * important senses come first
+   */
+  public WordSense getWordSense(int offset) {
     return (WordSense)this.wordSenses.get(offset);
   }
 
-
   /** get the SemanticRelation-s of this synset */
-  public List<SemanticRelation> getSemanticRelations() throws WordNetException{
+  public List<SemanticRelation> getSemanticRelations() throws WordNetException 
{
 
-    if (null == this.semRelations) {
+    if(null == this.semRelations) {
       _loadSemanticRelations();
     }
 
@@ -159,19 +154,20 @@
   }
 
   /** get the SemanticRelation-s of specific type (HYPERNYm) for this synset */
-  public List<SemanticRelation> getSemanticRelations(int type) throws 
WordNetException{
+  public List<SemanticRelation> getSemanticRelations(int type)
+    throws WordNetException {
 
     List<SemanticRelation> result = new ArrayList<SemanticRelation>(1);
 
-    if (null == this.semRelations) {
+    if(null == this.semRelations) {
       _loadSemanticRelations();
     }
 
     Iterator<SemanticRelation> it = this.semRelations.iterator();
-    while (it.hasNext()) {
+    while(it.hasNext()) {
       SemanticRelation sRel = (SemanticRelation)it.next();
       Assert.assertNotNull(sRel);
-      if (type == sRel.getType()) {
+      if(type == sRel.getType()) {
         result.add(sRel);
       }
     }
@@ -179,47 +175,47 @@
     return result;
   }
 
+  private void _loadSemanticRelations() throws WordNetException {
 
-  private void _loadSemanticRelations() throws WordNetException{
-
     POS jwPOS = null;
     jwPOS = WNHelper.int2POS(this.synsetPOS);
 
     try {
-      net.didion.jwnl.data.Synset jwSynset = 
this.wnDictionary.getSynsetAt(jwPOS,this.synsetOffset);
+      net.didion.jwnl.data.Synset jwSynset =
+        this.wnDictionary.getSynsetAt(jwPOS, this.synsetOffset);
       Assert.assertNotNull(jwSynset);
       Pointer[] jwPointers = jwSynset.getPointers();
 
       this.semRelations = new ArrayList<SemanticRelation>(jwPointers.length);
 
-      for (int i= 0; i< jwPointers.length; i++) {
+      for(int i = 0; i < jwPointers.length; i++) {
         Pointer currPointer = jwPointers[i];
 
-        //skip lexical relations
-        if (true == currPointer.isLexical()) {
+        // skip lexical relations
+        if(true == currPointer.isLexical()) {
           continue;
         }
         PointerType currType = currPointer.getType();
         try {
-        
-//        PointerTarget ptrSource = currPointer.getSource();
-        PointerTarget ptrTarget = currPointer.getTarget();
-        Assert.assertTrue(ptrTarget instanceof net.didion.jwnl.data.Synset);
-        net.didion.jwnl.data.Synset jwTargetSynset = 
(net.didion.jwnl.data.Synset)ptrTarget;
 
-        Synset gateTargetSynset = new 
SynsetImpl(jwTargetSynset,this.wnDictionary);
-        SemanticRelation currSemRel = new 
SemanticRelationImpl(WNHelper.PointerType2int(currType),
-                                                            this,
-                                                            gateTargetSynset);
-        //add to list of sem relations for this synset
-        this.semRelations.add(currSemRel);
+          // PointerTarget ptrSource = currPointer.getSource();
+          PointerTarget ptrTarget = currPointer.getTarget();
+          Assert.assertTrue(ptrTarget instanceof net.didion.jwnl.data.Synset);
+          net.didion.jwnl.data.Synset jwTargetSynset =
+            (net.didion.jwnl.data.Synset)ptrTarget;
+
+          SynsetImpl gateTargetSynset =
+            new SynsetImpl(jwTargetSynset, this.wnDictionary);
+          SemanticRelation currSemRel =
+            new SemanticRelationImpl(WNHelper.PointerType2int(currType), this,
+              gateTargetSynset);
+          // add to list of sem relations for this synset
+          this.semRelations.add(currSemRel);
+        } catch(IllegalArgumentException e) {
+          // System.err.println("Unknown PointerType:" + currType);
         }
-        catch (IllegalArgumentException e){
-          //System.err.println("Unknown PointerType:" + currType);
-        }
       }
-    }
-    catch(JWNLException e) {
+    } catch(JWNLException e) {
       throw new WordNetException(e);
     }
   }
@@ -229,4 +225,24 @@
 
     return this.synsetOffset;
   }
+
+  @Override
+  public int hashCode() {
+    final int prime = 31;
+    int result = 1;
+    result = prime * result + (int)(synsetOffset ^ (synsetOffset >>> 32));
+    result = prime * result + synsetPOS;
+    return result;
+  }
+
+  @Override
+  public boolean equals(Object obj) {
+    if(this == obj) return true;
+    if(obj == null) return false;
+    if(getClass() != obj.getClass()) return false;
+    SynsetImpl other = (SynsetImpl)obj;
+    if(synsetOffset != other.synsetOffset) return false;
+    if(synsetPOS != other.synsetPOS) return false;
+    return true;
+  }
 }
\ No newline at end of file

Modified: gate/trunk/plugins/WordNet/src/gate/wordnet/VerbFrameImpl.java
===================================================================
--- gate/trunk/plugins/WordNet/src/gate/wordnet/VerbFrameImpl.java      
2014-03-01 10:28:15 UTC (rev 17495)
+++ gate/trunk/plugins/WordNet/src/gate/wordnet/VerbFrameImpl.java      
2014-03-01 14:20:35 UTC (rev 17496)
@@ -1,17 +1,17 @@
 /*
- *  VerbFrameImpl.java
- *
- *  Copyright (c) 1995-2012, The University of Sheffield. See the file
- *  COPYRIGHT.txt in the software or at http://gate.ac.uk/gate/COPYRIGHT.txt
- *
- *  This file is part of GATE (see http://gate.ac.uk/), and is free
- *  software, licenced under the GNU Library General Public License,
- *  Version 2, June 1991 (in the distribution as file licence.html,
- *  and also available at http://gate.ac.uk/gate/licence.html).
- *
- *  Marin Dimitrov, 16/May/2002
- *
- *  $Id$
+ * VerbFrameImpl.java
+ * 
+ * Copyright (c) 1995-2012, The University of Sheffield. See the file
+ * COPYRIGHT.txt in the software or at http://gate.ac.uk/gate/COPYRIGHT.txt
+ * 
+ * This file is part of GATE (see http://gate.ac.uk/), and is free software,
+ * licenced under the GNU Library General Public License, Version 2, June 1991
+ * (in the distribution as file licence.html, and also available at
+ * http://gate.ac.uk/gate/licence.html).
+ * 
+ * Marin Dimitrov, 16/May/2002
+ * 
+ * $Id$
  */
 
 package gate.wordnet;
@@ -32,4 +32,23 @@
     return this.frame;
   }
 
+  @Override
+  public int hashCode() {
+    final int prime = 31;
+    int result = 1;
+    result = prime * result + ((frame == null) ? 0 : frame.hashCode());
+    return result;
+  }
+
+  @Override
+  public boolean equals(Object obj) {
+    if(this == obj) return true;
+    if(obj == null) return false;
+    if(getClass() != obj.getClass()) return false;
+    VerbFrameImpl other = (VerbFrameImpl)obj;
+    if(frame == null) {
+      if(other.frame != null) return false;
+    } else if(!frame.equals(other.frame)) return false;
+    return true;
+  }
 }
\ No newline at end of file

Modified: gate/trunk/plugins/WordNet/src/gate/wordnet/VerbImpl.java
===================================================================
--- gate/trunk/plugins/WordNet/src/gate/wordnet/VerbImpl.java   2014-03-01 
10:28:15 UTC (rev 17495)
+++ gate/trunk/plugins/WordNet/src/gate/wordnet/VerbImpl.java   2014-03-01 
14:20:35 UTC (rev 17496)
@@ -1,17 +1,17 @@
 /*
- *  VerbImpl.java
- *
- *  Copyright (c) 1995-2012, The University of Sheffield. See the file
- *  COPYRIGHT.txt in the software or at http://gate.ac.uk/gate/COPYRIGHT.txt
- *
- *  This file is part of GATE (see http://gate.ac.uk/), and is free
- *  software, licenced under the GNU Library General Public License,
- *  Version 2, June 1991 (in the distribution as file licence.html,
- *  and also available at http://gate.ac.uk/gate/licence.html).
- *
- *  Marin Dimitrov, 20/May/2002
- *
- *  $Id$
+ * VerbImpl.java
+ * 
+ * Copyright (c) 1995-2012, The University of Sheffield. See the file
+ * COPYRIGHT.txt in the software or at http://gate.ac.uk/gate/COPYRIGHT.txt
+ * 
+ * This file is part of GATE (see http://gate.ac.uk/), and is free software,
+ * licenced under the GNU Library General Public License, Version 2, June 1991
+ * (in the distribution as file licence.html, and also available at
+ * http://gate.ac.uk/gate/licence.html).
+ * 
+ * Marin Dimitrov, 20/May/2002
+ * 
+ * $Id$
  */
 
 package gate.wordnet;
@@ -22,29 +22,25 @@
 import junit.framework.Assert;
 import net.didion.jwnl.dictionary.Dictionary;
 
-/** Represents WordNet verb.
+/**
+ * Represents WordNet verb.
  */
-public class VerbImpl extends WordSenseImpl
-                      implements Verb {
+public class VerbImpl extends WordSenseImpl implements Verb {
 
   private List<VerbFrame> verbFrames;
 
-  public VerbImpl(Word _word,
-                  Synset _synset,
-                  int _senseNumber,
-                  int _orderInSynset,
-                  boolean _isSemcor,
-                  net.didion.jwnl.data.Verb _jwVerb,
-                  Dictionary _wnDict) {
+  public VerbImpl(WordImpl _word, SynsetImpl _synset, int _senseNumber,
+                  int _orderInSynset, boolean _isSemcor,
+                  net.didion.jwnl.data.Verb _jwVerb, Dictionary _wnDict) {
 
-    super(_word,_synset,_senseNumber,_orderInSynset,_isSemcor, _wnDict);
+    super(_word, _synset, _senseNumber, _orderInSynset, _isSemcor, _wnDict);
 
     Assert.assertNotNull(_jwVerb);
 
     String[] jwFrames = _jwVerb.getVerbFrames();
     this.verbFrames = new ArrayList<VerbFrame>(jwFrames.length);
 
-    for (int i= 0; i< jwFrames.length; i++) {
+    for(int i = 0; i < jwFrames.length; i++) {
       this.verbFrames.add(new VerbFrameImpl(jwFrames[i]));
     }
   }
@@ -53,4 +49,26 @@
   public List<VerbFrame> getVerbFrames() {
     return this.verbFrames;
   }
+
+  @Override
+  public int hashCode() {
+    final int prime = 31;
+    int result = super.hashCode();
+    result =
+      prime * result + ((verbFrames == null) ? 0 : verbFrames.hashCode());
+    return result;
+  }
+
+  @Override
+  public boolean equals(Object obj) {
+    if(this == obj) return true;
+    if(!super.equals(obj)) return false;
+    if(getClass() != obj.getClass()) return false;
+    VerbImpl other = (VerbImpl)obj;
+    if(verbFrames == null) {
+      if(other.verbFrames != null) return false;
+    } else if(!verbFrames.equals(other.verbFrames)) return false;
+    return true;
+  }
+
 }
\ No newline at end of file

Modified: gate/trunk/plugins/WordNet/src/gate/wordnet/WordImpl.java
===================================================================
--- gate/trunk/plugins/WordNet/src/gate/wordnet/WordImpl.java   2014-03-01 
10:28:15 UTC (rev 17495)
+++ gate/trunk/plugins/WordNet/src/gate/wordnet/WordImpl.java   2014-03-01 
14:20:35 UTC (rev 17496)
@@ -93,4 +93,24 @@
   public int getSenseCount(){
     return this.senseCount;
   }
+
+  @Override
+  public int hashCode() {
+    final int prime = 31;
+    int result = 1;
+    result = prime * result + ((lemma == null) ? 0 : lemma.hashCode());
+    return result;
+  }
+
+  @Override
+  public boolean equals(Object obj) {
+    if(this == obj) return true;
+    if(obj == null) return false;
+    if(getClass() != obj.getClass()) return false;
+    WordImpl other = (WordImpl)obj;
+    if(lemma == null) {
+      if(other.lemma != null) return false;
+    } else if(!lemma.equals(other.lemma)) return false;
+    return true;
+  }   
 }
\ No newline at end of file

Modified: gate/trunk/plugins/WordNet/src/gate/wordnet/WordSenseImpl.java
===================================================================
--- gate/trunk/plugins/WordNet/src/gate/wordnet/WordSenseImpl.java      
2014-03-01 10:28:15 UTC (rev 17495)
+++ gate/trunk/plugins/WordNet/src/gate/wordnet/WordSenseImpl.java      
2014-03-01 14:20:35 UTC (rev 17496)
@@ -16,26 +16,32 @@
 
 package gate.wordnet;
 
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
 
 import junit.framework.Assert;
 import net.didion.jwnl.JWNLException;
-import net.didion.jwnl.data.*;
+import net.didion.jwnl.data.IndexWord;
+import net.didion.jwnl.data.POS;
+import net.didion.jwnl.data.Pointer;
+import net.didion.jwnl.data.PointerTarget;
+import net.didion.jwnl.data.PointerType;
 import net.didion.jwnl.dictionary.Dictionary;
 
 
 public class WordSenseImpl implements WordSense {
 
-  private Word word;
-  private Synset  synset;
+  private WordImpl word;
+  private SynsetImpl  synset;
   private int senseNumber;
   private int orderInSynset;
   private boolean isSemcor;
   private List<LexicalRelation> lexRelations;
   private Dictionary wnDictionary;
 
-  public WordSenseImpl(Word _word,
-                      Synset _synset,
+  public WordSenseImpl(WordImpl _word,
+                      SynsetImpl _synset,
                       int _senseNumber,
                       int _orderInSynset,
                       boolean _isSemcor,
@@ -160,13 +166,13 @@
         IndexWord jwTargetIndexWord = 
this.wnDictionary.lookupIndexWord(jwTargetWord.getPOS(),
                                                                       
jwTargetWord.getLemma());
 
-        Synset gateSynset = new SynsetImpl(jwTargetSynset,this.wnDictionary);
+        SynsetImpl gateSynset = new 
SynsetImpl(jwTargetSynset,this.wnDictionary);
 
-        Word gateWord = new WordImpl(jwTargetWord.getLemma(),
+        WordImpl gateWord = new WordImpl(jwTargetWord.getLemma(),
                                       jwTargetIndexWord.getSenseCount(),
                                       this.wnDictionary);
 
-        WordSense gateTargetWordSense = new WordSenseImpl(gateWord,
+        WordSenseImpl gateTargetWordSense = new WordSenseImpl(gateWord,
                                                           gateSynset,
                                                           0,
                                                           
jwTargetWord.getIndex(),
@@ -188,4 +194,28 @@
       throw new WordNetException(e);
     }
   }
+
+  @Override
+  public int hashCode() {
+    final int prime = 31;
+    int result = 1;
+    result = prime * result + ((synset == null) ? 0 : synset.hashCode());
+    result = prime * result + ((word == null) ? 0 : word.hashCode());
+    return result;
+  }
+
+  @Override
+  public boolean equals(Object obj) {
+    if(this == obj) return true;
+    if(obj == null) return false;
+    if(getClass() != obj.getClass()) return false;
+    WordSenseImpl other = (WordSenseImpl)obj;
+    if(synset == null) {
+      if(other.synset != null) return false;
+    } else if(!synset.equals(other.synset)) return false;
+    if(word == null) {
+      if(other.word != null) return false;
+    } else if(!word.equals(other.word)) return false;
+    return true;
+  }
 }
\ No newline at end of file

Modified: gate/trunk/plugins/WordNet/src/gate/wordnet/test/TestWordNet.java
===================================================================
--- gate/trunk/plugins/WordNet/src/gate/wordnet/test/TestWordNet.java   
2014-03-01 10:28:15 UTC (rev 17495)
+++ gate/trunk/plugins/WordNet/src/gate/wordnet/test/TestWordNet.java   
2014-03-01 14:20:35 UTC (rev 17496)
@@ -16,17 +16,23 @@
 
 package gate.wordnet.test;
 
+import gate.Gate;
+import gate.GateConstants;
+import gate.util.Err;
+import gate.wordnet.JWNLWordNetImpl;
+import gate.wordnet.SemanticRelation;
+import gate.wordnet.Synset;
+import gate.wordnet.WordNet;
+import gate.wordnet.WordSense;
+
 import java.io.File;
-import java.util.Iterator;
 import java.util.List;
 
-import junit.framework.*;
+import junit.framework.Assert;
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
 
-import gate.Gate;
-import gate.GateConstants;
-import gate.util.Err;
-import gate.wordnet.*;
-
 public class TestWordNet extends TestCase {
 
   private static WordNet wnMain = null;
@@ -66,14 +72,12 @@
     //WN16 index files
 
     //get all synsets for "cup"
-    List senseList = wnMain.lookupWord("cup",WordNet.POS_NOUN);
+    List<WordSense> senseList = wnMain.lookupWord("cup",WordNet.POS_NOUN);
     Assert.assertTrue(senseList.size() == 8);
 
-    Iterator itSenses = senseList.iterator();
-
     for (int i=0; i< senseList.size(); i++) {
 
-      WordSense currSense = (WordSense)senseList.get(i);
+      WordSense currSense = senseList.get(i);
       Synset currSynset = currSense.getSynset();
       Assert.assertNotNull(currSynset);
 
@@ -144,11 +148,9 @@
     //compare the result with the WN16 index files
     //get all synsets for "cup"
 
-    List senseList = wnMain.lookupWord("cup",WordNet.POS_NOUN);
+    List<WordSense> senseList = wnMain.lookupWord("cup",WordNet.POS_NOUN);
     Assert.assertTrue(senseList.size() == 8);
 
-    Iterator itSenses = senseList.iterator();
-
     for (int i=0; i< senseList.size(); i++) {
 
       WordSense currSense = (WordSense)senseList.get(i);
@@ -159,7 +161,7 @@
         continue;
       }
 
-      List semRelations = 
currSynset.getSemanticRelations(SemanticRelation.REL_HYPERNYM);
+      List<SemanticRelation> semRelations = 
currSynset.getSemanticRelations(SemanticRelation.REL_HYPERNYM);
       Assert.assertNotNull(semRelations);
       Assert.assertTrue(2 == semRelations.size());
 
@@ -231,11 +233,9 @@
     //test hyponymy - check all direct hyponyms of a word
     //compare the result with the WN16 index files
 
-    List senseList = wnMain.lookupWord("cup",WordNet.POS_NOUN);
+    List<WordSense> senseList = wnMain.lookupWord("cup",WordNet.POS_NOUN);
     Assert.assertTrue(senseList.size() == 8);
 
-    Iterator itSenses = senseList.iterator();
-
     for (int i=0; i< senseList.size(); i++) {
 
       WordSense currSense = (WordSense)senseList.get(i);
@@ -246,7 +246,7 @@
         continue;
       }
 
-      List semRelations = 
currSynset.getSemanticRelations(SemanticRelation.REL_HYPONYM);
+      List<SemanticRelation> semRelations = 
currSynset.getSemanticRelations(SemanticRelation.REL_HYPONYM);
       Assert.assertNotNull(semRelations);
       Assert.assertTrue(9 == semRelations.size());
 
@@ -325,7 +325,7 @@
 
     Assert.assertEquals(s.getGloss(),gloss);
 
-    List wordSenses = s.getWordSenses();
+    List<WordSense> wordSenses = s.getWordSenses();
     Assert.assertTrue(wordSenses.size() == numWords);
   }
 

Modified: gate/trunk/src/main/gate/wordnet/Synset.java
===================================================================
--- gate/trunk/src/main/gate/wordnet/Synset.java        2014-03-01 10:28:15 UTC 
(rev 17495)
+++ gate/trunk/src/main/gate/wordnet/Synset.java        2014-03-01 14:20:35 UTC 
(rev 17496)
@@ -18,7 +18,6 @@
 
 import java.util.List;
 
-
 /** Represents WordNet synset.
  */
 public interface Synset {

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
Flow-based real-time traffic analytics software. Cisco certified tool.
Monitor traffic, SLAs, QoS, Medianet, WAAS etc. with NetFlow Analyzer
Customize your own dashboards, set traffic alerts and generate reports.
Network behavioral analysis & security monitoring. All-in-one tool.
http://pubads.g.doubleclick.net/gampad/clk?id=126839071&iu=/4140/ostg.clktrk
_______________________________________________
GATE-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gate-cvs

Reply via email to