vn
Class EventManager

java.lang.Object
  extended by vn.EventManager

public class EventManager
extends Object

This class invokes methods from the Cyc class as certain Inspector events are fired, essentially implementing the VxC application. The approach VxC takes to extending the Inspector is to put as little code into the EventManager class as possible, and utilize external classes for all additional required code (Cyc, Matcher, and PrepositionManager in this case).

At the beginning of the program the Cyc class is asked to initialize itself and read in both the Cyc verbSemTrans rules as well as the manual mapping file. At the start of each class or subclass the event tells the Cyc class what the current class being processed is. The class depth is also kept track of with classLevel. This is only used to implement the print class match counts feature (Cyc.flShowClassMatchCounts, -Sc on command-line). At the end of the program the Cyc class is called upon to close any external files it needs to and to print the final statistics of the automatic matching.

For VxC to function correctly, the Inspector must be running in verb-frame mode. Therefore, the -q option is mandatory for each execution (-Vq also works but no normal output is required to be printed).

That said, the only other real processing that takes place in this class happens at the end of each verb-frame pair. At this point, the syntax and semantics for the verb-frame pair has been visited and saved to syn and sem and all remaining required information is stored in the text parameter of the method. The Cyc class is called upon look for any matches present for the given VerbNet verb-frame pair.

See the EVENT_PROGRAM, EVENT_CLASS, EVENT_SUBCLASS, EVENT_SYNTAX, EVENT_SEMANTIC_PRED, EVENT_VF_PAIR, and EVENT_END_FRAMES events.

Version:
1.0, 2006.10.25
Author:
Derek Trumbo
See Also:
fireEvent(int, int, String, String, String, Element, Element)

Field Summary
private static int classLevel
          Stores the depth of the current class or subclass.
(package private) static int EVENT_CLASS
          Identifies that the event is for a main class.
(package private) static int EVENT_END
          Identifies that the event firing corresponds to the end of the element in question.
(package private) static int EVENT_END_FRAMES
          Identifies the moment right before another class begins.
(package private) static int EVENT_EXAMPLE
          Identifies that the event is for an example.
(package private) static int EVENT_FILE
          Identifies that the event is for a single XML file.
(package private) static int EVENT_FRAME
          Identifies that the event is for a frame.
(package private) static int EVENT_MEMBER
          Identifies that the event is for a single member (verb).
(package private) static int EVENT_PROGRAM
          Identifies that the event is for the entire program.
(package private) static int EVENT_SEMANTIC_PRED
          Identifies that the event is for a single semantic predicate.
(package private) static int EVENT_START
          Identifies that the event firing corresponds to the beginning of the element in question.
(package private) static int EVENT_SUBCLASS
          Identifies that the event is for a subclass.
(package private) static int EVENT_SYNTAX
          Identifies that the event is for syntax.
(package private) static int EVENT_THEMROLE
          Identifies that the event is for a thematic role.
(package private) static int EVENT_VF_PAIR
          Identifies that the event is for a verb-frame pair.
private static PrintStream originalStdOut
          The original stdout stream reference from the System class.
private static String sem
          The semantics of the given verb-frame pair.
private static String syn
          The syntax of the given verb-frame pair.
 
Constructor Summary
private EventManager()
          This constructor is private because the class is not intended to ever be instantiated.
 
Method Summary
(package private) static void fireEvent(int type, int startOrEnd, String curFile, String curClass, String text, Element n, Element nExtra)
          Captures events from the Inspector scanning system and passes relevant information from the XML files onto the Cyc class so that it can look for possible matches between the VerbNet and Cyc.
(package private) static void fireEventMaybe(int type, int startOrEnd, String curFile, String curClass, String text, Node n, Node nExtra)
          Fires an event if events are enabled for this execution of the Inspector.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

syn

private static String syn
The syntax of the given verb-frame pair. This is essentially just a temporary storage location for the syntax of a verb-frame pair since the syntax is needed when each verb-frame pair is processed at the end of each pair. See EVENT_SYNTAX and EVENT_VF_PAIR.

See Also:
fireEvent(int, int, String, String, String, Element, Element)

sem

private static String sem
The semantics of the given verb-frame pair. This is essentially just a temporary storage location for the semantics of a verb-frame pair since the semantics is needed when each verb-frame pair is processed at the end of each pair. This string is the conglomeration of all semantic predicates in one. See EVENT_SEMANTIC_PRED and EVENT_VF_PAIR.

See Also:
fireEvent(int, int, String, String, String, Element, Element)

classLevel

private static int classLevel
Stores the depth of the current class or subclass. The main class in a file is level 0. This is used only to implement the print class match counts feature (Cyc.flShowClassMatchCounts, -Sc on command-line). See the EVENT_CLASS, EVENT_SUBCLASS, and EVENT_END_FRAMES events.

See Also:
fireEvent(int, int, String, String, String, Element, Element)

EVENT_START

static final int EVENT_START
Identifies that the event firing corresponds to the beginning of the element in question.

See Also:
fireEvent(int, int, String, String, String, Element, Element), Constant Field Values

EVENT_END

static final int EVENT_END
Identifies that the event firing corresponds to the end of the element in question.

See Also:
fireEvent(int, int, String, String, String, Element, Element), Constant Field Values

EVENT_PROGRAM

static final int EVENT_PROGRAM
Identifies that the event is for the entire program.

See Also:
fireEvent(int, int, String, String, String, Element, Element), Constant Field Values

EVENT_FILE

static final int EVENT_FILE
Identifies that the event is for a single XML file.

See Also:
fireEvent(int, int, String, String, String, Element, Element), Constant Field Values

EVENT_CLASS

static final int EVENT_CLASS
Identifies that the event is for a main class.

See Also:
fireEvent(int, int, String, String, String, Element, Element), Constant Field Values

EVENT_SUBCLASS

static final int EVENT_SUBCLASS
Identifies that the event is for a subclass.

See Also:
fireEvent(int, int, String, String, String, Element, Element), Constant Field Values

EVENT_MEMBER

static final int EVENT_MEMBER
Identifies that the event is for a single member (verb).

See Also:
fireEvent(int, int, String, String, String, Element, Element), Constant Field Values

EVENT_THEMROLE

static final int EVENT_THEMROLE
Identifies that the event is for a thematic role.

See Also:
fireEvent(int, int, String, String, String, Element, Element), Constant Field Values

EVENT_FRAME

static final int EVENT_FRAME
Identifies that the event is for a frame.

See Also:
fireEvent(int, int, String, String, String, Element, Element), Constant Field Values

EVENT_EXAMPLE

static final int EVENT_EXAMPLE
Identifies that the event is for an example.

See Also:
fireEvent(int, int, String, String, String, Element, Element), Constant Field Values

EVENT_SYNTAX

static final int EVENT_SYNTAX
Identifies that the event is for syntax.

See Also:
fireEvent(int, int, String, String, String, Element, Element), Constant Field Values

EVENT_SEMANTIC_PRED

static final int EVENT_SEMANTIC_PRED
Identifies that the event is for a single semantic predicate. There are no events that fire for the SEMANTICS element as a whole, only one for each semantic predicate.

See Also:
fireEvent(int, int, String, String, String, Element, Element), Constant Field Values

EVENT_VF_PAIR

static final int EVENT_VF_PAIR
Identifies that the event is for a verb-frame pair.

See Also:
fireEvent(int, int, String, String, String, Element, Element), Constant Field Values

EVENT_END_FRAMES

static final int EVENT_END_FRAMES
Identifies the moment right before another class begins. This is synonymous with </FRAMES> but not synonymous with end of class. So a special event is needed. This event only has an 'end' event.

See Also:
fireEvent(int, int, String, String, String, Element, Element), Constant Field Values

originalStdOut

private static PrintStream originalStdOut
The original stdout stream reference from the System class. This is saved in the static initializer for this class and exists just in case the stdout stream is reset to a custom file in the fireEvent(int, int, String, String, String, Element, Element). A researcher can use this reference to reset the System class's stdout stream back to the original stream whenever desired.

See Also:
System.out, System.setOut(PrintStream)
Constructor Detail

EventManager

private EventManager()
This constructor is private because the class is not intended to ever be instantiated. The Inspector is a very procedural process and thus all the members are static.

Method Detail

fireEvent

static void fireEvent(int type,
                      int startOrEnd,
                      String curFile,
                      String curClass,
                      String text,
                      Element n,
                      Element nExtra)
Captures events from the Inspector scanning system and passes relevant information from the XML files onto the Cyc class so that it can look for possible matches between the VerbNet and Cyc. For VxC to function it must be running in verb-frame pair mode. This means that the member and frame events do not fire, but rather the verb-frame pair events fire. Upon visiting each verb-frame pair, the verb, syntax, semantics and frame information are sent to the Cyc class to be compared to all the relevant Cyc rules. When this method captures the 'end' of program event, it asks the Cyc class to print its results.

Parameters:
type - the type of element to which this event corresponds (EVENT_PROGRAM, EVENT_FILE, etc.)
startOrEnd - whether this event is for the beginning of the element or the end of the element (EVENT_START or EVENT_END)
curFile - the name of the file currently being processed (i.e. approve-77.xml). This argument is null for the PROGRAM element.
curClass - the name of the class or subclass currently being processed (i.e. devour-39.4-1). This argument is null for the PROGRAM and FILE elements.
text - the simple-text representation of the element to which this event corresponds. This text is equivalent to the text that would be printed for this element had it been printed by the Inspector under the view options -Vab (full output). For the PROGRAM element, this argument is equal to the concatenation of all the command line elements with spaces.
n - the XML node corresponding to the element being visited. This argument is null for the PROGRAM and FILE elements. For verb-frame pairs, this is the XML node corresponding to the MEMBER element in the verb-frame pair.
nExtra - the XML node corresponding to the FRAME element in the verb-frame pair being visited. This argument is null for all other elements.
See Also:
Cyc.initialize(), Cyc.loadExternalData(), Cyc.closeExternalData(), Cyc.compareMatches(), Cyc.setClass(String), Cyc.findCycMatches(String, String, String, int, String), Cyc.printClassMatchCount(int)

fireEventMaybe

static void fireEventMaybe(int type,
                           int startOrEnd,
                           String curFile,
                           String curClass,
                           String text,
                           Node n,
                           Node nExtra)
Fires an event if events are enabled for this execution of the Inspector. This method exists only to implement the "suppress all events" option (-e) of the Inspector. Events are enabled by default. This option must be supplied to prevent them from firing. If the events are not being suppressed, this method simply hands the arguments given to it to the real fireEvent method. It also makes a quick conversion between Nodes and Elements for code simplification purposes only. One error message has been added to this method for the VxC extension of the Inspector. Do not modify this method.

Parameters:
type - the type of element to which this event corresponds (EVENT_PROGRAM, EVENT_FILE, etc.)
startOrEnd - whether this event is for the beginning of the element or the end of the element (EVENT_START or EVENT_END)
curFile - the name of the file currently being processed (i.e. approve-77.xml). This argument is null for the PROGRAM element.
curClass - the name of the class or subclass currently being processed (i.e. devour-39.4-1). This argument is null for the PROGRAM and FILE elements.
text - the simple-text representation of the element to which this event corresponds. This text is equivalent to the text that would be printed for this element had it been printed by the Inspector under the view options -Vab (full output). For the PROGRAM element, this argument is equal to the concatenation of all the command line elements with spaces.
n - the XML node corresponding to the element being visited. This argument is null for the PROGRAM and FILE elements. For verb-frame pairs, this is the XML node corresponding to the MEMBER element in the verb-frame pair.
nExtra - the XML node corresponding to the FRAME element in the verb-frame pair being visited. This argument is null for all other elements.
See Also:
fireEvent(int, int, String, String, String, Element, Element), Inspector.flSuppressEvents