gate.creole.annic
Class Parser

java.lang.Object
  extended by gate.creole.annic.Parser

public class Parser
extends Object

This class provides utility methods to export the Hits to XML and read them back from XML to HIT objects.

Author:
niraj

Field Summary
static String ANNOTATION_SET_NAME
          ANNOTATION_SET_NAME XML Element
static String DOC_ID
          DOC_ID XML Element
static String END
          END XML Element
static String END_OFFSET
          END_OFFSET XML Element
static String FEATURE
          FEATURE XML Element
static String FEATURES
          FEATURES XML Element
static String HIT
          HIT XML Element
static String HITS
          HITS XML Element
static String KEY
          KEY XML Element
static String LEFT_CONTEXT_START_OFFSET
          LEFT_CONTEXT_START_OFFSET XML Element
static String PATTERN_ANNOTATION
          PATTERN_ANNOTATION XML Element
static String PATTERN_ANNOTATIONS
          PATTERN_ANNOTATIONS XML Element
static String PATTERN_TEXT
          PATTERN_TEXT XML Element
static String POSITION
          POSITION XML Element
static String QUERY
          QUERY XML Element
static String RIGHT_CONTEXT_END_OFFSET
          RIGHT_CONTEXT_END_OFFSET XML Element
static String START
          START XML Element
static String START_OFFSET
          START_OFFSET XML Element
static String TEXT
          TEXT XML Element
static String TYPE
          TYPE XML Element
static String VALUE
          VALUE XML Element
 
Constructor Summary
Parser()
           
 
Method Summary
static Hit[] fromXML(String xml)
          Given xml representation of HIT converts them into an array of hits
static String replaceAmpChars(String s)
          This method replaces all the special characters (invalid xml characters) with their respective legal sequences.
static String toXML(Hit[] hits)
          Given an array of instances of Hit, this method returns an xml representation of the Hit
static String wrap(String elementText, boolean startElement)
          wraps the element into the following format
static String wrap(String elementText, int elementValue)
          wraps the element into the following format
static String wrap(String elementText, String elementValue)
          wraps the element into the following format
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

HITS

public static final String HITS
HITS XML Element

See Also:
Constant Field Values

HIT

public static final String HIT
HIT XML Element

See Also:
Constant Field Values

DOC_ID

public static final String DOC_ID
DOC_ID XML Element

See Also:
Constant Field Values

ANNOTATION_SET_NAME

public static final String ANNOTATION_SET_NAME
ANNOTATION_SET_NAME XML Element

See Also:
Constant Field Values

START_OFFSET

public static final String START_OFFSET
START_OFFSET XML Element

See Also:
Constant Field Values

END_OFFSET

public static final String END_OFFSET
END_OFFSET XML Element

See Also:
Constant Field Values

QUERY

public static final String QUERY
QUERY XML Element

See Also:
Constant Field Values

LEFT_CONTEXT_START_OFFSET

public static final String LEFT_CONTEXT_START_OFFSET
LEFT_CONTEXT_START_OFFSET XML Element

See Also:
Constant Field Values

RIGHT_CONTEXT_END_OFFSET

public static final String RIGHT_CONTEXT_END_OFFSET
RIGHT_CONTEXT_END_OFFSET XML Element

See Also:
Constant Field Values

PATTERN_TEXT

public static final String PATTERN_TEXT
PATTERN_TEXT XML Element

See Also:
Constant Field Values

PATTERN_ANNOTATIONS

public static final String PATTERN_ANNOTATIONS
PATTERN_ANNOTATIONS XML Element

See Also:
Constant Field Values

PATTERN_ANNOTATION

public static final String PATTERN_ANNOTATION
PATTERN_ANNOTATION XML Element

See Also:
Constant Field Values

START

public static final String START
START XML Element

See Also:
Constant Field Values

END

public static final String END
END XML Element

See Also:
Constant Field Values

TEXT

public static final String TEXT
TEXT XML Element

See Also:
Constant Field Values

TYPE

public static final String TYPE
TYPE XML Element

See Also:
Constant Field Values

POSITION

public static final String POSITION
POSITION XML Element

See Also:
Constant Field Values

FEATURES

public static final String FEATURES
FEATURES XML Element

See Also:
Constant Field Values

FEATURE

public static final String FEATURE
FEATURE XML Element

See Also:
Constant Field Values

KEY

public static final String KEY
KEY XML Element

See Also:
Constant Field Values

VALUE

public static final String VALUE
VALUE XML Element

See Also:
Constant Field Values
Constructor Detail

Parser

public Parser()
Method Detail

toXML

public static String toXML(Hit[] hits)
Given an array of instances of Hit, this method returns an xml representation of the Hit

Parameters:
hits -
Returns:

replaceAmpChars

public static String replaceAmpChars(String s)
This method replaces all the special characters (invalid xml characters) with their respective legal sequences. These includes &, <, >, \ and '.

Parameters:
s -
Returns:

fromXML

public static Hit[] fromXML(String xml)
                     throws IOException,
                            org.jdom.JDOMException
Given xml representation of HIT converts them into an array of hits

Parameters:
xml -
Returns:
Throws:
IOException
org.jdom.JDOMException

wrap

public static String wrap(String elementText,
                          String elementValue)
wraps the element into the following format

Parameters:
elementText -
elementValue -
Returns:
elementValue\n

wrap

public static String wrap(String elementText,
                          int elementValue)
wraps the element into the following format

Parameters:
elementText -
elementValue -
Returns:
elementValue\n

wrap

public static String wrap(String elementText,
                          boolean startElement)
wraps the element into the following format

Parameters:
elementText -
startElement -
Returns:
"<" + (startElement ? "" : "/") + elementText + ">\n";