edu.stanford.nlp.wordseg
Class Sighan2005DocumentReaderAndWriter

java.lang.Object
  extended by edu.stanford.nlp.wordseg.Sighan2005DocumentReaderAndWriter
All Implemented Interfaces:
IteratorFromReaderFactory<java.util.List<CoreLabel>>, DocumentReaderAndWriter<CoreLabel>, LatticeWriter<CoreLabel>, java.io.Serializable

public class Sighan2005DocumentReaderAndWriter
extends java.lang.Object
implements DocumentReaderAndWriter<CoreLabel>, LatticeWriter<CoreLabel>

DocumentReader for Chinese segmentation task. (Sighan bakeoff 2005) Reads in characters and labels them as 1 or 0 (word START or NONSTART).

Note: maybe this can do less interning, since some is done in ObjectBankWrapper, but this also calls trim() as it works....

Author:
Pi-Chuan Chang, Michel Galley (Viterbi seearch graph printing)
See Also:
Serialized Form

Nested Class Summary
 class Sighan2005DocumentReaderAndWriter.CTBDocumentParser
           
 
Constructor Summary
Sighan2005DocumentReaderAndWriter()
           
 
Method Summary
 java.util.Iterator<java.util.List<CoreLabel>> getIterator(java.io.Reader r)
          Return an iterator over the contents read from r.
 void init(SeqClassifierFlags flags)
          This will be called immediately after construction.
 void printAnswers(java.util.List<CoreLabel> doc, java.io.PrintWriter pw)
          This method prints the output of the classifier to a PrintWriter.
 void printLattice(DFSA tagLattice, java.util.List<CoreLabel> doc, java.io.PrintWriter out)
          This method prints the output lattice (typically, Viterbi search graph) of the classifier to a PrintWriter.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Sighan2005DocumentReaderAndWriter

public Sighan2005DocumentReaderAndWriter()
Method Detail

getIterator

public java.util.Iterator<java.util.List<CoreLabel>> getIterator(java.io.Reader r)
Description copied from interface: IteratorFromReaderFactory
Return an iterator over the contents read from r.

Specified by:
getIterator in interface IteratorFromReaderFactory<java.util.List<CoreLabel>>
Parameters:
r - Where to read objects from
Returns:
An Iterator over the objects

init

public void init(SeqClassifierFlags flags)
Description copied from interface: DocumentReaderAndWriter
This will be called immediately after construction. It's easier having an init() method because DocumentReaderAndWriter objects are usually created using reflection.

Specified by:
init in interface DocumentReaderAndWriter<CoreLabel>
Parameters:
flags - Flags specifying behavior

printAnswers

public void printAnswers(java.util.List<CoreLabel> doc,
                         java.io.PrintWriter pw)
Description copied from interface: DocumentReaderAndWriter
This method prints the output of the classifier to a PrintWriter.

Specified by:
printAnswers in interface DocumentReaderAndWriter<CoreLabel>
Parameters:
doc - The document which has answers (it has been classified)
pw - Where to send the output

printLattice

public void printLattice(DFSA tagLattice,
                         java.util.List<CoreLabel> doc,
                         java.io.PrintWriter out)
Description copied from interface: LatticeWriter
This method prints the output lattice (typically, Viterbi search graph) of the classifier to a PrintWriter.

Specified by:
printLattice in interface LatticeWriter<CoreLabel>


Stanford NLP Group