public class PlainTextDocumentReaderAndWriter<IN extends CoreMap> extends Object implements DocumentReaderAndWriter<IN>
Implementation note: see
itest/src/edu/stanford/nlp/ie/crf/CRFClassifierITest.java for examples and
test cases for the output options.
This class works over a list of anything that extends CoreMap
.
The usual case is CoreLabel
.
Modifier and Type | Class and Description |
---|---|
static class |
PlainTextDocumentReaderAndWriter.OutputStyle |
Constructor and Description |
---|
PlainTextDocumentReaderAndWriter()
Construct a PlainTextDocumentReaderAndWriter.
|
Modifier and Type | Method and Description |
---|---|
String |
getAnswers(List<IN> l,
PlainTextDocumentReaderAndWriter.OutputStyle outputStyle,
boolean preserveSpacing) |
Iterator<List<IN>> |
getIterator(Reader r)
Return an iterator over the contents read from r.
|
void |
init(SeqClassifierFlags flags)
This will be called immediately after construction.
|
void |
init(SeqClassifierFlags flags,
TokenizerFactory<IN> tokenizerFactory) |
void |
printAnswers(List<IN> list,
PrintWriter out)
Print the classifications for the document to the given Writer.
|
void |
printAnswers(List<IN> l,
PrintWriter out,
PlainTextDocumentReaderAndWriter.OutputStyle outputStyle,
boolean preserveSpacing) |
public PlainTextDocumentReaderAndWriter()
public void init(SeqClassifierFlags flags)
DocumentReaderAndWriter
init
in interface DocumentReaderAndWriter<IN extends CoreMap>
flags
- Flags specifying behaviorpublic void init(SeqClassifierFlags flags, TokenizerFactory<IN> tokenizerFactory)
public Iterator<List<IN>> getIterator(Reader r)
IteratorFromReaderFactory
getIterator
in interface IteratorFromReaderFactory<List<IN extends CoreMap>>
r
- Where to read objects frompublic void printAnswers(List<IN> list, PrintWriter out)
outputFormat
property, and can print in
slashTags, inlineXML, xml (stand-Off XML), tsv, or a 3-column tabbed format
for easy entity retrieval. For both the XML output
formats, it preserves spacing, while for the other formats, it prints
tokenized (since preserveSpacing output is somewhat dysfunctional with these
formats, but you can control this by calling getAnswers()).printAnswers
in interface DocumentReaderAndWriter<IN extends CoreMap>
list
- List of tokens with classifier answersout
- Where to print the output topublic String getAnswers(List<IN> l, PlainTextDocumentReaderAndWriter.OutputStyle outputStyle, boolean preserveSpacing)
public void printAnswers(List<IN> l, PrintWriter out, PlainTextDocumentReaderAndWriter.OutputStyle outputStyle, boolean preserveSpacing)