Revision: 14687
http://gate.svn.sourceforge.net/gate/?rev=14687&view=rev
Author: ian_roberts
Date: 2011-12-07 18:01:41 +0000 (Wed, 07 Dec 2011)
Log Message:
-----------
Fixed up the backwards-compatibility DSL methodMissing to work with the new
JavaBean style of default SAH construction.
Modified Paths:
--------------
mimir/branches/3.4/mimir-web/src/groovy/gate/mimir/util/SemanticAnnotationsHandler.groovy
Modified:
mimir/branches/3.4/mimir-web/src/groovy/gate/mimir/util/SemanticAnnotationsHandler.groovy
===================================================================
---
mimir/branches/3.4/mimir-web/src/groovy/gate/mimir/util/SemanticAnnotationsHandler.groovy
2011-12-07 15:22:19 UTC (rev 14686)
+++
mimir/branches/3.4/mimir-web/src/groovy/gate/mimir/util/SemanticAnnotationsHandler.groovy
2011-12-07 18:01:41 UTC (rev 14687)
@@ -100,19 +100,21 @@
* <dt>type</dt><dd>The Class object representing the type
* of the helper. This class must implement
* {@link SemanticAnnotationHelper} and must provide a
- * constructor taking six arguments - the annotation type
- * and five String[] arguments giving the nominal, integer,
- * float, text and URI feature names.</dd>
- * <dt>nominalFeatures</dt>
- * <dt>integerFeatures</dt>
- * <dt>floatFeatures</dt>
- * <dt>textFeatures</dt>
- * <dt>uriFeatures</dt><dd>The features of various kinds that
- * should be indexed by the helper. These entries should be
- * String arrays or List<String> (anything that is convertable
- * to a String array by Groovy's <code>as String[]</code>
- * operator)</dd>
+ * no-argument constructor and JavaBean property setters for
+ * at least the property "annType".</dd>
* </dl>
+ * This method will call the Groovy-style Map constructor, passing a map
+ * containing the key "annType" (mapped to the name of the "missing" method)
+ * along with any other keys in the map that was passed to this method except
+ * the "type" key. The resulting helper is then passed to the normal
+ * <code>annotation</code> method in the usual way. For example, a call of
+ * <pre>
+ * Person(type:DefaultHelper, nominalFeatures:["gender"])
+ * </pre>
+ * is converted to a call
+ * <pre>
+ * annotation type:"Person", helper:new DefaultHelper(annType:"Person",
nominalFeatures:["gender"])
+ * </pre>
*/
void methodMissing(String annotationType, args) {
if(args.size() != 1 || !(args[0] instanceof Map)) {
@@ -128,11 +130,10 @@
"type for the semantic annotation helper for annotation type
${annotationType}.")
}
- annotation(helper:theClass.newInstance(annotationType,
- defParams?.nominalFeatures as String[],
- defParams?.integerFeatures as String[],
- defParams?.floatFeatures as String[],
- defParams?.textFeatures as String[],
- defParams?.uriFeatures as String[]))
+ def helperParams = [:]
+ helperParams.addAll(defParams)
+ helperParams.remove('type')
+ helperParams.annType = annotationType
+ annotation(type:annotationType, helper:theClass.newInstance(helperParams))
}
}
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Cloud Services Checklist: Pricing and Packaging Optimization
This white paper is intended to serve as a reference, checklist and point of
discussion for anyone considering optimizing the pricing and packaging model
of a cloud services business. Read Now!
http://www.accelacomm.com/jaw/sfnl/114/51491232/
_______________________________________________
GATE-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gate-cvs