Revision: 16746
http://sourceforge.net/p/gate/code/16746
Author: adamfunk
Date: 2013-07-23 13:22:45 +0000 (Tue, 23 Jul 2013)
Log Message:
-----------
TermScoreCopier PR now copies term & doc frequencies back to the
annotations (optional but turned on by default).
All termbanks now have getDocFrequency(Term) method (used above).
Modified Paths:
--------------
gate/trunk/plugins/TermRaider/src/gate/termraider/apply/TermScoreCopier.java
gate/trunk/plugins/TermRaider/src/gate/termraider/bank/AbstractTermbank.java
Modified:
gate/trunk/plugins/TermRaider/src/gate/termraider/apply/TermScoreCopier.java
===================================================================
---
gate/trunk/plugins/TermRaider/src/gate/termraider/apply/TermScoreCopier.java
2013-07-19 14:00:41 UTC (rev 16745)
+++
gate/trunk/plugins/TermRaider/src/gate/termraider/apply/TermScoreCopier.java
2013-07-23 13:22:45 UTC (rev 16746)
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012, The University of Sheffield. See the file
+ * Copyright (c) 2012--2013, The University of Sheffield. See the file
* COPYRIGHT.txt in the software or at http://gate.ac.uk/gate/COPYRIGHT.txt
*
* This file is part of GATE (see http://gate.ac.uk/), and is free
@@ -25,7 +25,9 @@
import java.text.NumberFormat;
import java.util.*;
+import org.apache.commons.lang.StringUtils;
+
@CreoleResource(name = "Termbank Score Copier",
icon = "termbank-lr.png",
comment = "Copy scores from Termbanks back to their source annotations")
@@ -38,6 +40,7 @@
/* CREOLE PARAMETERS */
private AbstractTermbank termbank;
private String annotationSetName;
+ private String frequencyFeature, docFrequencyFeature;
public Resource init() throws ResourceInstantiationException {
@@ -83,6 +86,15 @@
if (rawScore != null) {
fm.put(rawScoreFeature, rawScore);
}
+
+ if (useFeature(frequencyFeature)) {
+ fm.put(frequencyFeature, termbank.getTermFrequency(term));
+ }
+
+ if (useFeature(docFrequencyFeature)) {
+ fm.put(docFrequencyFeature, termbank.getDocFrequency(term));
+ }
+
checkInterruption();
} // end for candidates loop
@@ -99,6 +111,11 @@
if(isInterrupted()) { throw new ExecutionInterruptedException(
"Execution of " + this.getName() + " has been abruptly interrupted!");
}
}
+
+
+ private boolean useFeature(String feature) {
+ return (StringUtils.stripToEmpty(feature).length() > 0);
+ }
/* CREOLE METHODS */
@@ -113,7 +130,32 @@
return this.termbank;
}
+
@RunTime
+ @CreoleParameter(comment = "annotation feature for term frequency (blank to
ignore)",
+ defaultValue = "frequency")
+ public void setFrequencyFeature(String feature) {
+ this.frequencyFeature = feature;
+ }
+
+ public String getFrequencyFeature() {
+ return this.frequencyFeature;
+ }
+
+
+ @RunTime
+ @CreoleParameter(comment = "annotation feature for document frequency (blank
to ignore)",
+ defaultValue = "docFrequency")
+ public void setDocFrequencyFeature(String feature) {
+ this.docFrequencyFeature = feature;
+ }
+
+ public String getDocFrequencyFeature() {
+ return this.docFrequencyFeature;
+ }
+
+
+ @RunTime
@CreoleParameter(comment = "AnnotationSet name",
defaultValue = "")
public void setAnnotationSetName(String name) {
Modified:
gate/trunk/plugins/TermRaider/src/gate/termraider/bank/AbstractTermbank.java
===================================================================
---
gate/trunk/plugins/TermRaider/src/gate/termraider/bank/AbstractTermbank.java
2013-07-19 14:00:41 UTC (rev 16745)
+++
gate/trunk/plugins/TermRaider/src/gate/termraider/bank/AbstractTermbank.java
2013-07-23 13:22:45 UTC (rev 16746)
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008--2012, The University of Sheffield. See the file
+ * Copyright (c) 2008--2013, The University of Sheffield. See the file
* COPYRIGHT.txt in the software or at http://gate.ac.uk/gate/COPYRIGHT.txt
*
* This file is part of GATE (see http://gate.ac.uk/), and is free
@@ -262,6 +262,15 @@
}
+ public int getDocFrequency(Term term) {
+ if (docFrequencies.containsKey(term)) {
+ return docFrequencies.get(term);
+ }
+ // implied else
+ return 0;
+ }
+
+
/***** CREOLE PARAMETERS *****/
@CreoleParameter(comment = "input AS name",
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
See everything from the browser to the database with AppDynamics
Get end-to-end visibility with application monitoring from AppDynamics
Isolate bottlenecks and diagnose root cause in seconds.
Start your free trial of AppDynamics Pro today!
http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk
_______________________________________________
GATE-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gate-cvs