Search in sources :

Example 1 with TransformXML

use of edu.stanford.nlp.process.TransformXML in project CoreNLP by stanfordnlp.

the class MaxentTagger method tagFromXML.

/**
   * Uses an XML transformer to turn an input stream into a bunch of
   * output.  Tags all of the text between xmlTags.
   *
   * The difference between using this and using runTagger in XML mode
   * is that this preserves the XML structure outside of the list of
   * elements to tag, whereas the runTagger method throws away all of
   * the surrounding structure and returns tagged plain text.
   */
public void tagFromXML(InputStream input, Writer writer, String... xmlTags) {
    OutputStyle outputStyle = OutputStyle.fromShortName(config.getOutputFormat());
    TransformXML<String> txml = new TransformXML<>();
    switch(outputStyle) {
        case XML:
        case INLINE_XML:
            txml.transformXML(xmlTags, new TaggerWrapper(this), input, writer, new TransformXML.NoEscapingSAXInterface<>());
            break;
        case SLASH_TAGS:
        case TSV:
            txml.transformXML(xmlTags, new TaggerWrapper(this), input, writer, new TransformXML.SAXInterface<>());
            break;
        default:
            throw new RuntimeException("Unexpected format " + outputStyle);
    }
}
Also used : TransformXML(edu.stanford.nlp.process.TransformXML) OutputStyle(edu.stanford.nlp.sequences.PlainTextDocumentReaderAndWriter.OutputStyle)

Example 2 with TransformXML

use of edu.stanford.nlp.process.TransformXML in project CoreNLP by stanfordnlp.

the class MaxentTagger method tagFromXML.

public void tagFromXML(Reader input, Writer writer, String... xmlTags) {
    OutputStyle outputStyle = OutputStyle.fromShortName(config.getOutputFormat());
    TransformXML<String> txml = new TransformXML<>();
    switch(outputStyle) {
        case XML:
        case INLINE_XML:
            txml.transformXML(xmlTags, new TaggerWrapper(this), input, writer, new TransformXML.NoEscapingSAXInterface<>());
            break;
        case SLASH_TAGS:
        case TSV:
            txml.transformXML(xmlTags, new TaggerWrapper(this), input, writer, new TransformXML.SAXInterface<>());
            break;
        default:
            throw new RuntimeException("Unexpected format " + outputStyle);
    }
}
Also used : TransformXML(edu.stanford.nlp.process.TransformXML) OutputStyle(edu.stanford.nlp.sequences.PlainTextDocumentReaderAndWriter.OutputStyle)

Aggregations

TransformXML (edu.stanford.nlp.process.TransformXML)2 OutputStyle (edu.stanford.nlp.sequences.PlainTextDocumentReaderAndWriter.OutputStyle)2