com.aliasi.corpus
Class LineParser<H extends Handler>

java.lang.Object
  extended by com.aliasi.corpus.Parser<H>
      extended by com.aliasi.corpus.InputSourceParser<H>
          extended by com.aliasi.corpus.LineParser<H>
Type Parameters:
H - the type of handler to which this parser sends events
Direct Known Subclasses:
SvmLightClassificationParser

Deprecated. Implement directly.

@Deprecated
public abstract class LineParser<H extends Handler>
extends InputSourceParser<H>

A LineParser provides an abstract adapter for line-based parsing. For each line of the input, the abstract method parseLine(String,int) is called. The newline marker character(s) are not part of the line sent to the line parser method.

The notion of line is defined by BufferedReader.readLine(). As in that method, newlines may be marked by any of the markers in the following table:

MarkerCharacter Sequence
line feed\n
carriage return\r
carriage return, line feed\r\n

The newline marker is not returned as part of the line. Zero-length lines will be included as lines except for the very last line. The following table shows some example:

InputLines
""
"\n" ""
"\n\n" "", ""
"abc" "abc"
"abc\n" "abc"
"abc\rdef" "abc", "def"
"\nabc\rdef\r\n\n" "", "abc", "def", ""

It is up to the line parser method to handle comments, empty lines, and other conditions defined by the particular input format to be parsed.

Since:
LingPipe3.5
Version:
3.9.1
Author:
Bob Carpenter

Constructor Summary
LineParser()
          Deprecated. Construct a line parser without a specified handler.
LineParser(H handler)
          Deprecated. Construct a line parser with the handler set to the specified handler.
 
Method Summary
 void parse(InputSource inSrc)
          Deprecated. Parse the specified input source by converting to a reader and then using a buffered reader to parse out lines.
protected abstract  void parseLine(String line, int lineNumber)
          Deprecated. Handle a line of input.
 
Methods inherited from class com.aliasi.corpus.InputSourceParser
parseString
 
Methods inherited from class com.aliasi.corpus.Parser
getHandler, parse, parse, parseString, setHandler
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LineParser

public LineParser()
Deprecated. 
Construct a line parser without a specified handler. The handler may be set after construction.


LineParser

public LineParser(H handler)
Deprecated. 
Construct a line parser with the handler set to the specified handler. The handler may be reset after construction.

Parameters:
handler - Handler to use.
Method Detail

parse

public void parse(InputSource inSrc)
           throws IOException
Deprecated. 
Parse the specified input source by converting to a reader and then using a buffered reader to parse out lines.

The reader or input stream from the input source will be closed before this method exits.

Specified by:
parse in class Parser<H extends Handler>
Parameters:
inSrc - Input source from which to extract a reader.
Throws:
IOException - If there is an underlying I/O error from the input source's input stream or reader.

parseLine

protected abstract void parseLine(String line,
                                  int lineNumber)
Deprecated. 
Handle a line of input. The end-of-line characters are not included in the line.

Parameters:
line - Line to parse.
lineNumber - Line number being parsed.