Example usage for edu.stanford.nlp.ling CoreLabel TAG_SEPARATOR

List of usage examples for edu.stanford.nlp.ling CoreLabel TAG_SEPARATOR

Introduction

In this page you can find the example usage for edu.stanford.nlp.ling CoreLabel TAG_SEPARATOR.

Prototype

String TAG_SEPARATOR

To view the source code for edu.stanford.nlp.ling CoreLabel TAG_SEPARATOR.

Click Source Link

Document

Tag separator to use by default

Usage

From source file:opennlp.tools.parse_thicket.opinion_processor.DefaultSentimentProcessor.java

License:Apache License

public static <T> String wordToString(T o, final boolean justValue, final String separator) {
    if (justValue && o instanceof Label) {
        if (o instanceof CoreLabel) {
            CoreLabel l = (CoreLabel) o;
            String w = l.value();
            if (w == null)
                w = l.word();//from w  w w .jav a2 s.  co  m
            return w;
        } else {
            return (((Label) o).value());
        }
    } else if (o instanceof CoreLabel) {
        CoreLabel l = ((CoreLabel) o);
        String w = l.value();
        if (w == null)
            w = l.word();
        if (l.tag() != null) {
            if (separator == null) {
                return w + CoreLabel.TAG_SEPARATOR + l.tag();
            } else {
                return w + separator + l.tag();
            }
        }
        return w;
        // an interface that covered these next four cases would be
        // nice, but we're moving away from these data types anyway
    } else if (separator != null && o instanceof TaggedWord) {
        return ((TaggedWord) o).toString(separator);
    } else if (separator != null && o instanceof LabeledWord) {
        return ((LabeledWord) o).toString();
    } else if (separator != null && o instanceof WordLemmaTag) {
        return ((WordLemmaTag) o).toString(separator);
    } else if (separator != null && o instanceof WordTag) {
        return ((WordTag) o).toString(separator);
    } else {
        return (o.toString());
    }
}