The
Regular Expressions
Regular expressions
are Annotation sources intended for structure-based annotation of documents,
i.e. annotating all words / phrases in a document that match a particular regular
expression. For details on the syntax of the regaulr expression, please refer to
the corresponding page in the JAVA API documentation
(http://java.sun.com/j2se/1.4.2/docs/api/java/util/regex/Pattern.html).
The Regular Expressions Menu
The regular expressions menu provides access to
functions for managing and applying regular rxpressions:
- Create: Create
a new regular expression.
- Load: Create
a new regular expression loading it from a text file from the local file
system.
- Edit: Open
the regular expression editor dialog.
- Apply: Select a regular expression
and use it to annotate all words / phrases in the document currently
selected that match that regular expression. This function is also available
through the Apply Regular Expression option in the Tools
menu.
The Edit Regular Expressions Dialog
The dialog for regular expression management is
accessible through the Edit function in the regular expressions menu. On the
right of the dialog, a list displays all existing regular expressions. In the
middle, it displays the regular expression currently selected in that list for
editing. The editor window allows line breaks and indentation in order to make
complex regular expressions easier to handle. Below the editor, four buttons
provide functions for editing the regular expression currently selected:
- Refresh: Refresh
the editor display. This will re-format the regular expression in order to
restore a clear view after more extensive editing.
- Validate: Check
if the regular expression currently marked in the editor is a valid pattern.
If nothing is marked in the editor, the entire regular expression is
validated.
- Test: Test
the regular expression by applying it to the document currently selected in
the GoldenGATE main window. This function does not change the document in
any way, it just displays the Annotations the regular expression would
extract in its current status.
- Enumeration: Produce
an enumeration matcher from the part currently selected in the editor. An
enumeration matcher is a pattern that matches a number of matches of the
original pattern, separated by commas. Example: The pattern "[A-Z][a-z]+"
matches a capitalized word, e.g. a proper name like "Jack",
"John", and "Jill" in "Jack, John and Jill".
The enumeration matcher "((([A-Z][a-z]+)\,\s)*([A-Z][a-z]+)((\,?\sand\s([A-Z][a-z]+))))"
would now match the entire enumeration as a whole.
At the top of the dialog, a line of buttons
provides the functionality for managing the regular expressions:
- Create: Create
a new regular expression.
- Clone: Create
a new regular expression, copying the one currently selected.
- Load: Create
a new regular expression loading a it from a text file from the local file system.
- Delete: Delete
the regular expression currently selected.
Applying Regular Expressions
Whenever a regular expression is to be applied,
there are five additional parameters providing influence on the behavior of the regular expression
based annotation:
- Max Tokens: Maximum
number of Tokens a match of the regular expression can comprise. 0 means no
limit. Attention: This will try to match any sub-sequence of the document's
Tokens, causing high computational effort in larger documents.
- Start Exclude: A
gazetteer list (see Lists) containing Tokens a match must not start with.
Matches of the regular expression starting with a Token contained in this
list are excluded.
- Exclude: A
gazetteer list (see Lists) containing Tokens a match must not contain.
Matches of the regular expression containing a Token contained in this list
are excluded.
- Overlapping Matches: If
checked, every word or phrase in the document is annotated if it is
contained in the regular expression, regardless of overlaps. Otherwise, only
the longest match is annotated from each set of overlapping matches.
- Ignore Linebreaks: If
checked, line breaks are ignored while matching. Otherwise, matching stops
at the end of a line, starting off at the beginning of the next one.