Example usage for edu.stanford.nlp.util XMLUtils escapeTextAroundXMLTags

List of usage examples for edu.stanford.nlp.util XMLUtils escapeTextAroundXMLTags

Introduction

In this page you can find the example usage for edu.stanford.nlp.util XMLUtils escapeTextAroundXMLTags.

Prototype

public static String escapeTextAroundXMLTags(String s) 

Source Link

Usage

From source file:final_dissertation.POStag.java

public static String getXMLWords(ArrayList<TaggedWord> taggedSentence, int sentNum) {
    StringBuilder sb = new StringBuilder();
    sb.append(System.lineSeparator());
    sb.append("<").append(XMLUtils.escapeTextAroundXMLTags("sentence")).append(" id=\"")
            .append(XMLUtils.escapeAttributeXML("" + sentNum)).append("\">");
    sb.append(System.lineSeparator());
    int sz = ((List) taggedSentence).size();
    for (int i = 0; i < sz; i++) {
        String word = ((HasWord) ((List) taggedSentence).get(i)).word();
        String tag = ((TaggedWord) ((List) taggedSentence).get(i)).tag();
        sb.append("<").append(XMLUtils.escapeTextAroundXMLTags("word")).append(" wid=\"")
                .append(XMLUtils.escapeAttributeXML("" + i)).append("\"").append(" pos=\"")
                .append(XMLUtils.escapeAttributeXML(tag)).append("\">").append(XMLUtils.escapeElementXML(word))
                .append("<").append(XMLUtils.escapeTextAroundXMLTags("/word")).append(">")
                .append(System.lineSeparator());
    }/* w  w w.j ava2s  .c  om*/
    sb.append("<").append(XMLUtils.escapeXML("/sentence")).append(">");
    return sb.toString();
}