Example usage for edu.stanford.nlp.ling Word setWord

List of usage examples for edu.stanford.nlp.ling Word setWord

Introduction

In this page you can find the example usage for edu.stanford.nlp.ling Word setWord.

Prototype

@Override
    public void setWord(String word) 

Source Link

Usage

From source file:org.linuxkernel.proof.digger.questiontypeanalysis.patternbased.MainPartExtracter.java

License:Open Source License

/**
 * ???/* w w  w  . j  a v a  2  s. c o m*/
 *
 * @param question 
 * @param questionWords ??
 * @return 
 */
public QuestionStructure getMainPart(String question, String questionWords) {
    List<Word> words = new ArrayList<>();
    String[] qw = questionWords.split("\\s+");
    for (String item : qw) {
        item = item.trim();
        if ("".equals(item)) {
            continue;
        }
        Word word = new Word();
        word.setWord(item.trim());
        words.add(word);
    }
    return getMainPart(question, words);
}

From source file:qmul.util.parse.PennTreebankTokenizer.java

License:Open Source License

/**
 * @param s/* w  ww .  j a  v  a2s. c om*/
 * @return a list of tokens "hello, bob." -> "[hello, ,, bob, .]"
 */
public List<Word> getWordsFromString(String s) {
    if (splitPennAbbreviations) {
        s = s.replaceAll("(\\w+)([.,?!;:])(\\s+|$)", "$1 $2");
    }
    List<Word> words = dp.getWordsFromString(s);
    for (Word w : words) {
        // Penn tokeniser transforms "a/b" into "a\/b"
        if (w.word().contains("/")) {
            w.setWord(w.word().replaceAll("\\\\/", "/"));
        }
    }
    return words;
}