Package net.didion.jwnl.data

Examples of net.didion.jwnl.data.IndexWord


  }

  public String[] getParentSenseKeys(String lemma, String pos, int sense) {
    //System.err.println("JWNLDictionary.getParentSenseKeys: lemma="+lemma);
    try {
      IndexWord iw = dict.getIndexWord(POS.NOUN,lemma);
      if (iw != null) {
        Synset synset = iw.getSense(sense+1);
        List<String> parents = new ArrayList<String>();
        getParents(synset,parents);
        return parents.toArray(new String[parents.size()]);
      }
      else {
View Full Code Here


     */
    public void play(final String channel, final boolean hard) {
        new Thread(new Runnable() {
            public void run() {
                try {
                    IndexWord word = getRandomWord(hard);
                    // System.out.println("Word is: " + word);
                    String scrambled = scramble(word.getLemma());
                    bot.wordGameRunning = true;
                    bot.sawGameDone = false;
                    bot.wordScore = 200;
                    if (hard)
                        bot.wordScore = bot.wordScore * 3;
                    bot.wordWord = word.getLemma();
                    String dots = "";
                    char[] toCharArray = word.getLemma().substring(2)
                            .toCharArray();
                    for (int i = 0; i < toCharArray.length; i++) {
                        dots = dots + ".";
                    }
                    int deduction = 10;
                    int thinkingTime = 15000;

                    // scrambled word
                    bot.send_privmsg(channel, "[w] [" + scrambled + "]");

                    if (isDone(thinkingTime, deduction))
                        return;

                    // part of speech
                    bot.send_privmsg(channel, "[w] Part of speech: "
                            + word.getPOS().getLabel());

                    if (isDone(thinkingTime, deduction))
                        return;

                    // beginning
                    bot.send_privmsg(channel, "[w] ["
                            + word.getLemma().charAt(0) + dots + ".]");

                    if (isDone(thinkingTime, deduction))
                        return;

                    // beginning and end
                    bot.send_privmsg(channel, "[w] ["
                            + word.getLemma().charAt(0)
                            + dots
                            + word.getLemma().charAt(
                                    word.getLemma().length() - 1) + "]");

                    if (isDone(thinkingTime, 60))
                        return;

                    // definition
                    String sendString = WNLookup.getStaticDefString(
                            word.getLemma()).split(";")[0].trim().replaceAll(
                            "#", "");
                    sendString = shortenIfRequired(sendString);
                    bot.send_privmsg(channel, "[w] Definition: " + sendString);

                    if (isDone(thinkingTime, deduction))
                        return;

                    // antonyms
                    String res = SemanticRelations.getAntoString(
                            word.getLemma()).replaceAll("\\[ none \\]", "")
                            .trim();
                    if (!res.equals("")) {
                        res = shortenIfRequired(res);
                        bot.send_privmsg(channel, "[w] Opposite: " + res);
                        if (isDone(thinkingTime, deduction))
                            return;
                    }

                    // synonymes
                    res = SemanticRelations.getSynoString(word.getLemma())
                            .replaceAll("\\[ none \\]", "").trim();
                    if (!res.equals("")) {
                        res = shortenIfRequired(res);
                        bot.send_privmsg(channel, "[w] Synonym: " + res);

                        if (isDone(thinkingTime, deduction))
                            return;
                    }
                    // hypernyms
                    if (word.getPOS().equals(POS.NOUN)
                            || word.getPOS().equals(POS.VERB)) {
                        res = SemanticRelations.getHyperString(word.getLemma())
                                .replaceAll("\\[ none \\]", "").trim();
                        if (!res.equals("")) {
                            res = shortenIfRequired(res);
                            bot.send_privmsg(channel, "[w] Parents: " + res);

                            if (isDone(thinkingTime, deduction))
                                return;
                        }
                    }
                    // hyponyms
                    if (word.getPOS().equals(POS.NOUN)) {
                        String hypo = SemanticRelations.getHypoString(
                                word.getLemma()).replaceAll("\\[ none \\]", "")
                                .trim();
                        if (!hypo.equals("")) {
                            hypo = shortenIfRequired(hypo);
                            bot.send_privmsg(channel, "[w] Children: " + hypo);

                            if (isDone(thinkingTime, deduction))
                                return;
                        }
                    }
                    // siblings
                    if (word.getPOS().equals(POS.NOUN)
                            || word.getPOS().equals(POS.VERB)) {
                        res = SemanticRelations.getSiblingsString(
                                word.getLemma()).replaceAll("\\[ none \\]", "")
                                .trim();

                        if (!res.equals("")) {
                            res = shortenIfRequired(res);
                            bot.send_privmsg(channel, "[w] Siblings: " + res);

                            if (isDone(thinkingTime, deduction))
                                return;
                        }
                    }
                    // holo- and meronyms
                    if (word.getPOS().equals(POS.NOUN)) {
                        String hypo = SemanticRelations.getMeroString(
                                word.getLemma()).replaceAll("\\[ none \\]", "")
                                .trim();
                        if (!hypo.equals("")) {
                            hypo = shortenIfRequired(hypo);
                            bot.send_privmsg(channel, "[w] Meronyms (parts): "
                                    + hypo);

                            if (isDone(thinkingTime, deduction))
                                return;
                        }

                        hypo = SemanticRelations.getHoloString(word.getLemma())
                                .replaceAll("\\[ none \\]", "").trim();
                        if (!hypo.equals("")) {
                            hypo = shortenIfRequired(hypo);
                            bot.send_privmsg(channel, "[w] Holonyms (whole): "
                                    + hypo);

                            if (isDone(thinkingTime, deduction))
                                return;
                        }
                    }
                    bot.send_privmsg(channel, "[w] Time over! The word was: "
                            + word.getLemma());
                    bot.wordGameRunning = false;
                    bot.sawGameDone = true;
                } catch (InterruptedException e) {
                    System.out.println("Threads caused trouble!");
                    bot.send_privmsg(channel, "Ooops! Something went wrong!");
View Full Code Here

        try {
            new WNLookup().init("config/file_properties.xml");
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
        IndexWord word = WNLookup.getDict().getRandomIndexWord(toPick);
        // normally, don't use complex words
        boolean condition = word.getLemma().contains(" ");
        // for hard games, use only complex words
        // if(hard)
        // condition = !condition;
//        while (word.getLemma().length() < 4 || condition)
//            word = WNLookup.getDict().getRandomIndexWord(toPick);
View Full Code Here

        String result = new String();
        IndexWordSet words;
        try {
            words = dict.lookupAllIndexWords(originalWord);
            Iterator iter = words.getIndexWordCollection().iterator();
            IndexWord word;
            while (iter.hasNext()) {
                word = (IndexWord) iter.next();
                if (word != null) {
                    result = word.getLemma();
                    return result;
                }
            }
        } catch (JWNLException e) {
            e.printStackTrace();
View Full Code Here

            return false;
        IndexWordSet words;
        try {
            words = dict.lookupAllIndexWords(originalWord);
            Iterator iter = words.getIndexWordCollection().iterator();
            IndexWord word;
            while (iter.hasNext()) {
                word = (IndexWord) iter.next();
                if (word != null) {
                    POS r = word.getPOS();
                    if (r.equals(POS.NOUN) || r.equals(POS.VERB)
                            || r.equals(POS.ADJECTIVE) || r.equals(POS.ADVERB))
                        return true;
                }
            }
View Full Code Here

        String result = new String();
        IndexWordSet words;
        try {
            words = dict.lookupAllIndexWords(originalWord);
            Iterator iter = words.getIndexWordCollection().iterator();
            IndexWord word;
            while (iter.hasNext()) {
                word = (IndexWord) iter.next();
                if (word != null) {
                    result = word.getPOS().getLabel();
                    return result;
                }
            }
        } catch (JWNLException e) {
            e.printStackTrace();
View Full Code Here

        Vector<String> result = new Vector<String>();
        IndexWordSet words;
        try {
            words = WNLookup.getDict().lookupAllIndexWords(s);
            Iterator iter = words.getIndexWordCollection().iterator();
            IndexWord word;
            // TODO mit mehr sem. relationen arbeiten... nett ev kohyponyme aber
            // auch partonyme, oder? das ufert natuerlich auch aus, hat ja nicht
            // alles was miteinander zu tun...
            while (iter.hasNext()) {
                word = (IndexWord) iter.next();
                if (word != null) {
                    // result.add(getWordLabel(word));
                    // for all senses...
                    for (int c = 0; c < word.getSenses().length; c++) {
                        // all hypernyms for the synset:
                        PointerTargetNodeList hyponyms = PointerUtils
                                .getInstance().getDirectHyponyms(
                                        word.getSense(c + 1));
                        result.addAll(getLemmata(hyponyms));
                    }
                }

            }
View Full Code Here

        Vector<Synset> result = new Vector<Synset>();
        IndexWordSet words;
        try {
            words = WNLookup.getDict().lookupAllIndexWords(s);
            Iterator iter = words.getIndexWordCollection().iterator();
            IndexWord word;
            while (iter.hasNext()) {
                word = (IndexWord) iter.next();
                if (word != null) {
                    // for all senses...
                    for (int c = 0; c < word.getSenses().length; c++) {
                        result.add(word.getSense(c + 1));
                    }
                }

            }
        } catch (JWNLException e) {
View Full Code Here

        Vector<String> result = new Vector<String>();
        IndexWordSet words;
        try {
            words = WNLookup.getDict().lookupAllIndexWords(s);
            Iterator iter = words.getIndexWordCollection().iterator();
            IndexWord word;
            while (iter.hasNext()) {
                word = (IndexWord) iter.next();

                String lemma = word.getLemma();
                if (!lemma.toLowerCase().equals(s.toLowerCase()))
                    result.add(lemma);
            }
        } catch (JWNLException e) {
            e.printStackTrace();
View Full Code Here

        Vector<String> result = new Vector<String>();
        IndexWordSet words;
        try {
            words = WNLookup.getDict().lookupAllIndexWords(baseWord);
            Iterator iter = words.getIndexWordCollection().iterator();
            IndexWord word;
            while (iter.hasNext()) {
                word = (IndexWord) iter.next();
                if (word != null) {
                    // result.add(getWordLabel(word));
                    // for all senses...
                    for (int c = 0; c < word.getSenses().length; c++) {
                        // all hypernyms for the synset:
                        PointerTargetNodeList hypernyms = PointerUtils
                                .getInstance().getDirectHypernyms(
                                        word.getSense(c + 1));
                        result.addAll(getLemmata(hypernyms));
                    }
                }

            }
View Full Code Here

TOP

Related Classes of net.didion.jwnl.data.IndexWord

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.