PointerType DERIVED used instead of PERTAINYM

  • Wolfgang Bischoff


    when I iterate over the pointers for the ADJECTIVE alaskan, I get pointers to the NOUN Alaska. Those pointers are of the DERIVED type which applies to ADVERBS! In my oppinion, the pointer type should be PERTAINYM which applies to ADJECTIVEs.

    My Question: Did I miss something or is this a bug?
    I am am using WordNet 2.1 on windows and checked out the JWNL recently from SVN.

    Thanks for sharing your opinions,

    • Ryan Nickell

      Ryan Nickell - 2009-08-13

      Hi, I did some messing around here and this is what I found.  Take the following block of code:

      String lemma = "alaskan";
      IndexWord alaskan = dictionary.lookupIndexWord(POS.ADJECTIVE, lemma);
      System.out.println("Number of senses:  " + alaskan.getSenseCount());
      Synset[] senses = alaskan.getSenses();
      for (Synset sense : senses) {
          Pointer [] pointers = sense.getPointers();
          for (Pointer pointer : pointers) {

      What this does is get all senses for "alaskan" and print all pointers and the glosses of their targets.  It will return the following in JWNL trunk:

      Number of senses:  1
      [PointerType: [Label: nominalization] [Key: +] Applies To: noun, verb]
      a state in northwestern North America; the 49th state admitted to the union; "Alaska is the largest state in the United States"
      [PointerType: [Label: derived] [Key: \] Applies To: adverb]
      a state in northwestern North America; the 49th state admitted to the union; "Alaska is the largest state in the United States"
      [PointerType: [Label: derived] [Key: \] Applies To: adverb]
      a native or resident of Alaska

      I'm not too sure what exactly is going on here, but one thing that deserves attention is the way WordNet itself works.  WordNet uses the same key symbol for PERTAINYMs as it does for DERIVED-FROM pointers, which is backslash \ .  This is a problem because in PointerType.java JWNL uses a HashMap to store pointer types.  As of now, only DERIVED is inserted into the map, but if both of them were then only the last would be inserted due to duplicate keys.  Inserting PERTAINYM into the list somewhere after DERIVED will fix it for PERTAINYMs such as "alaskan", but it will break DERIVED-FROMs such as "clearly".

      WordNet's own online tool on http://wordnetweb.princeton.edu/perl/webwn has the same issue except it's backwards:  Give it an adverb that ends in -ly, like "clearly", and it will tell you it's a PERTAINYM of the adjective "clear", even though it's clearly DERIVED-FROM the adjective "clear".

    • Ryan Nickell

      Ryan Nickell - 2009-08-13

      Here is a quick-and-dirty fix:   In PointerType.java, add PERTAINYM to ALL_TYPES.  Replace getPointerTypeForKey(String key) with the following:

          public static PointerType getPointerTypeForKey(String key, POS pos) {
              PointerType retval = null;
              if (key.equals(PointerType.PERTAINYM.getKey())) {
                  if (pos.equals(POS.ADJECTIVE))
                      retval = PERTAINYM;
                  else if (pos.equals(POS.ADVERB))
                      retval = DERIVED;
                      retval = (PointerType) KEY_TO_POINTER_TYPE_MAP.get(key);
              } else {
                  retval = (PointerType) KEY_TO_POINTER_TYPE_MAP.get(key);
              return retval;

      Assuming only ADJECTIVEs can be PERTAINYMs and ADVERBs can be DERIVED-FROMs, if key is "\" in this method then that implies we also need to know the POS of the word.  This method is called four times in JWNL; because we are adding a parameter we will need to change these calls as well.  The sources are:


      In the first three, add the pos variable from the calling method's parameter list.  In Pointer.java, change line 134 to the following so it passes null as the second parameter:

              _pointerType = PointerType.getPointerTypeForKey(_pointerType.getKey(), null);

      This is why I call it a quick-and-dirty fix because I don't know what to put in here.  Also there's probably a more elegant way to fix this than doing it this way.

    • Ryan Nickell

      Ryan Nickell - 2009-08-14

      Ignore the line I gave above and use this line instead for readObject() in Pointer.java:

      _pointerType = PointerType.getPointerTypeForKey(_pointerType.getKey(), getSource().getPOS());

      The method readObject() is only called during deserialization, when using MapBackedDictionary.  This, with the other modifications, will ensure that MapBackedDictionary works correctly under the scenario given in this thread.

    • Wolfgang Bischoff

      Thank you Ryan for your detailed answer. As I was not at my computer for several weeks I could not answer sooner. I am going to use your fix.

      Thanks a lot


Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.

No, thanks