⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 jword.java

📁 AutoSummary uses Natural Language Processing to generate a contextually-relevant synopsis of plain t
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
                            }
                            adverbs.trimToSize();
                        }
                    }
                }
            }
            catch (Exception e)
            {// ignore read errors- they mean the process is done
            }

            // close connection to input stream
            wnOutput.close();
        }
        catch(IOException e)
        {
            // couldn't execute wn command, usually due to incorrect path in config.txt
            System.err.println("Error on exec() method");
            e.printStackTrace();
            System.err.println("Check path to wn program in config.txt");
        }

        // generate POSscores using weighted probability formula
        // need to add heuristics for monosense words, common suffixes, adjacent words
        int tagTally = 0;
        if (nouns != null)
        {
            for (int i=0;i<nouns.size();i++)
            {
                tagTally += ((JSense)nouns.get(i)).getTagCount();
            }
            nounScore = (float)((tagTally/((0.5 * tagTally) + nouns.size())) + nouns.size());
        }
        tagTally = 0;
        if (verbs != null)
        {
            for (int i=0;i<verbs.size();i++)
            {
                tagTally += ((JSense)verbs.get(i)).getTagCount();
            }
            verbScore = (float)((tagTally/((0.5 * tagTally) + verbs.size())) + verbs.size());
        }
        tagTally = 0;
        if (adjectives != null)
        {
            for (int i=0;i<adjectives.size();i++)
            {
                tagTally += ((JSense)adjectives.get(i)).getTagCount();
            }
            adjScore = (float)((tagTally/((0.5 * tagTally) + adjectives.size())) + adjectives.size());
        }
        tagTally = 0;
        if (adverbs != null)
        {
            for (int i=0;i<adverbs.size();i++)
            {
                tagTally += ((JSense)adverbs.get(i)).getTagCount();
            }
            advScore = (float)((tagTally/((0.5 * tagTally) + adverbs.size())) + adverbs.size());
        }
    }

    /**
     * Displays key contents of JWord object formatting like a dictionary entry.  Prints
     * search word, then iterates through the part-of-speech ArrayLists and print the entry
     * for each sense.  Relies heavily on JSense.print().
     *
     * @see                 JSense#print()
     * @since               JWords 0.1.0a
     */
    public void print()
    {
        System.out.println(word);
        if (nouns != null && !nouns.isEmpty())
        {
            System.out.println();
            System.out.println("noun");
            for (int i=0;i<nouns.size();i++)
            {
                ((JSense)nouns.get(i)).print();
            }
        }
        if (verbs != null && !verbs.isEmpty())
        {
            System.out.println();
            System.out.println("verb");
            for (int i=0;i<verbs.size();i++)
            {
                ((JSense)verbs.get(i)).print();
            }
        }
        if (adjectives != null && !adjectives.isEmpty())
        {
            System.out.println();
            System.out.println("adj");
            for (int i=0;i<adjectives.size();i++)
            {
                ((JSense)adjectives.get(i)).print();
            }
        }
        if (adverbs != null && !adverbs.isEmpty())
        {
            System.out.println();
            System.out.println("adv");
            for (int i=0;i<adverbs.size();i++)
            {
                ((JSense)adverbs.get(i)).print();
            }
        }

    }

    /**
     * Retrieves list of noun senses of word.
     *
     * @return          the list of noun senses of the word
     * @since           JWords 0.1.0a
     */
    public ArrayList getNouns()
    {
        return nouns;
    }

    /**
     * Retrieves list of verb senses of word.
     *
     * @return          the list of verb senses of the word
     * @since           JWords 0.1.0a
     */
    public ArrayList getVerbs()
    {
        return verbs;
    }

    /**
     * Retrieves list of adjectives senses of word.
     *
     * @return          the list of adjectives senses of the word
     * @since           JWords 0.1.0a
     */
    public ArrayList getAdjectives()
    {
        return adjectives;
    }

    /**
     * Retrieves list of adverbs senses of word.
     *
     * @return          the list of adverbs senses of the word
     * @since           JWords 0.1.0a
     */
    public ArrayList getAdverbs()
    {
        return adverbs;
    }

    /**
     * Retrieves original search string which references the WordNet entry for this word.
     *
     * @return          original search string cooresponding to the word
     * @since           JWords 0.2.0a
     */
    public String getWord()
    {
        return word;
    }

    /**
     * Retrieves POS score of noun forms of the word calculated using weighted probability formula.
     *
     * @return          POS score of noun forms of the word
     * @since           JWords 0.2.0a
     */
    public float getNounScore()
    {
        return nounScore;
    }

    /**
     * Retrieves POS score of verb forms of the word calculated using weighted probability formula.
     *
     * @return          POS score of verb forms of the word
     * @since           JWords 0.2.0a
     */
    public float getVerbScore()
    {
        return verbScore;
    }

    /**
     * Retrieves POS score of adjective forms of the word calculated using weighted probability formula.
     *
     * @return          POS score of adjective forms of the word
     * @since           JWords 0.2.0a
     */
    public float getAdjScore()
    {
        return adjScore;
    }

    /**
     * Retrieves POS score of adverb forms of the word calculated using weighted probability formula.
     *
     * @return          POS score of adverb forms of the word
     * @since           JWords 0.2.0a
     */
    public float getAdvScore()
    {
        return advScore;
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -