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

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

Introduction

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

Prototype

@Override
public String value() 

Source Link

Document

Return the word value of the label (or null if none).

Usage

From source file:org.lambda3.text.simplification.discourse.utils.words.WordsUtils.java

License:Open Source License

public static Word lemmatize(Word word) {
    Sentence sentence = new Sentence(word.value());
    return new Word(sentence.lemma(0));
}

From source file:org.lambda3.text.simplification.discourse.utils.words.WordsUtils.java

License:Open Source License

private static Word capitalizeWord(Word word) {
    String s = word.value();
    if (s.length() > 0) {
        s = s.substring(0, 1).toUpperCase() + s.substring(1);
    }/*w  w  w . j  a va  2  s .co  m*/

    return new Word(s);
}

From source file:org.lambda3.text.simplification.discourse.utils.words.WordsUtils.java

License:Open Source License

public static Word lowercaseWord(Word word) {
    return new Word(word.value().toLowerCase());
}

From source file:org.lambda3.text.simplification.discourse.utils.words.WordsUtils.java

License:Open Source License

private static List<Word> wordsToProperSentence(List<Word> words) {
    List<Word> res = new ArrayList<>();
    res.addAll(words);/* w w w  . ja va2  s . co m*/

    // trim '.' and ',' at beginning and the end and remove multiple, consecutive occurrences
    for (String c : Arrays.asList(".", ",")) {
        Word prev = null;
        Iterator<Word> it = res.iterator();
        while (it.hasNext()) {
            Word word = it.next();
            if (word.value().equals(c)) {
                if (prev == null || prev.value().equals(word.value())) {
                    it.remove();
                }
            }
            prev = word;
        }
        if ((!res.isEmpty()) && (res.get(res.size() - 1).value().equals(c))) {
            res.remove(res.size() - 1);
        }
    }

    // add a '.' at the end
    res.add(new Word("."));

    // capitalize first word
    if (!res.isEmpty()) {
        res.set(0, capitalizeWord(res.get(0)));
    }

    return res;
}