corpora.markup
Class Marker

java.lang.Object
  |
  +--corpora.markup.Marker
Direct Known Subclasses:
PoetryMarker, ProsaMarker

public class Marker
extends java.lang.Object


Constructor Summary
Marker()
          Initialises auto-marker workspace.
 
Method Summary
 boolean closeUntil(java.io.BufferedWriter xmlBuffer, java.lang.String element, boolean include)
          Closes all opened stack elements until given element.
 int countElement(java.lang.String element)
          Counts each opened element in structure tree that matches the given element.
 java.io.BufferedWriter createLog(java.lang.String logFile)
          Creates log file of automatic structuring and marking process.
 java.io.BufferedWriter createXML(java.lang.String xmlFile, java.lang.String dtd)
          Creates transformation file that will contain marked text.
 java.io.BufferedReader getConfig(java.lang.String configFile)
          Opens auto-marker configuration file.
 java.io.BufferedReader getSource(java.lang.String srcFile)
          Opens source file - text to be structured and marked.
 void openElement(java.io.BufferedWriter xmlBuffer, java.lang.String element)
          Writes opening element into transformation file and pushes it into stack.
 java.lang.String readSource(java.io.BufferedReader srcBuffer)
          Reads current row of source file.
 java.lang.String topElement()
          Returns last opened element name.
 void writeLog(java.io.BufferedWriter logBuffer, java.lang.String type, java.lang.String text)
          Writes record of problem event in log file.
 void writeXML(java.io.BufferedWriter xmlBuffer, java.lang.String xmlRecord, int newLines)
          Writes marked string in transformation file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Marker

public Marker()
Initialises auto-marker workspace.

Method Detail

closeUntil

public boolean closeUntil(java.io.BufferedWriter xmlBuffer,
                          java.lang.String element,
                          boolean include)
                   throws java.lang.Exception
Closes all opened stack elements until given element.

Parameters:
xmlBuffer - buffered writer of transformation file.
element - the given element - element to close until.
include - if set to 'true' closes all element including the given one, otherwise closes until the given element.
Returns:
true if the given element was found; false otherwise (closing didn't processed).
java.lang.Exception

countElement

public int countElement(java.lang.String element)
Counts each opened element in structure tree that matches the given element.

Parameters:
element - matcher element.
Returns:
the resulting count; the return value 0 indicates that the element is not opened.

createLog

public java.io.BufferedWriter createLog(java.lang.String logFile)
                                 throws java.lang.Exception
Creates log file of automatic structuring and marking process.

Parameters:
logFile - log file name without extension (i.e. 'log_collection').
Returns:
buffered writer of log file.
java.lang.Exception

createXML

public java.io.BufferedWriter createXML(java.lang.String xmlFile,
                                        java.lang.String dtd)
                                 throws java.lang.Exception
Creates transformation file that will contain marked text.

Parameters:
xmlFile - transformation file name without extension (i.e. 'collection')
Returns:
buffered writer of transformation file.
java.lang.Exception

getConfig

public java.io.BufferedReader getConfig(java.lang.String configFile)
                                 throws java.lang.Exception
Opens auto-marker configuration file.

Parameters:
configFile - configuration file name with extension (i.e. 'config.xml').
Returns:
buffered reader of configuration file.
java.lang.Exception

getSource

public java.io.BufferedReader getSource(java.lang.String srcFile)
                                 throws java.lang.Exception
Opens source file - text to be structured and marked.

Returns:
buffered reader of source file.
java.lang.Exception

openElement

public void openElement(java.io.BufferedWriter xmlBuffer,
                        java.lang.String element)
                 throws java.lang.Exception
Writes opening element into transformation file and pushes it into stack.

Parameters:
xmlBuffer - buffered writer of transformation file.
element - element name (string) to open.
java.lang.Exception

readSource

public java.lang.String readSource(java.io.BufferedReader srcBuffer)
                            throws java.lang.Exception
Reads current row of source file.

Returns:
current row of source file.
java.lang.Exception

topElement

public java.lang.String topElement()
Returns last opened element name.

Returns:
string that represents last opened element name.

writeXML

public void writeXML(java.io.BufferedWriter xmlBuffer,
                     java.lang.String xmlRecord,
                     int newLines)
              throws java.lang.Exception
Writes marked string in transformation file.

Parameters:
xmlBuffer - buffered writer of transformation file.
xmlRecord - string (includes one-line opening-closing xml tags, that doesn't need openElement method) to write in transformation file.
newLines - count of actual new lines to write in transformation file (i.e. count of '\r\n').
java.lang.Exception

writeLog

public void writeLog(java.io.BufferedWriter logBuffer,
                     java.lang.String type,
                     java.lang.String text)
              throws java.lang.Exception
Writes record of problem event in log file.

Parameters:
logBuffer - buffered writer of log file.
type - type of log record (title).
text - text string of log record.
java.lang.Exception