Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

check Word

Help
mmaalej
2008-01-28
2013-04-29
  • mmaalej
    mmaalej
    2008-01-28

    Hi *

    i want to check if a Word (for example "Tag") is in the Dictionary,
    this word can be Noun, Verb, ....

    i dont find any Method that return a boolean, and that check if the word exist.

    my Src:
            public CheckWord(BufferedReader reader) {
            String line = "";
            try {
                while ((line = reader.readLine()) != null) {
                    int indexlastTag = line.lastIndexOf("|");
                    String tag = new String(line.substring(indexlastTag + 1));
                    try {
                        JWNL.initialize(TestDefaults.getInputStream());
                        IndexWord iw = Dictionary.getInstance().lookupIndexWord(POS.NOUN, tag);
                        System.out.println("Index word : " + iw.toString());
                        foundTags.add(tag);
                    } catch (JWNLException e) {
                        notFoundTags.add(tag);
                    }
                }
            } catch (IOException e) {
                System.out.println(e.getMessage());
            }

    if the Word not exist , i will become the NullpointerException,
    an the Programme exit.

    Thanks
    Maalej

     
    • userlite
      userlite
      2008-02-22

      You can try this:

      IndexWord[] arrayWords = Dictionary.getInstance().lookupAllIndexWords(yourword).getIndexWordArray();

      if( arrayWords .length > 0 )
        return true;
      else
        return false;

      This code returns true if the word exists in wordnet in any pos form (noun, adj, adv, ...).