Revision: 14174 http://gate.svn.sourceforge.net/gate/?rev=14174&view=rev Author: adamfunk Date: 2011-07-25 14:46:01 +0000 (Mon, 25 Jul 2011)
Log Message: ----------- Using optional/empty labels from the LHS in the RHS Modified Paths: -------------- userguide/trunk/jape.tex Modified: userguide/trunk/jape.tex =================================================================== --- userguide/trunk/jape.tex 2011-07-25 01:27:20 UTC (rev 14173) +++ userguide/trunk/jape.tex 2011-07-25 14:46:01 UTC (rev 14174) @@ -80,8 +80,8 @@ referred to on the RHS by means of labels that are attached to pattern elements. Consider the following example: -\begin{small}\begin{verbatim} - +\begin{small} +\begin{verbatim} Phase: Jobtitle Input: Lookup Options: control = appelt debug = true @@ -96,10 +96,9 @@ :jobtitle --> :jobtitle.JobTitle = {rule = "JobTitle1"} +\end{verbatim} +\end{small} - -\end{verbatim}\end{small} - The LHS is the part preceding the `\verb|-->|' and the RHS is the part following it. The LHS specifies a pattern to be matched to the annotated GATE document, whereas the RHS specifies what is to be done to the matched text. In this example, we have a @@ -161,15 +160,18 @@ To match a simple text string, you need to refer to a feature on an annotation that contains the string; for example, -\begin{small}\begin{verbatim} +\begin{small} +\begin{verbatim} {Token.string == "of"} -\end{verbatim}\end{small} +\end{verbatim} +\end{small} The following grammar shows a sequence of strings being matched. Bracketing, along with the `or' operator, is used to define how the strings should come together: -\begin{small}\begin{verbatim} +\begin{small} +\begin{verbatim} Phase: UrlPre Input: Token SpaceToken Options: control = appelt @@ -188,7 +190,8 @@ ):urlpre --> :urlpre.UrlPre = {rule = "UrlPre"} -\end{verbatim}\end{small} +\end{verbatim} +\end{small} Alternatively you could use the `string' metaproperty. See Section~\ref{sec:jape:metaproperties} for an example of using metaproperties. @@ -201,21 +204,26 @@ from a gazetteer, tokeniser, or other module. For example, the following will match a Lookup annotation: -\begin{small}\begin{verbatim} +\begin{small} +\begin{verbatim} {Lookup} -\end{verbatim}\end{small} +\end{verbatim} +\end{small} The following will match if there is \emph{not} a Lookup annotation at this location: -\begin{small}\begin{verbatim} +\begin{small} +\begin{verbatim} {!Lookup} -\end{verbatim}\end{small} +\end{verbatim} +\end{small} The following rule shows several different annotation types being matched. We also see a string being matched, and again, the use of the `or' operator: -\begin{small}\begin{verbatim} +\begin{small} +\begin{verbatim} Rule: Known Priority: 100 ( @@ -232,7 +240,8 @@ ):known --> {} -\end{verbatim}\end{small} +\end{verbatim} +\end{small} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \subsect{Using Attributes and Values} @@ -255,7 +264,8 @@ In the following rule, the `category' feature of the `Token' annotation is used, along with the `equals' operator: -\begin{small}\begin{verbatim} +\begin{small} +\begin{verbatim} Rule: Unknown Priority: 50 ( @@ -264,7 +274,8 @@ :unknown --> :unknown.Unknown = {kind = "PN", rule = Unknown} -\end{verbatim}\end{small} +\end{verbatim} +\end{small} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \subsect[sec:jape:metaproperties]{Using Meta-Properties} @@ -282,28 +293,34 @@ space is removed). \end{itemize} -\begin{small}\begin{verbatim} +\begin{small} +\begin{verbatim} {X@length > 5}:label-->:label.New = {} -\end{verbatim}\end{small} +\end{verbatim} +\end{small} \verb=@string= is also available in assignments on the right-hand side: -\begin{small}\begin{verbatim} +\begin{small} +\begin{verbatim} {X@length > 5}:label-->:label.New = {somefeat = :label.X@string } -\end{verbatim}\end{small} +\end{verbatim} +\end{small} As well as getting the string covered by a single annotation it is also possible to omit the annotation type and get the string spanned by all the annotations bound to a label, for example: -\begin{small}\begin{verbatim} +\begin{small} +\begin{verbatim} ( {X@length > 5} ({Y}+):ys ):label --> :label.New = { somefeat = :ys@string } -\end{verbatim}\end{small} +\end{verbatim} +\end{small} If several Y annotations were included in the match, the New annotation's feature would be set to the string starting at the beginning of the leftmost Y @@ -321,24 +338,29 @@ other programming languages, which can be referenced anywhere where a normal string literal, boolean or numeric value could be used, on the left- or right-hand side of a rule. In the simplest case templates can be constants: -\begin{small}\begin{verbatim} +\begin{small} +\begin{verbatim} Template: source = "Interesting entity finder" Template: threshold = 0.6 -\end{verbatim}\end{small} +\end{verbatim} +\end{small} % The templates can be used in rules by providing their names in square brackets: -\begin{small}\begin{verbatim} +\begin{small} +\begin{verbatim} Rule: InterestingLocation ( {Location.score >= [threshold]} ):loc --> :loc.Entity = { type = Location, source = [source] } -\end{verbatim}\end{small} +\end{verbatim} +\end{small} % The JAPE grammar parser substitutes the template values for their references when the grammar is parsed. Thus the example rule is equivalent to -\begin{small}\begin{verbatim} +\begin{small} +\begin{verbatim} Rule: InterestingLocation ( {Location.score >= 0.6} @@ -346,7 +368,8 @@ --> :loc.Entity = { type = Location, source = "Interesting entity finder" } -\end{verbatim}\end{small} +\end{verbatim} +\end{small} % The advantage of using templates is that if there are many rules in the grammar that all reference the {\tt threshold} template then it is possible to change @@ -354,23 +377,28 @@ The name ``template'' stems from the fact that templates whose value is a string can contain {\it parameters}, specified using \verb|${name}| notation: -\begin{small}\begin{verbatim} +\begin{small} +\begin{verbatim} Template: url = "http://gate.ac.uk/${path}" -\end{verbatim}\end{small} +\end{verbatim} +\end{small} % When a template containing parameters is referenced, values for the parameters may be specified: -\begin{small}\begin{verbatim} +\begin{small} +\begin{verbatim} ... --> :anchor.Reference = { page = [url path = "userguide"] } -\end{verbatim}\end{small} +\end{verbatim} +\end{small} % This is equivalent to \verb|page = "http://gate.ac.uk/userguide"|. Multiple parameter value assignments are separated by commas, for example: % -\begin{small}\begin{verbatim} +\begin{small} +\begin{verbatim} Template: proton = "http://proton.semanticweb.org/2005/04/proton${mod}#${n}" @@ -379,7 +407,8 @@ // equivalent to // {Lookup.class == // "http://proton.semanticweb.org/2005/04/protonkm#Mention"} -\end{verbatim}\end{small} +\end{verbatim} +\end{small} The parser will report an error if a value is specified for a parameter that is not declared by the referenced template, for example @@ -392,7 +421,8 @@ unchanged. Combined with the fact that the value for a template definition can itself be a reference to a previously-defined template, this allows for idioms like the following: -\begin{small}\begin{verbatim} +\begin{small} +\begin{verbatim} Template: proton = "http://proton.semanticweb.org/2005/04/proton${mod}#${n}" Template: pkm = [proton mod="km"] @@ -402,7 +432,8 @@ ({Lookup.class == [ptop n="Person"]}):look --> :look.Mention = { class = [pkm n="Mention"], of = "Person"} -\end{verbatim}\end{small} +\end{verbatim} +\end{small} (This example is inspired by the ontology-aware JAPE matching mode described in section~\ref{sec:ontologies:ontology-aware-jape}.) @@ -424,7 +455,8 @@ TempPerson annotation is labelled `person' and is given the new annotation `Person'. -\begin{small}\begin{verbatim} +\begin{small} +\begin{verbatim} Rule: PersonJobTitle Priority: 20 @@ -437,13 +469,15 @@ --> :jobtitle.JobTitle = {rule = "PersonJobTitle"}, :person.Person = {kind = "personName", rule = "PersonJobTitle"} -\end{verbatim}\end{small} +\end{verbatim} +\end{small} Similarly, labelled patterns can be nested, as in the example below, where the whole pattern is annotated as Person, but within the pattern, the jobtitle is annotated as JobTitle. -\begin{small}\begin{verbatim} +\begin{small} +\begin{verbatim} Rule: PersonJobTitle2 Priority: 20 @@ -456,7 +490,8 @@ --> :jobtitle.JobTitle = {rule = "PersonJobTitle"}, :person.Person = {kind = "personName", rule = "PersonJobTitle"} -\end{verbatim}\end{small} +\end{verbatim} +\end{small} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \subsect[sec:jape:lhsmacro]{LHS Macros} @@ -468,7 +503,8 @@ `NUMBER\_WORDS', and the rule `MoneyCurrencyUnit' then makes use of `AMOUNT\_NUMBER': -\begin{small}\begin{verbatim} +\begin{small} +\begin{verbatim} Phase: Number Input: Token Lookup Options: control = appelt @@ -517,7 +553,8 @@ ) :number --> :number.Money = {kind = "number", rule = "MoneyCurrencyUnit"} -\end{verbatim}\end{small} +\end{verbatim} +\end{small} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \subsect[sec:jape:context]{Using Context} @@ -537,7 +574,8 @@ macro for `year') would mean that a year would only be recognised if it occurs preceded by the words `in' or `by': -\begin{small}\begin{verbatim} +\begin{small} +\begin{verbatim} Rule: YearContext1 ({Token.string == "in"}| @@ -546,14 +584,16 @@ (YEAR) :date --> :date.Timex = {kind = "date", rule = "YearContext1"} -\end{verbatim}\end{small} +\end{verbatim} +\end{small} Similarly, the following rule (assuming an appropriate macro for `email') would mean that an email address would only be recognised if it occurred inside angled brackets (which would not themselves form part of the entity): -\begin{small}\begin{verbatim} +\begin{small} +\begin{verbatim} Rule: Emailaddress1 ({Token.string == `<'}) ( @@ -563,12 +603,14 @@ ({Token.string == `>'}) --> :email.Address= {kind = "email", rule = "Emailaddress1"} -\end{verbatim}\end{small} +\end{verbatim} +\end{small} Also, it is possible to specify the constraint that one annotation must start at the same place as another. For example: -\begin{small}\begin{verbatim} +\begin{small} +\begin{verbatim} Rule: SurnameStartingWithDe ( {Token.string == "de", @@ -577,7 +619,8 @@ ):de --> :de.Surname = {prefix = "de"} -\end{verbatim}\end{small} +\end{verbatim} +\end{small} This rule would match anywhere where a Token with string `de' and a Lookup with majorType `name' and minorType `surname' start at the same offset in @@ -600,7 +643,8 @@ constraint. For example, in this statement, the `category' of `Token' must equal `NNP': -\begin{small}\begin{verbatim} +\begin{small} +\begin{verbatim} Rule: Unknown Priority: 50 ( @@ -609,13 +653,15 @@ :unknown --> :unknown.Unknown = {kind = "PN", rule = Unknown} -\end{verbatim}\end{small} +\end{verbatim} +\end{small} However, it is equally acceptable to have multiple constraints in a statement. In this example, the `majorType' of `Lookup' must be `name' {\bf and} the `minorType' must be `surname': -\begin{small}\begin{verbatim} +\begin{small} +\begin{verbatim} Rule: Surname ( {Lookup.majorType == "name", @@ -623,14 +669,16 @@ ):surname --> :surname.Surname = {} -\end{verbatim}\end{small} +\end{verbatim} +\end{small} As we saw in Section~\ref{sec:jape:context}, the constraints may refer to different annotations. In this example, in addition to the constraints on the `majorType' and `minorType' of `Lookup', we also have a constraint on the `string' of `Token': -\begin{small}\begin{verbatim} +\begin{small} +\begin{verbatim} Rule: SurnameStartingWithDe ( {Token.string == "de", @@ -639,7 +687,8 @@ ):de --> :de.Surname = {prefix = "de"} -\end{verbatim}\end{small} +\end{verbatim} +\end{small} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \subsect[sec:jape:negation]{Negation} @@ -654,14 +703,16 @@ constrain the locations at which the positive constraint can match. For example: -\begin{small}\begin{verbatim} +\begin{small} +\begin{verbatim} Rule: PossibleName ( {Token.orth == "upperInitial", !Lookup} ):name --> :name.PossibleName = {} -\end{verbatim}\end{small} +\end{verbatim} +\end{small} This rule would match any uppercase-initial Token, but only where there is no Lookup annotation starting at the same location. The general rule is that a @@ -677,14 +728,16 @@ Any constraint can be negated, for example: -\begin{small}\begin{verbatim} +\begin{small} +\begin{verbatim} Rule: SurnameNotStartingWithDe ( {Surname, !Token.string ==~ "[Dd]e"} ):name --> :name.NotDe = {} -\end{verbatim}\end{small} +\end{verbatim} +\end{small} This would match any Surname annotation that does not start at the same place as a Token with the string `de' or `De'. Note that this is subtly different @@ -711,7 +764,8 @@ have the POS category PRP (personal pronoun). So we specify a negative rule that will fire if the PRP category exists, thereby preventing the positive rule from firing. -\begin{small}\begin{verbatim} +\begin{small} +\begin{verbatim} Rule: NotPersonReverse Priority: 20 // we don't want to match 'Jones, I' @@ -734,7 +788,8 @@ (INITIALS)? ) :person --> -\end{verbatim}\end{small} +\end{verbatim} +\end{small} % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -743,13 +798,17 @@ To specify a single or double quote as a string, precede it with a backslash, e.g. -\begin{small}\begin{verbatim} +\begin{small} +\begin{verbatim} {Token.string=="\""} -\end{verbatim}\end{small} will match a double quote. +\end{verbatim} +\end{small} will match a double quote. For other special characters, such as `\$', enclose it in double quotes, e.g. -\begin{small}\begin{verbatim} +\begin{small} +\begin{verbatim} {Token.category == "PRP$"} -\end{verbatim}\end{small} +\end{verbatim} +\end{small} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \sect[sec:jape:operators]{LHS Operators in Detail} @@ -780,7 +839,8 @@ In the following example, you can see the `$\mid $' and `?' operators being used: -\begin{small}\begin{verbatim} +\begin{small} +\begin{verbatim} Rule: LocOrganization Priority: 50 @@ -792,15 +852,20 @@ ) :orgName --> :orgName.TempOrganization = {kind = "orgName", rule=LocOrganization} -\end{verbatim}\end{small} +\end{verbatim} +\end{small} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \subsubsect[sec:jape:ranges]{Range Notation} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% A range notation can also be added. e.g. -\begin{small}\begin{verbatim}({Token})[1,3]\end{verbatim}\end{small} matches one to three Tokens -in a row. \begin{small}\begin{verbatim}({Token.kind == number})[3]\end{verbatim}\end{small} matches +\begin{small} +\begin{verbatim}({Token})[1,3]\end{verbatim} +\end{small} matches one to three Tokens +in a row. \begin{small} +\begin{verbatim}({Token.kind == number})[3]\end{verbatim} +\end{small} matches exactly 3 number Tokens in a row. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -966,31 +1031,33 @@ purpose of the `rule' attribute is simply to ease the process of manual rule validation). -\begin{small}\begin{verbatim} +\begin{small} +\begin{verbatim} Rule: GazLocation ( {Lookup.majorType == location} ) :location --> :location.Enamex = {kind="location", rule=GazLocation} -\end{verbatim}\end{small} +\end{verbatim} +\end{small} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \subsect{Copying Feature Values from the LHS to the RHS} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - JAPE provides limited support for copying annotation feature values from the left to the right hand side of a rule, for example: -\begin{small}\begin{verbatim} +\begin{small} +\begin{verbatim} Rule: LocationType - ( {Lookup.majorType == location} ):loc --> :loc.Location = {rule = "LocationType", type = :loc.Lookup.minorType} -\end{verbatim}\end{small} +\end{verbatim} +\end{small} This will set the `type' feature of the generated location to the value of the `minorType' feature from the `Lookup' annotation bound to the loc label. If @@ -1013,8 +1080,32 @@ you want to copy several feature values from the same left hand side annotation, you should consider using Java code on the right hand side of your rule (see Section \ref{sec:jape:javarhs}). - %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\subsect[sec:jape:optional]{Optional or Empty Labels} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +The JAPE compiler will throw an exception if the RHS of a rule uses a label +missing from the LHS. However, you can use labels from optional parts of the +LHS. +\begin{small} +\begin{verbatim} +Rule: NP +( (({Token.category == "DT"}):det)? + (({Token.category ==~ "JJ.*"})*):adjs + (({Token.category ==~ "NN.*"})+):noun +):np +--> +:det.Determiner = {}, +:adjs.Adjectives = {}, +:noun.Nouns = {}, +:np.NP = {} +\end{verbatim} +\end{small} +%% +This rule can match a sequence consisting of only one Token whose category +feature (POS tag) starts with \verb!NN!; in this case the \verb!:det! binding is +null and the \verb!:adjs! binding is an empty annotation set, and both of them +are silently ignored when the RHS of the rule is executed. +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \subsect{RHS Macros} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -1023,7 +1114,8 @@ case, the label (which matches the label on the LHS of the rule) should be included in the macro. Below we give an example of using a macro on the RHS: -\begin{small}\begin{verbatim} +\begin{small} +\begin{verbatim} Macro: UNDERSCORES_OKAY // separate :match // lines { @@ -1058,7 +1150,8 @@ ({Token.string == "SPANISH"}) :match)-->UNDERSCORES_OKAY // no label here, only macro name - \end{verbatim}\end{small} + \end{verbatim} +\end{small} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \sect[sec:jape:priority]{Use of Priority} @@ -1079,14 +1172,18 @@ rules, but the matching will continue from the next offset to the current one. For example, where [] are annotations of type Ann -\begin{small}\begin{verbatim} +\begin{small} +\begin{verbatim} [aaa[bbb]] [ccc[ddd]] -\end{verbatim}\end{small} +\end{verbatim} +\end{small} then a rule matching \{Ann\} and creating \{Ann-2\} for the same spans will generate: -\begin{small}\begin{verbatim} +\begin{small} +\begin{verbatim} BRILL: [aaabbb] [cccddd] ALL: [aaa[bbb]] [ccc[ddd]] -\end{verbatim}\end{small} +\end{verbatim} +\end{small} With the `first' style, a rule fires for the first match that's found. This makes it inappropriate for rules that end in `+' or `?' or @@ -1118,7 +1215,8 @@ For example, the following two rules for location could potentially match the same text. -\begin{small}\begin{verbatim} +\begin{small} +\begin{verbatim} Rule: Location1 Priority: 25 @@ -1139,7 +1237,8 @@ ({Lookup.majorType == location}):location ) --> :location.Name = {kind = "location", rule=GazLocation} -\end{verbatim}\end{small} +\end{verbatim} +\end{small} Assume we have the text `China sea', that `China' is defined in the gazetteer as `location', and that sea is defined as @@ -1268,7 +1367,8 @@ and therefore we must specify the annotation set we are referring to. -\begin{small}\begin{verbatim} +\begin{small} +\begin{verbatim} Rule: FirstName ( @@ -1284,7 +1384,8 @@ outputAS.add(person.firstNode(), person.lastNode(), "FirstPerson", features); } -\end{verbatim}\end{small} +\end{verbatim} +\end{small} The second rule (contained in a subsequent grammar phase) makes use of annotations produced by the first rule described above. Instead of @@ -1300,7 +1401,8 @@ another grammar phase. -\begin{small}\begin{verbatim} +\begin{small} +\begin{verbatim} Rule: GazPersonFirst ( {FirstPerson} @@ -1318,20 +1420,23 @@ features); inputAS.removeAll(person); } -\end{verbatim}\end{small} +\end{verbatim} +\end{small} You can combine Java blocks and normal assignments (separating each block or assignment from the next with a comma), so the above RHS could be more simply expressed as -\begin{small}\begin{verbatim} +\begin{small} +\begin{verbatim} --> :person.TempPerson = { gender = :person.FirstPerson.gender, rule = "GazPersonFirst" }, { inputAS.removeAll(bindings.get("person")); } -\end{verbatim}\end{small} +\end{verbatim} +\end{small} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \subsect{A More Complex Example} @@ -1355,7 +1460,8 @@ annotation and the title has no gender information, then we simply create the Person annotation with no gender feature. -\begin{small}\begin{verbatim} +\begin{small} +\begin{verbatim} Rule: PersonTitle Priority: 35 /* allows Mr. Jones, Mr Fred Jones etc. */ @@ -1403,7 +1509,8 @@ outputAS.add(personSet.firstNode(), personSet.lastNode(), "TempPerson", features); } -\end{verbatim}\end{small} +\end{verbatim} +\end{small} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -1430,7 +1537,8 @@ `message' is found, we add the feature `genre' with value `email' to the document. -\begin{small}\begin{verbatim} +\begin{small} +\begin{verbatim} Rule: Email Priority: 150 @@ -1441,7 +1549,8 @@ { doc.getFeatures().put("genre", "email"); } -\end{verbatim}\end{small} +\end{verbatim} +\end{small} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -1467,7 +1576,8 @@ by the HMM application. To inspect all JAPE grammars, see the muse/applications/hmm directory in the distribution. -\begin{small}\begin{verbatim} +\begin{small} +\begin{verbatim} Phase: NEInfo Input: Token Organization Location Person @@ -1544,7 +1654,8 @@ entityAnn.getFeatures().put("coref_chain_length", "0"); } -\end{verbatim}\end{small} +\end{verbatim} +\end{small} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \subsect[sec:jape:namedjavablocks]{Using Named Blocks} @@ -1553,7 +1664,8 @@ For the common case where a Java block refers just to the annotations from a single left-hand-side binding, JAPE provides a shorthand notation: % -\begin{small}\begin{verbatim} +\begin{small} +\begin{verbatim} Rule: RemoveDoneFlag ( @@ -1564,11 +1676,13 @@ Annotation theInstance = instAnnots.iterator().next(); theInstance.getFeatures().remove("flag"); } -\end{verbatim}\end{small} +\end{verbatim} +\end{small} This rule is equivalent to the following: % -\begin{small}\begin{verbatim} +\begin{small} +\begin{verbatim} Rule: RemoveDoneFlag ( @@ -1582,7 +1696,8 @@ theInstance.getFeatures().remove("flag"); } } -\end{verbatim}\end{small} +\end{verbatim} +\end{small} A label \verb|:<label>| on a Java block creates a local variable \verb|<label>Annots| within the Java block which is the \verb|AnnotationSet| @@ -1762,8 +1877,15 @@ \item avoid the use of the * and + operators. Replace them with range queries where possible. For example, instead of -\begin{small}\begin{verbatim}({Token})*\end{verbatim}\end{small} use -\begin{small}\begin{verbatim}({Token})[0,3] \end{verbatim}\end{small} +\begin{small} +\begin{verbatim}({Token})* +\end{verbatim} +\end{small} + use +\begin{small} +\begin{verbatim}({Token})[0,3] +\end{verbatim} +\end{small} if you can predict that you won't need to recognise a string of Tokens longer than 3. % This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------------ Storage Efficiency Calculator This modeling tool is based on patent-pending intellectual property that has been used successfully in hundreds of IBM storage optimization engage- ments, worldwide. Store less, Store more with what you own, Move data to the right place. Try It Now! http://www.accelacomm.com/jaw/sfnl/114/51427378/ _______________________________________________ GATE-cvs mailing list GATE-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gate-cvs