|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Objectat.ofai.gate.JAPEUtils
public class JAPEUtils
This class makes it easier to access and handle document features and annotations from within the Java code in a JAPE RHS. Remember that the following variables are usable in the Java code present in the RHS:
| Constructor Summary | |
|---|---|
JAPEUtils()
|
|
| Method Summary | |
|---|---|
static void |
addToFeatureDouble(gate.Document doc,
java.lang.String theKey,
double byThis)
Increments a document feature of type double. |
static void |
addToFeatureLong(gate.Document doc,
java.lang.String theKey,
long byThis)
Increments the value of a document feature of type long by a specific amount. |
static java.lang.String |
annotationString(gate.Document doc,
gate.Annotation annotation)
Returns the string of the annotation. |
static int |
annotationStringLength(gate.Document doc,
gate.Annotation annotation)
Returns the string length of the annotation. |
static void |
appendToFeatureString(gate.Document doc,
java.lang.String theKey,
java.lang.String appendThis)
Appends a string to a feature of type string. |
static int |
countAnnotationNums(gate.Document doc,
gate.Annotation annotation)
Returns the count of all numbers in the annotation. |
static gate.Annotation |
getAnnotation4Binding(java.util.Map bindings,
java.lang.String bindingname)
Returns an annotation for a JAPE rule binding. |
static double |
getFeatureDouble(gate.Document doc,
java.lang.String theKey)
Gets the value of a document feature of type double. |
static java.lang.Long |
getFeatureLong(gate.Document doc,
java.lang.String theKey)
Gets the value of a document feature of type long. |
static java.lang.String |
getFeatureString(gate.Document doc,
java.lang.String theKey)
Gets the value of a feature of type string. |
static void |
removeAnnotationsFromAnnotation(gate.Document doc,
gate.AnnotationSet inset,
gate.Annotation annotation,
java.lang.String sInside,
java.lang.String sRemove)
Removes Annotations inside an Annotation |
static void |
removeFeature(gate.Document doc,
java.lang.String name)
|
static void |
setFeatureDouble(gate.Document doc,
java.lang.String theKey,
double theValue)
Sets the value of a document feature of type double. |
static void |
setFeatureLong(gate.Document doc,
java.lang.String theKey,
long theValue)
Sets the value of a document feature of type long. |
static void |
setFeatureString(gate.Document doc,
java.lang.String theKey,
java.lang.String theValue)
Sets the value of a feature of type string. |
static java.lang.String |
toXML(java.lang.String tagName,
java.lang.String theValue)
Formats a string as XML. |
static java.lang.String |
toXMLAnnotationAnnotations(gate.Document doc,
gate.AnnotationSet inset,
gate.Annotation annotation,
java.lang.String namelist)
Formats annotations within an annotation as XML. |
static java.lang.String |
toXMLAnnotationFeatures(gate.Annotation annotation)
Creates a XML chunk for an annotation. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public JAPEUtils()
| Method Detail |
|---|
public static void addToFeatureLong(gate.Document doc,
java.lang.String theKey,
long byThis)
If the feature does not exist yet, it will be created and assumed to be 0.
Example:
at.ofai.gate.JAPEUtils.addToFeatureInt(doc,"myFeature",12);
doc - the document that contains the featuretheKey - the name of the featurebyThis - the integer value by which to increment the original value.
public static void setFeatureLong(gate.Document doc,
java.lang.String theKey,
long theValue)
doc - the document for which the feature is being settheKey - the name of the featuretheValue - the value to which the feature is set
public static java.lang.Long getFeatureLong(gate.Document doc,
java.lang.String theKey)
doc - the document that contains the featuretheKey - the name of the feature
public static void addToFeatureDouble(gate.Document doc,
java.lang.String theKey,
double byThis)
doc - the document for which to set the featuretheKey - the name of the featurebyThis - the increment value
public static void setFeatureDouble(gate.Document doc,
java.lang.String theKey,
double theValue)
doc - the document that contains the featuretheKey - the name of the featuretheValue - the value
public static double getFeatureDouble(gate.Document doc,
java.lang.String theKey)
doc - the document that contains the feature.theKey - the name of the feature.
public static void appendToFeatureString(gate.Document doc,
java.lang.String theKey,
java.lang.String appendThis)
If the feature does not exist it is treated as if it would contain the empty string.
doc - the document that contains the feature.theKey - the name of the feature.appendThis - the string value that is appended to the end of the
existing value.
public static void setFeatureString(gate.Document doc,
java.lang.String theKey,
java.lang.String theValue)
doc - the document that contains the feature.theKey - the name of the feature.theValue - the string to be used
public static java.lang.String getFeatureString(gate.Document doc,
java.lang.String theKey)
doc - the document that contains the feature.theKey - the name of the feature.
public static void removeFeature(gate.Document doc,
java.lang.String name)
public static java.lang.String toXML(java.lang.String tagName,
java.lang.String theValue)
tagName - the tagname that will enclose the string.theValue - the string value to enclose in the tag.public static java.lang.String toXMLAnnotationFeatures(gate.Annotation annotation)
Example: the annotation Person = { firstname = "John", lastname = "Smith" }
will be converted to
<pre><Person><firstname>John</firstname>
<lastname>Smith</lastname></Person>
annotation - the annotation of which the type name will be used
as tagname and the features will be used as enclosed tags.
public static int annotationStringLength(gate.Document doc,
gate.Annotation annotation)
doc - the document that contains the annotaion.annotation - the document for which to generate the XML.
public static java.lang.String annotationString(gate.Document doc,
gate.Annotation annotation)
doc - the document that contains the annotaion.annotation - the document for which to generate the XML.
public static gate.Annotation getAnnotation4Binding(java.util.Map bindings,
java.lang.String bindingname)
This function takes the bindings variable and the name of the binding and returns the corresponding annotation.
bindings - the bindings datastructure from the JAPE rule LHS.bindingname - the name of the binding from the JAPE rule LHS.
public static int countAnnotationNums(gate.Document doc,
gate.Annotation annotation)
doc - the document that contains the annotaion.annotation - the document for which to generate the XML.
public static void removeAnnotationsFromAnnotation(gate.Document doc,
gate.AnnotationSet inset,
gate.Annotation annotation,
java.lang.String sInside,
java.lang.String sRemove)
doc - the document that contains the annotaion.inset - the input annotation set - usually the variable inputAS.annotation - the document.sInsode - the Name of the annotation.sRemove - a string that contains the names of those annotations
that should be removed, seperated by commas (but not additional whitespace)
public static java.lang.String toXMLAnnotationAnnotations(gate.Document doc,
gate.AnnotationSet inset,
gate.Annotation annotation,
java.lang.String namelist)
This returns a string formatted as XML where the outermost tag corresponds to the name of the annotation passed as a parameter. This tag encloses the string of the annotation and in addition nested tags for all contained annotations whose names are mentioned in the namelist parameter.
The XML tags are sorted the same way like the annotations are found inside the document.
doc - the document that contains the annotaion.inset - the input annotation set - usually the variable inputAS.annotation - the document for which to generate the XML.namelist - a string that contains the names of those annotations
that should be included, seperated by commas (but not additional whitespace)
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||