Revision: 17440
http://sourceforge.net/p/gate/code/17440
Author: adamfunk
Date: 2014-02-26 15:39:05 +0000 (Wed, 26 Feb 2014)
Log Message:
-----------
Adding just a tad more of as much as I can without breaking existing
code...
Also, removing some cruft (old RDF generation utility functions &
other mysteries) and making the beloved SliderPanel take the general
Number for specifying min and max values.
Modified Paths:
--------------
gate/trunk/plugins/TermRaider/src/gate/termraider/gui/SliderPanel.java
gate/trunk/plugins/TermRaider/src/gate/termraider/util/AbstractBank.java
gate/trunk/plugins/TermRaider/src/gate/termraider/util/ScoreType.java
gate/trunk/plugins/TermRaider/src/gate/termraider/util/Utilities.java
Modified: gate/trunk/plugins/TermRaider/src/gate/termraider/gui/SliderPanel.java
===================================================================
--- gate/trunk/plugins/TermRaider/src/gate/termraider/gui/SliderPanel.java
2014-02-26 15:38:00 UTC (rev 17439)
+++ gate/trunk/plugins/TermRaider/src/gate/termraider/gui/SliderPanel.java
2014-02-26 15:39:05 UTC (rev 17440)
@@ -26,32 +26,41 @@
private AbstractBank scoredbank;
private JSlider slider;
-
-
- // TODO
- // Add another constructor for DocumentFrequencyBank, with more
- // suitable slider range calculations
public SliderPanel(AbstractBank scoredbank, String verb, boolean startLeft,
TermbankViewer viewer) {
this.scoredbank = scoredbank;
this.setLayout(new FlowLayout());
-
JLabel typeLabel = new JLabel("Score cut-off");
- double min = Math.floor(this.scoredbank.getMinScore());
- double max = Math.ceil(this.scoredbank.getMaxScore());
+
+ int imin, imax, middle;
+ Number minScore = this.scoredbank.getMinScore();
- if (max - min < 1.0) {
- max = max + 1.0;
- min = min - 1.0;
+ // This one is for DocumentFrequencyBank, which has int quasi-scores
+ if (minScore instanceof Integer) {
+ imin = minScore.intValue();
+ imax = this.scoredbank.getMaxScore().intValue();
+ middle = (int) ( (imin + imax) / 2);
}
- else if (max - min < 2.0) {
- min = min - 1.0;
+
+ // This is for everything else
+ else {
+ double min = Math.floor(minScore.doubleValue());
+ double max = Math.ceil(this.scoredbank.getMaxScore().doubleValue());
+
+ if (max - min < 1.0) {
+ max = max + 1.0;
+ min = min - 1.0;
+ }
+ else if (max - min < 2.0) {
+ min = min - 1.0;
+ }
+
+ imin = (int) min;
+ imax = (int) max - 1;
+ middle = (int) Math.floor((min + max) / 2);
}
- int imin = (int) min;
- int imax = (int) max - 1;
- int middle = (int) Math.floor((min + max) / 2);
slider = new JSlider(imin, imax);
slider.setToolTipText("minimum value to " + verb);
slider.setPaintTicks(false);
Modified:
gate/trunk/plugins/TermRaider/src/gate/termraider/util/AbstractBank.java
===================================================================
--- gate/trunk/plugins/TermRaider/src/gate/termraider/util/AbstractBank.java
2014-02-26 15:38:00 UTC (rev 17439)
+++ gate/trunk/plugins/TermRaider/src/gate/termraider/util/AbstractBank.java
2014-02-26 15:39:05 UTC (rev 17440)
@@ -17,7 +17,6 @@
import gate.creole.metadata.CreoleParameter;
import gate.util.GateException;
import java.io.File;
-import org.apache.commons.lang.StringUtils;
import java.util.*;
@@ -31,9 +30,9 @@
protected Set<String> languages, types;
- public abstract Double getMinScore();
+ public abstract Number getMinScore();
- public abstract Double getMaxScore();
+ public abstract Number getMaxScore();
public abstract void saveAsCsv(double threshold, File file)
throws GateException;
@@ -48,21 +47,7 @@
public Set<String> getTypes() {
return this.types;
}
-
- public String shortScoreDescription() {
- String result = "";
- if (this.scoreProperty != null) {
- result = this.scoreProperty;
- if (result.endsWith("Score")) {
- result = StringUtils.substring(result, 0, -5);
- }
- }
- return result;
- }
-
-
-
public Term makeTerm(Annotation annotation, Document document) {
return new Term(annotation, document,
this.languageFeature, this.inputAnnotationFeature);
@@ -139,6 +124,5 @@
public String getInputASName() {
return this.inputASName;
}
-
}
Modified: gate/trunk/plugins/TermRaider/src/gate/termraider/util/ScoreType.java
===================================================================
--- gate/trunk/plugins/TermRaider/src/gate/termraider/util/ScoreType.java
2014-02-26 15:38:00 UTC (rev 17439)
+++ gate/trunk/plugins/TermRaider/src/gate/termraider/util/ScoreType.java
2014-02-26 15:39:05 UTC (rev 17440)
@@ -11,8 +11,6 @@
*/
package gate.termraider.util;
-import org.apache.commons.lang.StringUtils;
-import org.apache.commons.lang.WordUtils;
public class ScoreType implements Comparable<ScoreType> {
@@ -37,7 +35,7 @@
this.string = string;
// Normalize = remove leading & trailing whitespace then camelCase
- this.normalizedString =
WordUtils.capitalize(StringUtils.trimToEmpty(string)).replaceAll("\\s+", "");
+ this.normalizedString = Utilities.cleanAndCamelCase(string);
if (this.normalizedString.length() == 0) {
throw new IllegalArgumentException("ScoreType must contain some
non-whitespace characters.");
Modified: gate/trunk/plugins/TermRaider/src/gate/termraider/util/Utilities.java
===================================================================
--- gate/trunk/plugins/TermRaider/src/gate/termraider/util/Utilities.java
2014-02-26 15:38:00 UTC (rev 17439)
+++ gate/trunk/plugins/TermRaider/src/gate/termraider/util/Utilities.java
2014-02-26 15:39:05 UTC (rev 17440)
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008--2013, The University of Sheffield. See the file
+ * Copyright (c) 2008--2014, 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
@@ -16,7 +16,8 @@
import java.io.*;
import java.net.*;
import java.util.*;
-import gate.termraider.bank.*;
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang.WordUtils;
public class Utilities implements ANNIEConstants {
@@ -47,13 +48,11 @@
* The following produces the right half of a sigmoid
* curve adjusted so that
* f(0) = 0; f(inf) = 100; f(x>0) > 0
- * @param score
- * @return
+ * @param score from 0 to inf
+ * @return score from 0 to 100
*/
public static double normalizeScore(double score) {
double norm = 2.0 / (1.0 + Math.exp(-score / xScale)) - 1.0;
- // The old normalization function was undocumented
- //double norm = 1.0 - 1.0 / (1.0 + Math.log10(1.0 + score));
return (double) (100.0F * norm);
}
@@ -67,50 +66,15 @@
return Double.parseDouble(x.toString()) ;
}
-
- /**
- * Suitable for embedding in URIs.
- */
- public static String veryCleanString(String input) {
- String clean = input.trim();
- return clean.replaceAll("[^\\p{Alnum}\\p{Lu}\\p{Ll}]+", "_");
- }
-
-
- public static String generateID(String prefix, String suffix) {
- return prefix + java.util.UUID.randomUUID().toString() + suffix;
+ public static String cleanAndCamelCase(String input) {
+ // remove leading & trailing whitespace then camelCase
+ return
WordUtils.capitalize(StringUtils.trimToEmpty(input)).replaceAll("\\s+", "");
}
-
- public static URL getUrlInJar(AbstractTermbank termbank, String filename) {
- ClassLoader cl = termbank.getClass().getClassLoader();
- return cl.getResource(filename);
- }
-
- public static List<String> keysAsStrings(FeatureMap fm) {
- List<String> result = new ArrayList<String>();
- if (fm != null) {
- Set<?> keys = fm.keySet();
- for (Object key : keys) {
- result.add(key.toString());
- }
- }
- return result;
- }
-
-
- public static List<String> valuesAsStrings(FeatureMap fm) {
- List<String> result = new ArrayList<String>();
- if (fm != null) {
- for (Object key : fm.keySet()) {
- result.add(fm.get(key).toString());
- }
- }
- return result;
- }
-
-
+ /* The following methods are NOT cruft but are used in some JAPEs,
+ * so don't delete them.
+ */
public static void setCanonicalFromLemma(Annotation token, Document doc,
String lemmaFeatureName) {
String canonical = getCanonicalFromLemma(token, doc, lemmaFeatureName);
token.getFeatures().put("canonical", canonical);
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Flow-based real-time traffic analytics software. Cisco certified tool.
Monitor traffic, SLAs, QoS, Medianet, WAAS etc. with NetFlow Analyzer
Customize your own dashboards, set traffic alerts and generate reports.
Network behavioral analysis & security monitoring. All-in-one tool.
http://pubads.g.doubleclick.net/gampad/clk?id=126839071&iu=/4140/ostg.clktrk
_______________________________________________
GATE-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gate-cvs