Revision: 15931
http://gate.svn.sourceforge.net/gate/?rev=15931&view=rev
Author: valyt
Date: 2012-07-13 11:02:58 +0000 (Fri, 13 Jul 2012)
Log Message:
-----------
Support for direct indexes in index templates.
Modified Paths:
--------------
mimir/trunk/mimir-web/src/groovy/gate/mimir/util/SemanticAnnotationsHandler.groovy
mimir/trunk/mimir-web/src/groovy/gate/mimir/util/TokenFeaturesHandler.groovy
Modified:
mimir/trunk/mimir-web/src/groovy/gate/mimir/util/SemanticAnnotationsHandler.groovy
===================================================================
---
mimir/trunk/mimir-web/src/groovy/gate/mimir/util/SemanticAnnotationsHandler.groovy
2012-07-13 11:01:51 UTC (rev 15930)
+++
mimir/trunk/mimir-web/src/groovy/gate/mimir/util/SemanticAnnotationsHandler.groovy
2012-07-13 11:02:58 UTC (rev 15931)
@@ -41,6 +41,10 @@
}
def index(Closure callable) {
+ index([:], callable)
+ }
+
+ def index(Map params, Closure callable) {
Map savedCurrentIndex = currentIndex
currentIndex = [annotationTypes:[], helpers:[]]
callable.delegate = this
@@ -48,7 +52,8 @@
indexerConfigs << new SemanticIndexerConfig(
currentIndex.annotationTypes as String[],
- currentIndex.helpers as SemanticAnnotationHelper[])
+ currentIndex.helpers as SemanticAnnotationHelper[],
+ params?.directIndex ? true : false)
currentIndex = savedCurrentIndex
}
Modified:
mimir/trunk/mimir-web/src/groovy/gate/mimir/util/TokenFeaturesHandler.groovy
===================================================================
---
mimir/trunk/mimir-web/src/groovy/gate/mimir/util/TokenFeaturesHandler.groovy
2012-07-13 11:01:51 UTC (rev 15930)
+++
mimir/trunk/mimir-web/src/groovy/gate/mimir/util/TokenFeaturesHandler.groovy
2012-07-13 11:02:58 UTC (rev 15931)
@@ -37,15 +37,37 @@
def firstFeature = indexerConfigs.isEmpty()
TermProcessor processor = null
+ boolean directIndex = false
if(args) {
- if(args[0] instanceof TermProcessor) {
- processor = (TermProcessor)args[0]
+ for(arg in args) {
+ if(arg instanceof TermProcessor) {
+ if(processor != null) {
+ throw new IllegalArgumentException(
+ "Term processor for token feature ${name} specified more than
once")
+ }
+ processor = (TermProcessor)arg
+ } else if(arg instanceof Map) {
+ if(arg.directIndex) directIndex = true
+ if(arg.termProcessor) {
+ if(processor != null) {
+ throw new IllegalArgumentException(
+ "Term processor for token feature ${name} specified more than
once")
+ }
+ if(arg.termProcessor instanceof TermProcessor) {
+ processor = arg.termProcessor
+ } else {
+ throw new IllegalArgumentException(
+ "termProcessor value for token feature ${name} is not a
TermProcessor instance")
+ }
+ }
+ }
+ else {
+ throw new IllegalArgumentException("${args[0]} is not a
TermProcessor")
+ }
}
- else {
- throw new IllegalArgumentException("${args[0]} is not a TermProcessor")
- }
}
- else {
+
+ if(processor == null) {
if(firstFeature) {
processor = DowncaseTermProcessor.getInstance()
}
@@ -54,6 +76,6 @@
}
}
- indexerConfigs << new TokenIndexerConfig(name, processor)
+ indexerConfigs << new TokenIndexerConfig(name, processor, directIndex)
}
}
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
GATE-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gate-cvs