how to find POS

  • Anonymous

    Anonymous - 2003-09-05

    Can the JWNL find the POS of word?
    Example  "President" can get 'NOUN'
                 "was " can get 'VERB'

    I use methods like:                 

    but when i run my program, occur some error
       net.didion.jwnl.JWNLRuntimeException: DATA_EXCEPTION_004
            at Source)
            at JwnlTest.main(

    has anyone used?   Thanks

    • Anonymous

      Anonymous - 2003-09-08

      i was also trying to get POS.
      Unfortunately, i too landed in the  same problem.

        But it is working fine when i checked with the following code.
        IndexWord wd=Dictionary.getInstance().getIndexWord(POS.VERB,"accomplish");

      If u trace out the problem, do mail me.

      • Yaroslav Bulatov

        The question by itself is not well-posed. Consider for instance word "bend". It is often used as noun as it is as verb. Insteat what you want is a polysemy count for each part of speech possibility for given word. The code below will produce lines like "turn:12,26,0,0" meaning that turn has 12 meanings as noun, 26 as verb, 0 as adjective and 0 as adverb:

        import java.util.*;

        import net.didion.jwnl.*;
        import net.didion.jwnl.dictionary.*;
        import net.didion.jwnl.dictionary.Dictionary;

        public class WSJTest {
          public static void main(String[] args) throws Exception {
            JWNL.initialize(new FileInputStream(args[0]));
            String[] words = new String[]{"bend","cat","clown","meet","bend",
            for (int i = 0; i < words.length; ++i) {
              int[] p = polysemy(words[i]);
              for (int j = 0; j < p.length; ++j)
           * Returns list of polysemy counts for word.
           * result[0] is count for noun, 1 for verb, 2 for adjective, 3 for adverb
           * @param word word to examine
           * @return
          public static int[] polysemy(String word) throws JWNLException {
            int[] polysemies = new int[4];
            Dictionary d = Dictionary.getInstance();
            IndexWord noun_form = d.getIndexWord(POS.NOUN, word);
            polysemies[0] = (noun_form==null)?0:noun_form.getSenses().length;
            IndexWord verb_form = d.getIndexWord(POS.VERB, word);
            polysemies[1] = (verb_form==null)?0:verb_form.getSenses().length;
            IndexWord adj_form = d.getIndexWord(POS.ADJECTIVE, word);
            polysemies[2] = (adj_form==null)?0:adj_form.getSenses().length;
            IndexWord adv_form = d.getIndexWord(POS.ADVERB, word);
            polysemies[3] = (adv_form==null)?0:adv_form.getSenses().length;
            return polysemies;

    • John Didion

      John Didion - 2003-11-11

      The method Purna described is the correct way to the the part of speech for a word.


Log in to post a comment.