Java Reference
In-Depth Information
CharacterOffsetEnd=73] [Text=. CharacterOffsetBegin=73
CharacterOffsetEnd=74]
Alternatively, we can use the
xmlPrint
method. This will produce the output in XML
format, which can often be easier for extracting the information of interest. This method is
shown here, and it requires that the
IOException
be handled:
try {
pipeline.xmlPrint(annotation, System.out);
} catch (IOException ex) {
// Handle exception
}
A partial listing of the output is as follows:
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="CoreNLP-to-HTML.xsl" type="text/
xsl"?>
<root>
<document>
<sentences>
<sentence id="1">
<tokens>
<token id="1">
<word>When</word>
<CharacterOffsetBegin>0</CharacterOffsetBegin>
<CharacterOffsetEnd>4</CharacterOffsetEnd>
</token>
...
<token id="34">
<word>...</word>
<CharacterOffsetBegin>316</CharacterOffsetBegin>
<CharacterOffsetEnd>317</CharacterOffsetEnd>
</token>
</tokens>
</sentence>
</sentences>
</document>
</root>