Example usage for edu.stanford.nlp.ling WordTag word

List of usage examples for edu.stanford.nlp.ling WordTag word

Introduction

In this page you can find the example usage for edu.stanford.nlp.ling WordTag word.

Prototype

String word

To view the source code for edu.stanford.nlp.ling WordTag word.

Click Source Link

Usage

From source file:classify.Classify.java

private static HashMap prePro(String input) throws IOException {
    File in = new File(input);
    HashMap hm = new HashMap();
    vn.hus.nlp.sd.SentenceDetector st = new SentenceDetector("models\\sentDetection\\VietnameseSD.bin.gz");
    String s[] = st.detectSentences(input);
    VietnameseMaxentTagger tagger = new VietnameseMaxentTagger();
    for (String t : s) {

        if (isConsortium(in)) {
            List<WordTag> li = tagger.tagText2(Convert.convertFromConsortiumToNormal(t));
        }//from   w w w. j  a  v  a2s.co m
        List<WordTag> li = tagger.tagText2(t);
        for (WordTag l : li) {
            String word = l.word().replaceAll(" ", "_");
            String tag = l.tag();
            if (check_word(word) && check_tag(tag)) {
                if (hm.containsKey(word)) {
                    int number = (int) hm.get(word);
                    hm.put(word, number + 1);
                } else {
                    hm.put(word, 1);
                }
            }
        }

    }

    return hm;
}

From source file:classify.Classify.java

private static HashMap prePro_string(String input) throws IOException {

    HashMap hm = new HashMap();
    vn.hus.nlp.sd.SentenceDetector st = new SentenceDetector("models\\sentDetection\\VietnameseSD.bin.gz");
    String s[] = st.detectSentences(input);
    VietnameseMaxentTagger tagger = new VietnameseMaxentTagger();
    for (String t : s) {

        List<WordTag> li = tagger.tagText2(t);
        for (WordTag l : li) {
            String word = l.word().replaceAll(" ", "_");
            String tag = l.tag();
            if (check_word(word) && check_tag(tag)) {
                if (hm.containsKey(word)) {
                    int number = (int) hm.get(word);
                    hm.put(word, number + 1);
                } else {
                    hm.put(word, 1);/*from  w ww .  j  a  va 2  s .  c  o  m*/
                }
            }
        }

    }

    return hm;
}