vn
Class Sweeper

java.lang.Object
  extended by vn.Sweeper

public class Sweeper
extends Object

This class defines the action to take upon encountering each element in a VerbNet XML file. The name Sweeper has no particular significance other than to be memorable enough to be associated with this important task.

The Inspector class, after it has processed all command-line arguments, will begin reading in the requested XML files one-by-one. After loading and parsing each one, a recursive process is begun that executes the methods in this class. The appropriate method is called based solely upon the tag name of the element being processed by use of reflection. The methods Inspector.processNode(Node) or Inspector.processNodeByPairs(Node, ArrayList) recursively traverse the XML nodes and call upon Inspector.executeHTMLMethod(String, Node) to execute the appropriate method in this class.

This class has multiple responsibilities. They include:

The implementation of this class is fairly intricate so that the EventManager class is as easy to use as possible for researchers. A researcher should never have to modify this code, but it is provided openly so that doing so is available if necessary.

This file has also been as convenient as possible for future developers. Since VerbNet is not a fixed entity (its structure and content can change as work progresses on it), elements and attributes may be added to or removed from the XML format.

If a new element is added to the XML files, one can simply insert new methods named startNODE and endNODE where NODE is the tag name of the new element. They will be invoked when the driver class (Inspector) begins and ends processing the node, respectively. Just the act of inserting these methods, in the same manner as the already-existing methods, makes them active since reflection is used.

If an attribute is added to or removed from an element, one can find the appropriate startNODE or endNODE method and modfiy how the attributes are used to construct the simple-text representation of the element. All attributes are stored into local String objects at the very beginning of each of the methods (using the Element.getAttribute(String) method). Read the specific documentation of each method below carefully to avoid invalid modifications.

Finally, a sweeper method has the general form:
 static void startNODE( Node n )
 {
    // 1. Grab all attributes from the element (Node n).
    // 2. Construct local output string (simple-text representation) for this element.
    // 3. Initialize global event string to local output string or append local output
    //    string to global event string.
    // 4. If the proper view options are supplied for this element, display the
    //    local output string.
    // 5. If applicable, fire appropriate event(s)
 }
The Inspector is ready for use right out of the box. There is very little to configure. However, these notes (all of which shown on Inspector, Sweeper, and EventManager classes) provide some more logistical details about the software.

NOTE 1: The Inspector is implemented almost entirely with static methods. Text parsing and scanning is a very serial process and the Inspector would only have been made more complicated with a more object-oriented scheme.

NOTE 2: The Inspector produces simple-text representations for frame syntax which are congruent with the representations for frame syntax presented in the Unified Verb Index. The only difference is that the UVI represents noun phrase thematic roles with underline (Agent) and the Inspector represents them with a preceding % sign (%Agent). Look at the UVI's key or the Inspector's key (-k option on command line) for more information.

NOTE 3: Use of the Inspector, either by extension or by insertion into an existing application, requires the entirety of the VerbNet XML files. They may be placed anywhere in relation to the Inspector source code, as the only required argument to the Inspector is this XML input directory path. They can be downloaded here. Finally, the DTD file contained in this download is required to be in the same directory as the XML files (it's already there, just don't remove it).

NOTE 4: This software assumes that the XML files it is processing match the VerbNet DTD. This means that elements appear in the proper order (MEMBERS, THEMROLES, FRAMES, SUBCLASSES) and all tag names are in upper case (i.e. <FRAME>). The files available for download should match the DTD almost 100%.

NOTE 5: This documentation utilizes the terms 'researcher' and 'future developer' so as to reduce confusion as much as possible. A researcher is one who downloads the Inspector source code from the website with the intention of extending it for his or her own purposes, or integrating it into an existing NLP application. A future developer is a member of the University of Colorado team responsible for the Inspector who might modify or enhance it over time. This documentation is written for both parties.

NOTE 6: This Javadoc documentation is not written like a standard public API might be written. First, all private members are displayed here because this is also made to be convenient documentation for future developers. Second, all "See Also" links below actually reference other places in the code that reference or are referenced by the given member. This is in contrast to public API documentation, in which the "See Also" links commonly refer the reader to class members of related or contrasted functionality.

NOTE 7: Although originally written with a few Java 1.5 features, the Inspector was downgraded so as to be compilable with javac 1.4.2. The reason for this was so researchers did not need to download and run Java 1.5 for this software. This software will however work with Java 1.5. If you do not have Java installed on your system, download the most recent release right here. Also, here are links to the 1.4.2 documentation and the 1.5.0 documentation.

Version:
1.0, 2006.10.25
Author:
Derek Trumbo

Nested Class Summary
private static class Sweeper.MemberNode
          Holds all crucial information about a member when it is encountered so it can be properly displayed in later processing.
 
Field Summary
private static String curClass
          The name of the current class or subclass being processed.
private static String curFile
          The name of the current XML file being processed.
private static int curIndentLevel
          Represents how many levels of indentation should be printed when output is printed to stdout.
private static ArrayList curVFFrameList
          All the frames visited so far since the main (root) class.
private static Node curVFFrameNode
          The XML FRAME node corresponding to the current verb-frame pair (used only when the Inspector is running in verb-frame pair mode).
(package private) static int curVFFrameNum
          When the Inspector is running in verb-frame pair mode, this integer represents the frame number in the recursion chain.
private static Node curVFMemberNode
          The XML MEMBER node corresponding to the current verb-frame pair (used only when the Inspector is running in verb-frame pair mode).
private static String curVFVerbName
          The verb corresponding to the current verb-frame pair (used only when the Inspector is running in verb-frame pair mode).
private static String curVFVerbWN
          The WordNet sense corresponding to the current verb-frame pair (used only when the Inspector is running in verb-frame pair mode).
private static String evText
          The string which is given to EventManager.fireEvent(int, int, String, String, String, Element, Element) when events are fired.
private static String evTextLocal
          The string which contains the characters that each sweeper method will output locally.
private static Stack evTexts
          A stack of strings which holds the global event string for various elements which was created for their 'start' events until their 'end' events come around.
private static boolean hasBeenOther
          Used by various types of nodes for which there might be a list to display to know if another of their same kind has already been shown, so as to print the appropriate separator.
private static int INDENT_WIDTH
          The number of spaces for a single indentation width.
private static String indentSpaces
          A string consisting of INDENT_WIDTH spaces.
private static ArrayList members
          Holds all the member information for a given class or subclass.
private static boolean npSelRestrs
          Whether or not the SELRESTRS about to be entered is under an NP node (as compared to a PREP or THEMROLE node).
private static boolean prepSelRestrs
          Whether or not the SELRESTRS about to be entered is under a PREP node (as compared to a THEMROLE or NP node).
private static Stack replicateLabels
          A stack of strings which holds the labels for all printed elements that have caused additional nesting (file, class, subclass, and frame).
private static int restrsLevel
          The level of nested SELRESTRS being processed.
private static boolean trSelRestrs
          Whether or not the SELRESTRS about to be entered is under a THEMROLE node (as compared to a PREP or NP node).
private static boolean usingOr
          Whether or not nodes which specify logical operators for their children are using 'or'.
 
Constructor Summary
private Sweeper()
          This constructor is private because the class is not intended to ever be instantiated.
 
Method Summary
private static void classHierarchyPrint(Element cls, int level)
          Prints name of the class element provided and the names of all subclass elements contained within, joint with the number of members and frames for each.
(package private) static void endADJ(Node n)
          Prints the text that corresponds to the closing of the ADJ element in the VerbNet XML files.
(package private) static void endADV(Node n)
          Prints the text that corresponds to the closing of the ADV element in the VerbNet XML files.
(package private) static void endARG(Node n)
          Prints the text that corresponds to the closing of the ARG element in the VerbNet XML files.
(package private) static void endARGS(Node n)
          Prints the text that corresponds to the closing of the ARGS element in the VerbNet XML files.
(package private) static void endDESCRIPTION(Node n)
          Prints the text that corresponds to the closing of the DESCRIPTION element in the VerbNet XML files.
(package private) static void endEXAMPLE(Node n)
          Prints the text that corresponds to the closing of the EXAMPLE element in the VerbNet XML files.
(package private) static void endEXAMPLES(Node n)
          Prints the text that corresponds to the closing of the EXAMPLES element in the VerbNet XML files.
(package private) static void endFRAME(Node n)
          Prints the text that corresponds to the closing of the FRAME element in the VerbNet XML files.
(package private) static void endFRAMES(Node n)
          Prints the text that corresponds to the closing of the FRAMES element in the VerbNet XML files.
(package private) static void endLEX(Node n)
          Prints the text that corresponds to the closing of the LEX element in the VerbNet XML files.
(package private) static void endMEMBER(Node n)
          Prints the text that corresponds to the closing of the MEMBER element in the VerbNet XML files.
(package private) static void endMEMBERS(Node n)
          Prints the text that corresponds to the closing of the MEMBERS element in the VerbNet XML files.
(package private) static void endNP(Node n)
          Prints the text that corresponds to the closing of the NP element in the VerbNet XML files.
(package private) static void endPRED(Node n)
          Prints the text that corresponds to the closing of the PRED element in the VerbNet XML files.
(package private) static void endPREP(Node n)
          Prints the text that corresponds to the closing of the PREP element in the VerbNet XML files.
(package private) static void endSELRESTR(Node n)
          Prints the text that corresponds to the closing of the SELRESTR element in the VerbNet XML files.
(package private) static void endSELRESTRS(Node n)
          Prints the text that corresponds to the closing of the SELRESTRS element in the VerbNet XML files.
(package private) static void endSEMANTICS(Node n)
          Prints the text that corresponds to the closing of the SEMANTICS element in the VerbNet XML files.
(package private) static void endSYNRESTR(Node n)
          Prints the text that corresponds to the closing of the SYNRESTR element in the VerbNet XML files.
(package private) static void endSYNRESTRS(Node n)
          Prints the text that corresponds to the closing of the SYNRESTRS element in the VerbNet XML files.
(package private) static void endSYNTAX(Node n)
          Prints the text that corresponds to the closing of the SYNTAX element in the VerbNet XML files.
(package private) static void endTHEMROLE(Node n)
          Prints the text that corresponds to the closing of the THEMROLE element in the VerbNet XML files.
(package private) static void endTHEMROLES(Node n)
          Prints the text that corresponds to the closing of the THEMROLES element in the VerbNet XML files.
(package private) static void endVERB(Node n)
          Prints the text that corresponds to the closing of the VERB element in the VerbNet XML files.
(package private) static void endVNCLASS(Node n)
          Prints the text that corresponds to the closing of the VNCLASS element in the VerbNet XML files.
(package private) static void endVNSUBCLASS(Node n)
          Prints the text that corresponds to the closing of the VNSUBCLASS element in the VerbNet XML files.
private static boolean hasKids(Node n, String which)
          Whether or not the given XML element has children with a given tag name.
private static void iprint(String s)
          Does the exact same thing as print(String) if the indentation flag (-i) was not supplied on the command line (and thus Inspector.flIndent is false).
private static void iprintln(String s)
          Does the exact same thing as println(String) if the indentation flag (-i) was not supplied on the command line (and thus Inspector.flIndent is false).
private static int numKids(Node n, String which)
          Counts the number of children of a given XML element who have the given tag name.
private static void popText()
          Removes a string from the global event string stack and places it into the class-level global event string.
private static void popTextForReplicate()
          Removes the most recently stored label text for replication.
private static void print(String s)
          Used as shorthand for System.out.print.
private static void println(String s)
          Used as shorthand for System.out.println.
private static void printMembers()
          Prints the text for all the members in this class.
private static void printVerbFramePairs()
          Prints all verb-frame pairs if the Inspector is running in verb-frame pair mode.
private static void pushText()
          Saves the class-level global event string to a stack of event strings.
private static void pushTextForReplicate(String text)
          Saves the text for a label to be replicated for all elements contained within it.
private static void replicateLabels()
          Prints all the labels currently stored for replication.
(package private) static void setCurFile(String newFileName)
          Sets the current file being processed.
(package private) static void setFrameList(ArrayList newFrameList)
          Sets a class-level reference to a list containing all the frames visited so far since the main (root) class.
(package private) static void startADJ(Node n)
          Prints the text that corresponds to the beginning of the ADJ element in the VerbNet XML files.
(package private) static void startADV(Node n)
          Prints the text that corresponds to the beginning of the ADV element in the VerbNet XML files.
(package private) static void startARG(Node n)
          Prints the text that corresponds to the beginning of the ARG element in the VerbNet XML files.
(package private) static void startARGS(Node n)
          Prints the text that corresponds to the beginning of the ARG element in the VerbNet XML files.
(package private) static void startDESCRIPTION(Node n)
          Prints the text that corresponds to the beginning of the DESCRIPTION element in the VerbNet XML files.
(package private) static void startEXAMPLE(Node n)
          Prints the text that corresponds to the beginning of the EXAMPLE element in the VerbNet XML files.
(package private) static void startEXAMPLES(Node n)
          Prints the text that corresponds to the beginning of the EXAMPLES element in the VerbNet XML files.
(package private) static void startFRAME(Node n)
          Prints the text that corresponds to the beginning of the FRAME element in the VerbNet XML files.
(package private) static void startFRAMES(Node n)
          Prints the text that corresponds to the beginning of the FRAMES element in the VerbNet XML files.
(package private) static void startLEX(Node n)
          Prints the text that corresponds to the beginning of the LEX element in the VerbNet XML files.
(package private) static void startMEMBER(Node n)
          Prints the text that corresponds to the beginning of the MEMBER element in the VerbNet XML files.
(package private) static void startMEMBERS(Node n)
          Prints the text that corresponds to the beginning of the MEMBERS element in the VerbNet XML files.
(package private) static void startNP(Node n)
          Prints the text that corresponds to the beginning of the NP element in the VerbNet XML files.
(package private) static void startPRED(Node n)
          Prints the text that corresponds to the beginning of the PRED element in the VerbNet XML files.
(package private) static void startPREP(Node n)
          Prints the text that corresponds to the beginning of the PREP element in the VerbNet XML files.
(package private) static void startSELRESTR(Node n)
          Prints the text that corresponds to the beginning of the SELRESTR element in the VerbNet XML files.
(package private) static void startSELRESTRS(Node n)
          Prints the text that corresponds to the beginning of the SELRESTRS element in the VerbNet XML files.
(package private) static void startSEMANTICS(Node n)
          Prints the text that corresponds to the beginning of the SEMANTICS element in the VerbNet XML files.
(package private) static void startSYNRESTR(Node n)
          Prints the text that corresponds to the beginning of the SYNRESTR element in the VerbNet XML files.
(package private) static void startSYNRESTRS(Node n)
          Prints the text that corresponds to the beginning of the SYNRESTRS element in the VerbNet XML files.
(package private) static void startSYNTAX(Node n)
          Prints the text that corresponds to the beginning of the SYNTAX element in the VerbNet XML files.
(package private) static void startTHEMROLE(Node n)
          Prints the text that corresponds to the beginning of the THEMROLE element in the VerbNet XML files.
(package private) static void startTHEMROLES(Node n)
          Prints the text that corresponds to the beginning of the THEMROLES element in the VerbNet XML files.
(package private) static void startVERB(Node n)
          Prints the text that corresponds to the beginning of the VERB element in the VerbNet XML files.
(package private) static void startVNCLASS(Node n)
          Prints the text that corresponds to the beginning of the VNCLASS element in the VerbNet XML files.
(package private) static void startVNSUBCLASS(Node n)
          Prints the text that corresponds to the beginning of the VNSUBCLASS element in the VerbNet XML files.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

curFile

private static String curFile
The name of the current XML file being processed. This is set in the Inspector.performInspection() method, which calls setCurFile(String). This is used so that at any point during the execution of the sweeper methods, the currently-active file name is available for use. It is given to EventManager.fireEvent(int, int, String, String, String, Element, Element) upon firing of each event.

See Also:
Inspector.performInspection(), startVNCLASS(Node)

curClass

private static String curClass
The name of the current class or subclass being processed. This is set when each new class or subclass is begun. This is used so that at any point during the execution of the sweeper methods, the currently-active class or subclass name is available for use. It is given to EventManager.fireEvent(int, int, String, String, String, Element, Element) upon firing of each event.

See Also:
startVNCLASS(Node), startVNSUBCLASS(Node)

hasBeenOther

private static boolean hasBeenOther
Used by various types of nodes for which there might be a list to display to know if another of their same kind has already been shown, so as to print the appropriate separator.

See Also:
startSELRESTRS(Node), startSELRESTR(Node), startARGS(Node), startARG(Node), startSYNRESTRS(Node), startSYNRESTR(Node)

usingOr

private static boolean usingOr
Whether or not nodes which specify logical operators for their children are using 'or'. This only happens with SELRESTRS and SYNRESTRS. When their children execute, they know whether to print a | or an & before printing themselves.

See Also:
startSELRESTRS(Node), startSELRESTR(Node), startSYNRESTRS(Node), startSYNRESTR(Node)

restrsLevel

private static int restrsLevel
The level of nested SELRESTRS being processed. The definition of SELRESTRS is recursive in the DTD (<!ELEMENT SELRESTRS (SELRESTR|SELRESTRS)*>) and a | or an & should be printed if it's not the top-level element. Currently, this only happens in a few files: bring-11.3.html, carry-11.4.html, cheat-10.6.html, drive-11.5.html, pour-9.5.html, send-11.1.html, slide-11.2.html, spray-9.7.html, steal-10.5.html, throw-17.1.html.

See Also:
startSELRESTRS(Node), endSELRESTRS(Node)

prepSelRestrs

private static boolean prepSelRestrs
Whether or not the SELRESTRS about to be entered is under a PREP node (as compared to a THEMROLE or NP node). This is modified upon entering and leaving a PREP element. SELRESTRS for a preposition are displayed differently than other uses of SELRESTRS.

See Also:
startPREP(Node), endPREP(Node), startSELRESTRS(Node), endSELRESTRS(Node), startSELRESTR(Node), endSELRESTR(Node)

trSelRestrs

private static boolean trSelRestrs
Whether or not the SELRESTRS about to be entered is under a THEMROLE node (as compared to a PREP or NP node). This is modified upon entering and leaving a THEMROLE element. SELRESTRS for thematic roles are displayed much like those for noun phrases (NP).

See Also:
startTHEMROLE(Node), endTHEMROLE(Node), startSELRESTRS(Node), endSELRESTRS(Node), startSELRESTR(Node), endSELRESTR(Node)

npSelRestrs

private static boolean npSelRestrs
Whether or not the SELRESTRS about to be entered is under an NP node (as compared to a PREP or THEMROLE node). This is modified upon entering and leaving a NP element. SELRESTRS for noun phrases are displayed much like those for thematic roles.

See Also:
startNP(Node), endNP(Node), startSELRESTRS(Node), endSELRESTRS(Node), startSELRESTR(Node), endSELRESTR(Node)

members

private static ArrayList members
Holds all the member information for a given class or subclass. Information for a single member consists of the verb, its list of WordNet senses and the XML MEMBER node from which that information was extracted. It is cleared at the start of each class or subclass, loaded up during the <MEMBER> tag scanning, and sorted and dumped upon reaching the </MEMBERS> tag. This was only added to facilitate sorted member sections. If sorting was not a priority, then members would just be printed as they were reached. If verb-frame pairs are enabled, then the members are not printed in </MEMBERS> but rather printed in a pair with each frame in printVerbFramePairs().

See Also:
startMEMBERS(Node), startMEMBER(Node), printMembers(), printVerbFramePairs()

INDENT_WIDTH

private static final int INDENT_WIDTH
The number of spaces for a single indentation width.

See Also:
Constant Field Values

indentSpaces

private static String indentSpaces
A string consisting of INDENT_WIDTH spaces. This is set in the static initializer for this class and used when the indentation flag (-i) is specified.

See Also:
iprint(String), iprintln(String), classHierarchyPrint(Element, int)

curIndentLevel

private static int curIndentLevel
Represents how many levels of indentation should be printed when output is printed to stdout. This variable is modified regardless of whether the indentation flag (-i) is specified. The iprint(String) and iprintln(String) methods control whether the actual indentation is performed. Indentation level is changed only by FILE, CLASS, SUBCLASS, and FRAME.

See Also:
iprint(String), iprintln(String), startVNCLASS(Node), endVNCLASS(Node), startVNSUBCLASS(Node), endVNSUBCLASS(Node), startFRAME(Node), endFRAME(Node)

curVFVerbName

private static String curVFVerbName
The verb corresponding to the current verb-frame pair (used only when the Inspector is running in verb-frame pair mode). This needs to be class-level so the printVerbFramePairs() method can communicate information to startDESCRIPTION(Node) This string is used in constructing the header line for the verb-frame pair.

See Also:
startDESCRIPTION(Node), printVerbFramePairs()

curVFVerbWN

private static String curVFVerbWN
The WordNet sense corresponding to the current verb-frame pair (used only when the Inspector is running in verb-frame pair mode). This needs to be class-level so the printVerbFramePairs() method can communicate information to startDESCRIPTION(Node). This string is used in constructing the header line for the verb-frame pair.

See Also:
startDESCRIPTION(Node), printVerbFramePairs()

curVFMemberNode

private static Node curVFMemberNode
The XML MEMBER node corresponding to the current verb-frame pair (used only when the Inspector is running in verb-frame pair mode). This needs to be class-level so the printVerbFramePairs() method can communicate information to startDESCRIPTION(Node). This node is used when firing the 'start' and 'end' events for the verb-frame pair.

See Also:
startDESCRIPTION(Node), endFRAME(Node), printVerbFramePairs(), EventManager.fireEvent(int, int, String, String, String, Element, Element)

curVFFrameNum

static int curVFFrameNum
When the Inspector is running in verb-frame pair mode, this integer represents the frame number in the recursion chain. This is somewhat temporary as it does not represent a completely useful numbering scheme. The first frame in each file is number 1.


curVFFrameNode

private static Node curVFFrameNode
The XML FRAME node corresponding to the current verb-frame pair (used only when the Inspector is running in verb-frame pair mode). This needs to be class-level so the printVerbFramePairs() method can communicate information to startDESCRIPTION(Node). This node is used when firing the 'start' and 'end' events for the verb-frame pair.

See Also:
startDESCRIPTION(Node), endFRAME(Node), printVerbFramePairs(), EventManager.fireEvent(int, int, String, String, String, Element, Element)

curVFFrameList

private static ArrayList curVFFrameList
All the frames visited so far since the main (root) class. Or at least that's the description used throughout this documentation. What does this mean though? A verb in VerbNet is involved in not only the frames in its class or subclass, but also all those frames in the ancestor classes or subclasses (using tree terminology). Therefore, if we take the separate-23.1 class:
 separate-23.1 [Members: 4, Frames: 5]
     separate-23.1-1 [Members: 7, Frames: 1]
     separate-23.1-2 [Members: 4, Frames: 1]
When the Sweeper is scanning the main class's verb-frame pairs there are 4 members x 5 frames = 20 verb-frame pairs in curVFFrameNode. When the Sweeper is scanning the first subclass's verb-frame pairs there are 7 members x (5+1) frames = 42 verb-frame pairs in curVFFrameNode. When the Sweeper is scanning the second subclass's verb-frame pairs there are 4 members x (5+1) frames = 24 verb-frame pairs in curVFFrameNode. A subclass does not inherit frames from a sibling class, only ancestor classes. This array is loaded up in Inspector.processNodeByPairs(Node, ArrayList). Remember that this member and all verb-frame-pair-related members are only used by the code if the -q or -Vq options are specified.

See Also:
printVerbFramePairs(), setFrameList(ArrayList), Inspector.processNodeByPairs(Node, ArrayList)

evText

private static String evText
The string which is given to EventManager.fireEvent(int, int, String, String, String, Element, Element) when events are fired. This string does not necessarily equal the line of text that is sent to stdout for the given element. What is displayed on stdout is controlled by view options (-V operator) but this string contains as much text for the line as is available in the XML files for that element. In other words this string is the same as the lines of text send to stdout for ALL elements if and only if the option -Vab were supplied (which prints all information from the XML files to stdout).

See Also:
pushText(), popText(), EventManager, EventManager.fireEvent(int, int, String, String, String, Element, Element)

evTextLocal

private static String evTextLocal
The string which contains the characters that each sweeper method will output locally. This was promoted to a class-level variable only for convenience so it wouldn't have to be declared in every sweeper method. Sometimes there are other intermediate strings that are used until the final value for this variable is known. Then, usually it is appended to evText or evText is initialized to it (in cases where the method in question prints the first characters for a line of text).

See Also:
evText

evTexts

private static Stack evTexts
A stack of strings which holds the global event string for various elements which was created for their 'start' events until their 'end' events come around.

See Also:
pushText(), popText()

replicateLabels

private static Stack replicateLabels
A stack of strings which holds the labels for all printed elements that have caused additional nesting (file, class, subclass, and frame). So at any given time this stack contains at most one file label, one class label, a handful of subclass labels, and one frame label (that scenario would be for when an example, syntax, or semantic predicate was being printed in a class with multiple subclasses and most view options enabled with the replicate flag supplied). Applies to replicate flag only.

See Also:
pushTextForReplicate(String), popTextForReplicate(), replicateLabels()
Constructor Detail

Sweeper

private Sweeper()
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

println

private static void println(String s)
Used as shorthand for System.out.println.

Parameters:
s - the string to print to stdout, followed by a carriage return
See Also:
PrintStream.println(String)

print

private static void print(String s)
Used as shorthand for System.out.print.

Parameters:
s - the string to print to stdout
See Also:
PrintStream.print(String)

iprintln

private static void iprintln(String s)
Does the exact same thing as println(String) if the indentation flag (-i) was not supplied on the command line (and thus Inspector.flIndent is false). However, if indentation was requested, then this method first prints the appropriate number of spaces based on the current indentation level. Indentation level is changed only by FILE, CLASS, SUBCLASS, and FRAME.

Parameters:
s - the string to print to stdout, with possible indenting, followed by a carriage return
See Also:
println(String), curIndentLevel, Inspector.flIndent

iprint

private static void iprint(String s)
Does the exact same thing as print(String) if the indentation flag (-i) was not supplied on the command line (and thus Inspector.flIndent is false). However, if indentation was requested, then this method first prints the appropriate number of spaces based on the current indentation level. Indentation level is changed only by FILE, CLASS, SUBCLASS, and FRAME.

Parameters:
s - the string to print to stdout, with possible indenting
See Also:
print(String), curIndentLevel, Inspector.flIndent

setCurFile

static void setCurFile(String newFileName)
Sets the current file being processed. It is primarily used when firing events.

Parameters:
newFileName - the current file being processed in Inspector.performInspection()
See Also:
Inspector.performInspection(), curFile

setFrameList

static void setFrameList(ArrayList newFrameList)
Sets a class-level reference to a list containing all the frames visited so far since the main (root) class. This is set each time a new class or subclass is reached in the driver class's recursive XML traversal method (Inspector.processNodeByPairs(Node, ArrayList)). This is only used when the Inspector is running in verb-frame pair mode.

Parameters:
newFrameList - the list containing all of the frames visited so far since the main (root) class
See Also:
Inspector.processNodeByPairs(Node, ArrayList), printVerbFramePairs(), curVFFrameList

hasKids

private static boolean hasKids(Node n,
                               String which)
Whether or not the given XML element has children with a given tag name.

Parameters:
n - the node whose children should be checked
which - the tag name to look for among the children
Returns:
whether or not the node contains one or more children of the given type

numKids

private static int numKids(Node n,
                           String which)
Counts the number of children of a given XML element who have the given tag name.

Parameters:
n - the node whose children should be checked
which - the tag name to look for among the children
Returns:
the number of children of the given type that the node contains

pushText

private static void pushText()
Saves the class-level global event string to a stack of event strings. This is required because the 'end' event for all elements contains the same event text as the 'start' events. Since all the elements use the same class-level global event string, this text needs to be saved for the 'end' events of certain elements. These elements are: FILE, CLASS, SUBCLASS, and FRAME.

See Also:
classHierarchyPrint(Element, int), startVNCLASS(Node), startVNSUBCLASS(Node), startDESCRIPTION(Node), popText(), evTexts

popText

private static void popText()
Removes a string from the global event string stack and places it into the class-level global event string. This is so an element which had previously saved this string from its 'start' event, could use it again for its end event.

See Also:
classHierarchyPrint(Element, int), endVNCLASS(Node), endVNSUBCLASS(Node), endFRAME(Node), pushText(), evTexts

pushTextForReplicate

private static void pushTextForReplicate(String text)
Saves the text for a label to be replicated for all elements contained within it. Applies to replicate flag only.

See Also:
startVNCLASS(Node), startVNSUBCLASS(Node), startDESCRIPTION(Node), popTextForReplicate(), replicateLabels

popTextForReplicate

private static void popTextForReplicate()
Removes the most recently stored label text for replication. This method is called whenever a an element which causes nesting closes (i.e. when a file, class, subclass, or frame ends). Applies to replicate flag only.

See Also:
endVNCLASS(Node), endVNSUBCLASS(Node), endFRAME(Node), pushTextForReplicate(String), replicateLabels

replicateLabels

private static void replicateLabels()
Prints all the labels currently stored for replication. The labels printed will be any file, class, subclass, and frame elements that have already been printed due to the appropriate view options being set. This method is called for all printable elements besides file (because nothing would be in this stack). For example, the -r flag will not produce any additional output for the view options -Vm. However, when the -r flag is applied to -Vcm, each member is preceded by all classes and subclasses in which it is contained. Applies to replicate flag only.

See Also:
Inspector.flReplicate

classHierarchyPrint

private static void classHierarchyPrint(Element cls,
                                        int level)
Prints name of the class element provided and the names of all subclass elements contained within, joint with the number of members and frames for each. This method is recursive and it is first called by startVNCLASS(Node) which is provided the document root Element object by Inspector.processNode(Node). This method is only called when the class hierarchy option (-c) is provided. The view operator (-V) is ignored and class counts (-m) are not honored.

Parameters:
cls - the XML Element object representing a class or subclass
level - the depth of the class or subclass (0 represents the main class in file)
See Also:
startVNCLASS(Node), Inspector.incrementTagCounter(String), Inspector.incrementTagCounter(String, int)

startVNCLASS

static void startVNCLASS(Node n)
Prints the text that corresponds to the beginning of the VNCLASS element in the VerbNet XML files. The global event string will be initialized to this text in preparation for the events that fire for the VNCLASS element. As there is exactly one main class (VNCLASS) per file, this method also handles FILE actions. Starting events for both FILE and the VNCLASS element are handled here.

Parameters:
n - the Node object representing the active VNCLASS element
See Also:
iprintln(String), Inspector.incrementTagCounter(String)

endVNCLASS

static void endVNCLASS(Node n)
Prints the text that corresponds to the closing of the VNCLASS element in the VerbNet XML files. No additional text needs to be printed here. However, as there is exactly one main class (VNCLASS) per file, this method also handles FILE actions. Ending events for both FILE and the VNCLASS element are handled here.

Parameters:
n - the Node object representing the active VNCLASS element

startVNSUBCLASS

static void startVNSUBCLASS(Node n)
Prints the text that corresponds to the beginning of the VNSUBCLASS element in the VerbNet XML files. The global event string will be initialized to this text in preparation for the events that fire for the VNSUBCLASS element.

Parameters:
n - the Node object representing the active VNSUBCLASS element
See Also:
iprintln(String), Inspector.incrementTagCounter(String)

endVNSUBCLASS

static void endVNSUBCLASS(Node n)
Prints the text that corresponds to the closing of the VNSUBCLASS element in the VerbNet XML files. No additional text needs to be printed here. Only the 'end' event for the subclass is fired.

Parameters:
n - the Node object representing the active VNSUBCLASS element

startMEMBERS

static void startMEMBERS(Node n)
Prints the text that corresponds to the beginning of the MEMBERS element in the VerbNet XML files. There is no text actually printed here other than the <NO MEMBERS> label if there are no members for this class or subclass and the "no-absence" flag (-z) was not supplied on the command line.

Parameters:
n - the Node object representing the active MEMBERS element
See Also:
iprintln(String)

endMEMBERS

static void endMEMBERS(Node n)
Prints the text that corresponds to the closing of the MEMBERS element in the VerbNet XML files. No specific closing text is needed to be printed, but here is where all the members of the current class or subclass are printed, now that they were all loaded up (and possibly sorted) by startMEMBER(Node).

Parameters:
n - the Node object representing the active MEMBERS element
See Also:
printMembers(), startMEMBER(Node)

startMEMBER

static void startMEMBER(Node n)
Prints the text that corresponds to the beginning of the MEMBER element in the VerbNet XML files. Instead of printing the member at this moment, all the members are stored into a list to be printed later upon executing the endMEMBERS(Node) method. This method adds the members to the list in sorted order if the sort members (-s) flag is provded (Inspector.flSortMembers).

Parameters:
n - the Node object representing the active MEMBER element
See Also:
printMembers(), endMEMBERS(Node)

endMEMBER

static void endMEMBER(Node n)
Prints the text that corresponds to the closing of the MEMBER element in the VerbNet XML files. Although it is specified for completeness, this method does not do anything useful. This is because <!ELEMENT MEMBER EMPTY> in the DTD, so any "closing text" could just be placed at the end of the startMEMBER(Node) method.

Parameters:
n - the Node object representing the active MEMBER element

startTHEMROLES

static void startTHEMROLES(Node n)
Prints the text that corresponds to the beginning of the THEMROLES element in the VerbNet XML files. There is no text actually printed here other than the <NO THEMROLES> label if there are no thematic roles for this class or subclass and the "no-absence" flag (-z) was not supplied on the command line.

Parameters:
n - the Node object representing the active THEMROLES element
See Also:
iprintln(String)

endTHEMROLES

static void endTHEMROLES(Node n)
Prints the text that corresponds to the closing of the THEMROLES element in the VerbNet XML files. No text is needed to be printed here, as THEMROLE elements are printed independently on their own line.

Parameters:
n - the Node object representing the active THEMROLES element

startTHEMROLE

static void startTHEMROLE(Node n)
Prints the text that corresponds to the beginning of the THEMROLE element in the VerbNet XML files. The global event string will be initialized to this text in preparation for the events that fire for the THEMROLE element in endTHEMROLE(org.w3c.dom.Node).

Parameters:
n - the Node object representing the active THEMROLE element
See Also:
iprint(String), Inspector.incrementTagCounter(String)

endTHEMROLE

static void endTHEMROLE(Node n)
Prints the text that corresponds to the closing of the THEMROLE element in the VerbNet XML files. Right now the primary responsibility of this method is to fire both the 'start THEMROLE' and 'end THEMROLE' events. The gloabl event string will have been initialized to the proper THEMROLE label and the events are ready to be fired. Since the THEMROLE element takes up only one line in the console, the 'start' and 'end' events are fired one right after the other.

Parameters:
n - the Node object representing the active THEMROLE element

startSELRESTRS

static void startSELRESTRS(Node n)
Prints the text that corresponds to the beginning of the SELRESTRS element in the VerbNet XML files. The text is also appended to the global event string that will be used in the events that fire for the THEMROLE or SYNTAX (NP or PREP) elements.

Parameters:
n - the Node object representing the active SELRESTRS element

endSELRESTRS

static void endSELRESTRS(Node n)
Prints the text that corresponds to the closing of the SELRESTRS element in the VerbNet XML files. The text is also appended to the global event string that will be used in the events that fire for the THEMROLE or SYNTAX (NP or PREP) elements.

Parameters:
n - the Node object representing the active SELRESTRS element

startSELRESTR

static void startSELRESTR(Node n)
Prints the text that corresponds to the beginning of the SELRESTR element in the VerbNet XML files. The text is also appended to the global event string that will be used in the events that fire for the THEMROLE or SYNTAX (NP or PREP) elements.

Parameters:
n - the Node object representing the active SELRESTR element

endSELRESTR

static void endSELRESTR(Node n)
Prints the text that corresponds to the closing of the SELRESTR element in the VerbNet XML files. Although it is specified for completeness, this method does not do anything useful. This is because <!ELEMENT SELRESTR EMPTY> in the DTD, so any "closing text" could just be placed at the end of the startSELRESTR(Node) method.

Parameters:
n - the Node object representing the active SELRESTR element

startFRAMES

static void startFRAMES(Node n)
Prints the text that corresponds to the beginning of the FRAMES element in the VerbNet XML files. There is no text actually printed here other than the <NO FRAMES> label if there are no frames for this class or subclass and the "no-absence" flag (-z) was not supplied on the command line.

Parameters:
n - the Node object representing the active FRAMES element
See Also:
iprintln(String)

endFRAMES

static void endFRAMES(Node n)
Prints the text that corresponds to the closing of the FRAMES element in the VerbNet XML files. Although no text is actually required at this point, this method does have the important task of printing verb-frame pairs and class counts.

Parameters:
n - the Node object representing the active FRAMES element
See Also:
printVerbFramePairs(), Inspector.printTagCounts(boolean)

startFRAME

static void startFRAME(Node n)
Prints the text that corresponds to the beginning of the FRAME element in the VerbNet XML files. The global event string will be initialized to this text in preparation for the events that fire for the FRAME element or verb-frame pair. The FRAME element is used to print verb-frame pairs.

Parameters:
n - the Node object representing the active FRAME element
See Also:
iprint(String), Inspector.incrementTagCounter(String)

endFRAME

static void endFRAME(Node n)
Prints the text that corresponds to the closing of the FRAME element in the VerbNet XML files. No additional text is required to be printed, but the 'end' events are fired for the FRAME element or verb-frame pair.

Parameters:
n - the Node object representing the active FRAME element

startDESCRIPTION

static void startDESCRIPTION(Node n)
Prints the text that corresponds to the beginning of the DESCRIPTION element in the VerbNet XML files. This adds the bulk of the header label for both verb-frame pairs and regular frames elements. The 'start' events for the verb-frame pairs and regular frame elements are fired here since their text is completed in this method.

Parameters:
n - the Node object representing the active DESCRIPTION element

endDESCRIPTION

static void endDESCRIPTION(Node n)
Prints the text that corresponds to the closing of the DESCRIPTION element in the VerbNet XML files. Although it is specified for completeness, this method does not do anything useful. This is because <!ELEMENT DESCRIPTION EMPTY> in the DTD, so any "closing text" could just be placed at the end of the startDESCRIPTION(Node) method.

Parameters:
n - the Node object representing the active DESCRIPTION element

startEXAMPLES

static void startEXAMPLES(Node n)
Prints the text that corresponds to the beginning of the EXAMPLES element in the VerbNet XML files. No text is currently printed for the start of the examples section. Each example is printed independently on its own line.

Parameters:
n - the Node object representing the active EXAMPLES element

endEXAMPLES

static void endEXAMPLES(Node n)
Prints the text that corresponds to the closing of the EXAMPLES element in the VerbNet XML files. No text is currently printed for the end of the examples section. Each example is printed independently on its own line.

Parameters:
n - the Node object representing the active EXAMPLES element

startEXAMPLE

static void startEXAMPLE(Node n)
Prints the text that corresponds to the beginning of the EXAMPLE element in the VerbNet XML files. The global event string will be initialized to this text in preparation for the events that fire for the EXAMPLE element. There is one line of text output for each VerbNet EXAMPLE element.

Parameters:
n - the Node object representing the active EXAMPLE element
See Also:
iprintln(String), Inspector.incrementTagCounter(String)

endEXAMPLE

static void endEXAMPLE(Node n)
Prints the text that corresponds to the closing of the EXAMPLE element in the VerbNet XML files. Although it is specified for completeness, this method does not do anything useful. This is because <!ELEMENT EXAMPLE (#PCDATA)> in the DTD, so any "closing text" could just be placed at the end of the startEXAMPLE(Node) method. However, for symmetry with other sweeper methods, it does fire the 'start' and 'end' events for the EXAMPLE element.

Parameters:
n - the Node object representing the active EXAMPLE element

startSEMANTICS

static void startSEMANTICS(Node n)
Prints the text that corresponds to the beginning of the SEMANTICS element in the VerbNet XML files. No text is needed to be printed here, as PRED elements are printed independently on their own line (unlike the Unified Verb Index).

Parameters:
n - the Node object representing the active SEMANTICS element

endSEMANTICS

static void endSEMANTICS(Node n)
Prints the text that corresponds to the closing of the SEMANTICS element in the VerbNet XML files. No text is needed to be printed here, as PRED elements are printed independently on their own line (unlike the Unified Verb Index).

Parameters:
n - the Node object representing the active SEMANTICS element

startPRED

static void startPRED(Node n)
Prints the text that corresponds to the beginning of the PRED element in the VerbNet XML files. The global event string will be initialized to this text in preparation for the events that fire for the PRED element. There is one line of text output for each VerbNet PRED element.

Parameters:
n - the Node object representing the active PRED element
See Also:
iprint(String), Inspector.incrementTagCounter(String)

endPRED

static void endPRED(Node n)
Prints the text that corresponds to the closing of the PRED element in the VerbNet XML files. The text is also appended to the global event string that will be used in the events that fire for the SYNTAX element. The events for PRED (SEMANTIC PRED) are fired in this method, since all the text has been accumulated for the predicate and arguments at this point.

Parameters:
n - the Node object representing the active PRED element

startARGS

static void startARGS(Node n)
Prints the text that corresponds to the beginning of the ARG element in the VerbNet XML files. No text is needed to be printed here, as the beginning text for arguments is printed in startPRED(org.w3c.dom.Node).

Parameters:
n - the Node object representing the active ARGS element

endARGS

static void endARGS(Node n)
Prints the text that corresponds to the closing of the ARGS element in the VerbNet XML files. No text is needed to be printed here, as the ending text for arguments is printed in endPRED(org.w3c.dom.Node).

Parameters:
n - the Node object representing the active ARGS element

startARG

static void startARG(Node n)
Prints the text that corresponds to the beginning of the ARG element in the VerbNet XML files. The text is also appended to the global event string that will be used in the events that fire for the PRED (SEMANTIC PRED) element.

Parameters:
n - the Node object representing the active ARG element

endARG

static void endARG(Node n)
Prints the text that corresponds to the closing of the ARG element in the VerbNet XML files. Although it is specified for completeness, this method does not do anything useful. This is because <!ELEMENT ARG EMPTY> in the DTD, so any "closing text" could just be placed at the end of the startARG(Node) method.

Parameters:
n - the Node object representing the active ARG element

startSYNTAX

static void startSYNTAX(Node n)
Prints the text that corresponds to the beginning of the SYNTAX element in the VerbNet XML files. The global event string will be initialized to this text in preparation for the events that fire for the SYNTAX element.

Parameters:
n - the Node object representing the active SYNTAX element
See Also:
iprint(String), Inspector.incrementTagCounter(String)

endSYNTAX

static void endSYNTAX(Node n)
Prints the text that corresponds to the closing of the SYNTAX element in the VerbNet XML files. Right now the primary responsibility of this method is to fire both the 'start SYNTAX' and 'end SYNTAX' events. The gloabl event string will have been appended to by all of SYNTAX's children elements and the events are ready to be fired. Since the SYNTAX element takes up only one line in the console, the 'start' and 'end' events are fired one right after the other.

Parameters:
n - the Node object representing the active SYNTAX element

startNP

static void startNP(Node n)
Prints the text that corresponds to the beginning of the NP element in the VerbNet XML files. The text is also appended to the global event string that will be used in the events that fire for the SYNTAX element.

Parameters:
n - the Node object representing the active NP element

endNP

static void endNP(Node n)
Prints the text that corresponds to the closing of the NP element in the VerbNet XML files. Right now there is not actually any printing required as all NP and SELRESTR/SYNRESTR elements will have been printed before this point and there is no closing text for the NP as a whole.

Parameters:
n - the Node object representing the active NP element

startSYNRESTRS

static void startSYNRESTRS(Node n)
Prints the text that corresponds to the beginning of the SYNRESTRS element in the VerbNet XML files. The text is also appended to the global event string that will be used in the events that fire for the SYNTAX element.

Parameters:
n - the Node object representing the active SYNRESTRS element

endSYNRESTRS

static void endSYNRESTRS(Node n)
Prints the text that corresponds to the closing of the SYNRESTRS element in the VerbNet XML files. The text is also appended to the global event string that will be used in the events that fire for the SYNTAX element.

Parameters:
n - the Node object representing the active SYNRESTRS element

startSYNRESTR

static void startSYNRESTR(Node n)
Prints the text that corresponds to the beginning of the SYNRESTR element in the VerbNet XML files. The text is also appended to the global event string that will be used in the events that fire for the SYNTAX element.

Parameters:
n - the Node object representing the active SYNRESTR element

endSYNRESTR

static void endSYNRESTR(Node n)
Prints the text that corresponds to the closing of the SYNRESTR element in the VerbNet XML files. Although it is specified for completeness, this method does not do anything useful. This is because <!ELEMENT SYNRESTR EMPTY> in the DTD, so any "closing text" could just be placed at the end of the startSYNRESTR(Node) method.

Parameters:
n - the Node object representing the active SYNRESTR element

startPREP

static void startPREP(Node n)
Prints the text that corresponds to the beginning of the PREP element in the VerbNet XML files. The text is also appended to the global event string that will be used in the events that fire for the SYNTAX element. Selectional restriction output may follow this method to show preposition classes.

Parameters:
n - the Node object representing the active PREP element
See Also:
startSELRESTRS(Node), endSELRESTRS(Node)

endPREP

static void endPREP(Node n)
Prints the text that corresponds to the closing of the PREP element in the VerbNet XML files. The text is also appended to the global event string that will be used in the events that fire for the SYNTAX element.

Parameters:
n - the Node object representing the active PREP element

startVERB

static void startVERB(Node n)
Prints the text that corresponds to the beginning of the VERB element in the VerbNet XML files. The text is also appended to the global event string that will be used in the events that fire for the SYNTAX element.

Parameters:
n - the Node object representing the active VERB element

endVERB

static void endVERB(Node n)
Prints the text that corresponds to the closing of the VERB element in the VerbNet XML files. Although it is specified for completeness, this method does not do anything useful. This is because <!ELEMENT VERB EMPTY> in the DTD, so any "closing text" could just be placed at the end of the startVERB(Node) method.

Parameters:
n - the Node object representing the active VERB element

startADJ

static void startADJ(Node n)
Prints the text that corresponds to the beginning of the ADJ element in the VerbNet XML files. The text is also appended to the global event string that will be used in the events that fire for the SYNTAX element.

Parameters:
n - the Node object representing the active ADJ element

endADJ

static void endADJ(Node n)
Prints the text that corresponds to the closing of the ADJ element in the VerbNet XML files. Although it is specified for completeness, this method does not do anything useful. This is because <!ELEMENT ADJ EMPTY> in the DTD, so any "closing text" could just be placed at the end of the startADJ(Node) method.

Parameters:
n - the Node object representing the active ADJ element

startADV

static void startADV(Node n)
Prints the text that corresponds to the beginning of the ADV element in the VerbNet XML files. The text is also appended to the global event string that will be used in the events that fire for the SYNTAX element.

Parameters:
n - the Node object representing the active ADV element

endADV

static void endADV(Node n)
Prints the text that corresponds to the closing of the ADV element in the VerbNet XML files. Although it is specified for completeness, this method does not do anything useful. This is because <!ELEMENT ADV EMPTY> in the DTD, so any "closing text" could just be placed at the end of the startADV(Node) method.

Parameters:
n - the Node object representing the active ADV element

startLEX

static void startLEX(Node n)
Prints the text that corresponds to the beginning of the LEX element in the VerbNet XML files. The text is also appended to the global event string that will be used in the events that fire for the SYNTAX element.

Parameters:
n - the Node object representing the active LEX element

endLEX

static void endLEX(Node n)
Prints the text that corresponds to the closing of the LEX element in the VerbNet XML files. Although it is specified for completeness, this method does not do anything useful. This is because <!ELEMENT LEX EMPTY> in the DTD, so any "closing text" could just be placed at the end of the startLEX(Node) method.

Parameters:
n - the Node object representing the active LEX element

printMembers

private static void printMembers()
Prints the text for all the members in this class. The members would have just been printed in startMEMBER(Node) as they were encountered but in order to implement the sorting feature, all the members need to be visited and saved before the printing can occur. The body of the loop follows the standard format of a single sweeper method, as described in Sweeper class's description.

See Also:
startMEMBER(Node), endMEMBERS(Node), iprintln(String), Inspector.incrementTagCounter(String)

printVerbFramePairs

private static void printVerbFramePairs()
Prints all verb-frame pairs if the Inspector is running in verb-frame pair mode. This method is called once a FRAMES element has completed, signalling the point right before the start of a new class or subclass. This is the point when the verb-frame pairs should be printed. The members array has already been properly loaded and all the frames visited up to this point since the main (root) class has been given to the Sweeper class via setFrameList(ArrayList). This method either visits verb-frame pairs for this class or subclass in verb-major order or frame-major order depending on the "invert-verb-frame-pair-order" flag (-v, Inspector.flVFPairsInvert).

See Also:
iprint(String), endFRAMES(Node), startMEMBER(Node), curVFFrameList, Inspector.processNodeByPairs(Node, ArrayList)