Class OntologyParser

java.lang.Object
  extended by org.xml.sax.helpers.DefaultHandler
      extended by OntologyParser
All Implemented Interfaces:
org.xml.sax.ContentHandler, org.xml.sax.DTDHandler, org.xml.sax.EntityResolver, org.xml.sax.ErrorHandler

public class OntologyParser
extends org.xml.sax.helpers.DefaultHandler

This class is assisting TQL in the extraction of events. It holds a list of words that are of some importance ("buzzwords"). Such buzzword may have significance when discovered in a cruical position in TQL.

See Also:
TQL

Field Summary
 java.lang.String[] clues
           
 java.lang.String currClass
           
 boolean debug_op
           
 boolean debug_op_2
           
 java.io.File file
           
 OntologyParser handler
           
 java.util.HashMap<java.lang.String,java.lang.String> onto
           
 boolean subclass
           
 
Constructor Summary
OntologyParser()
          An ontologyparser without a ontology (yet).
OntologyParser(java.lang.String filepath)
          An ontologyparser with a predefined ontology.
 
Method Summary
 void characters(char[] buf, int offset, int len)
          The string between tags (usually empty) is processed by this method.
 void emit(java.lang.String s)
           
 void endDocument()
          XML-parsing function for end of parsing.\ It has no function but to inform the user of parser completion.
 void endElement(java.lang.String namespaceURI, java.lang.String sName, java.lang.String qName)
          This method completes the action of startElement, namely unsets references that has been set, and adding items to misc lists.
 boolean isBuzzAdjective(java.lang.String s)
          Wrapper method to mid-levelly check if an adjective has some significance.\ This method is tentative.
 boolean isBuzzNoun(java.lang.String s)
          Wrapper method to low-levelly check if a word has some significance.
 boolean isBuzzVerb(java.lang.String s)
          Wrapper method to low-levelly check if a word has some significance.
 boolean isBuzzWord(java.lang.String s)
          Wrapper method to mid-levelly check if a word has some significance.
 boolean isClueWord(java.lang.String s)
          Wrapper method to low-levelly check if a word has some significance.
 boolean isInOntology(java.lang.String s)
          Wrapper method to high-levelly check if a word has some significance.
 boolean isOfClass(java.lang.String i, java.lang.String c)
          Checks if a word (noun, verb) is of a certain class in the ontology.
static void main(java.lang.String[] args)
          An onologyparser may be started from the command line to verify the correctness of an ontology.\ Thus it has a main-method.
 void makeParser(java.lang.String filepath)
          Makes a parser, and invokes parsing if there is a defined ontology file.
 java.lang.String rmH(java.lang.String s)
          This method removes a hash (#) occuring at the start of a string.
 void startDocument()
          XML-parsing function for start of parsing, but it has no function.
 void startElement(java.lang.String namespaceURI, java.lang.String sName, java.lang.String qName, org.xml.sax.Attributes attrs)
          Called when the parser find a new starting tag.
 
Methods inherited from class org.xml.sax.helpers.DefaultHandler
endPrefixMapping, error, fatalError, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, setDocumentLocator, skippedEntity, startPrefixMapping, unparsedEntityDecl, warning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

file

public java.io.File file

handler

public OntologyParser handler

subclass

public boolean subclass

currClass

public java.lang.String currClass

onto

public java.util.HashMap<java.lang.String,java.lang.String> onto

debug_op

public boolean debug_op

debug_op_2

public boolean debug_op_2

clues

public java.lang.String[] clues
Constructor Detail

OntologyParser

public OntologyParser(java.lang.String filepath)
An ontologyparser with a predefined ontology.

Parameters:
filepath - path to the ontology file

OntologyParser

public OntologyParser()
An ontologyparser without a ontology (yet).

Method Detail

main

public static void main(java.lang.String[] args)
An onologyparser may be started from the command line to verify the correctness of an ontology.\ Thus it has a main-method.


makeParser

public void makeParser(java.lang.String filepath)
Makes a parser, and invokes parsing if there is a defined ontology file.

Parameters:
filepath - path to the ontology file

isOfClass

public boolean isOfClass(java.lang.String i,
                         java.lang.String c)
Checks if a word (noun, verb) is of a certain class in the ontology. If the word is found, but of different class, it recurses upward in the ontology.

Parameters:
i - the noun or verb
c - the class
Returns:
a boolean indicating if the noun or verb is of class

isInOntology

public boolean isInOntology(java.lang.String s)
Wrapper method to high-levelly check if a word has some significance.

Parameters:
s - the word
Returns:
wether the word is significant or not
See Also:
isBuzzWord(String), isClueWord(String)

isBuzzWord

public boolean isBuzzWord(java.lang.String s)
Wrapper method to mid-levelly check if a word has some significance.

Parameters:
s - the word
Returns:
wether the word is significant or not
See Also:
isBuzzNoun(String), isBuzzVerb(String)

isBuzzAdjective

public boolean isBuzzAdjective(java.lang.String s)
Wrapper method to mid-levelly check if an adjective has some significance.\ This method is tentative.

Parameters:
s - the word
Returns:
wether the word is significant or not

isBuzzVerb

public boolean isBuzzVerb(java.lang.String s)
Wrapper method to low-levelly check if a word has some significance.

Parameters:
s - the word
Returns:
wether the word is significant or not

isBuzzNoun

public boolean isBuzzNoun(java.lang.String s)
Wrapper method to low-levelly check if a word has some significance.

Parameters:
s - the word
Returns:
wether the word is significant or not

isClueWord

public boolean isClueWord(java.lang.String s)
Wrapper method to low-levelly check if a word has some significance.

Parameters:
s - the word
Returns:
wether the word is significant or not

startDocument

public void startDocument()
XML-parsing function for start of parsing, but it has no function.

Specified by:
startDocument in interface org.xml.sax.ContentHandler
Overrides:
startDocument in class org.xml.sax.helpers.DefaultHandler

endDocument

public void endDocument()
XML-parsing function for end of parsing.\ It has no function but to inform the user of parser completion.

Specified by:
endDocument in interface org.xml.sax.ContentHandler
Overrides:
endDocument in class org.xml.sax.helpers.DefaultHandler

startElement

public void startElement(java.lang.String namespaceURI,
                         java.lang.String sName,
                         java.lang.String qName,
                         org.xml.sax.Attributes attrs)
                  throws org.xml.sax.SAXException
Called when the parser find a new starting tag. This tag is matched against a number of clauses, i.e. sentence, term, event .. If no mathcing clause is found, the tag is ignored. This method sets data according to which tag has been discovered.

Specified by:
startElement in interface org.xml.sax.ContentHandler
Overrides:
startElement in class org.xml.sax.helpers.DefaultHandler
Throws:
org.xml.sax.SAXException
See Also:
endElement(String, String, String)

endElement

public void endElement(java.lang.String namespaceURI,
                       java.lang.String sName,
                       java.lang.String qName)
                throws org.xml.sax.SAXException
This method completes the action of startElement, namely unsets references that has been set, and adding items to misc lists.

Specified by:
endElement in interface org.xml.sax.ContentHandler
Overrides:
endElement in class org.xml.sax.helpers.DefaultHandler
Throws:
org.xml.sax.SAXException
See Also:
startElement(String, String, String, Attributes)

characters

public void characters(char[] buf,
                       int offset,
                       int len)
                throws org.xml.sax.SAXException
The string between tags (usually empty) is processed by this method. It is only used to to set PMID of abstracts.

Specified by:
characters in interface org.xml.sax.ContentHandler
Overrides:
characters in class org.xml.sax.helpers.DefaultHandler
Throws:
org.xml.sax.SAXException

emit

public void emit(java.lang.String s)
          throws org.xml.sax.SAXException
Throws:
org.xml.sax.SAXException

rmH

public java.lang.String rmH(java.lang.String s)
This method removes a hash (#) occuring at the start of a string.

Parameters:
s - the string
Returns:
the same string, except for an eventual hash