Revision: 19738
http://sourceforge.net/p/gate/code/19738
Author: markagreenwood
Date: 2016-11-15 15:15:06 +0000 (Tue, 15 Nov 2016)
Log Message:
-----------
some performance fixes and AbstractProcessingResource no longer implements
ANNIEConstants as most PRs that needed it implemented it anyway and many PRs
don't need it anyway
Modified Paths:
--------------
gate/branches/sawdust2/gate-core/src/main/java/gate/creole/AbstractProcessingResource.java
gate/branches/sawdust2/plugins/ANNIE/pom.xml
gate/branches/sawdust2/plugins/ANNIE/src/main/java/com/ontotext/gate/gazetteer/HashGazetteer.java
gate/branches/sawdust2/plugins/ANNIE/src/main/java/gate/creole/POSTagger.java
gate/branches/sawdust2/plugins/ANNIE/src/main/java/gate/creole/Transducer.java
gate/branches/sawdust2/plugins/ANNIE/src/main/java/gate/creole/annotdelete/AnnotationDeletePR.java
gate/branches/sawdust2/plugins/ANNIE/src/main/java/gate/creole/coref/AbstractCoreferencer.java
gate/branches/sawdust2/plugins/ANNIE/src/main/java/gate/creole/coref/Coreferencer.java
gate/branches/sawdust2/plugins/ANNIE/src/main/java/gate/creole/coref/NominalCoref.java
gate/branches/sawdust2/plugins/ANNIE/src/main/java/gate/creole/gazetteer/DefaultGazetteer.java
gate/branches/sawdust2/plugins/ANNIE/src/main/java/gate/creole/orthomatcher/BasicAnnotationOrthography.java
gate/branches/sawdust2/plugins/ANNIE/src/main/java/gate/creole/orthomatcher/OrthoMatcher.java
gate/branches/sawdust2/plugins/ANNIE/src/main/java/gate/creole/splitter/SentenceSplitter.java
gate/branches/sawdust2/plugins/ANNIE/src/main/java/gate/creole/tokeniser/SimpleTokeniser.java
gate/branches/sawdust2/plugins/ANNIE/src/main/java/gate/util/compilers/Eclipse.java
gate/branches/sawdust2/plugins/Tools/src/main/java/gate/creole/morph/Morph.java
Added Paths:
-----------
gate/branches/sawdust2/plugins/ANNIE/src/build/
gate/branches/sawdust2/plugins/ANNIE/src/build/resources/
gate/branches/sawdust2/plugins/ANNIE/src/build/resources/findbugs-excluded.xml
Modified:
gate/branches/sawdust2/gate-core/src/main/java/gate/creole/AbstractProcessingResource.java
===================================================================
---
gate/branches/sawdust2/gate-core/src/main/java/gate/creole/AbstractProcessingResource.java
2016-11-15 02:22:49 UTC (rev 19737)
+++
gate/branches/sawdust2/gate-core/src/main/java/gate/creole/AbstractProcessingResource.java
2016-11-15 15:15:06 UTC (rev 19738)
@@ -29,7 +29,7 @@
* code.
*/
abstract public class AbstractProcessingResource
-extends AbstractResource implements ProcessingResource, ANNIEConstants
+extends AbstractResource implements ProcessingResource
{
private static final long serialVersionUID = -5919543745701986862L;
Modified: gate/branches/sawdust2/plugins/ANNIE/pom.xml
===================================================================
--- gate/branches/sawdust2/plugins/ANNIE/pom.xml 2016-11-15 02:22:49 UTC
(rev 19737)
+++ gate/branches/sawdust2/plugins/ANNIE/pom.xml 2016-11-15 15:15:06 UTC
(rev 19738)
@@ -77,5 +77,25 @@
</plugin>
</plugins>
</build>
+
+ <reporting>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>findbugs-maven-plugin</artifactId>
+ <version>3.0.3</version>
+ <configuration>
+ <findbugsXmlOutput>true</findbugsXmlOutput>
+
<findbugsXmlWithMessages>true</findbugsXmlWithMessages>
+
<excludeFilterFile>src/build/resources/findbugs-excluded.xml</excludeFilterFile>
+
+ <xmlOutput>true</xmlOutput>
+ <effort>Max</effort>
+ <threshold>Low</threshold>
+
+ </configuration>
+ </plugin>
+ </plugins>
+ </reporting>
</project>
Added:
gate/branches/sawdust2/plugins/ANNIE/src/build/resources/findbugs-excluded.xml
===================================================================
---
gate/branches/sawdust2/plugins/ANNIE/src/build/resources/findbugs-excluded.xml
(rev 0)
+++
gate/branches/sawdust2/plugins/ANNIE/src/build/resources/findbugs-excluded.xml
2016-11-15 15:15:06 UTC (rev 19738)
@@ -0,0 +1,31 @@
+<FindBugsFilter>
+ <Match>
+ <Or>
+ <!--
+ It isn't always clear what encoding should be used so for now we're
going to
+ ignore these. We'll revist this issue at some future point.
+ -->
+ <Bug pattern="DM_DEFAULT_ENCODING" />
+ <Bug pattern="DM_CONVERT_CASE" />
+
+ <!--
+ Whilst unused private methods are indicative of bad code, at the
moment we don't
+ really care about them too much, so just for now we'll ignore them
+ -->
+ <Bug pattern="UPM_UNCALLED_PRIVATE_METHOD" />
+ </Or>
+ </Match>
+
+ <!--
+ Don't bother checking packages where the code is auto-generated or included
via jar-jar
+ as there is nothing we can do to fix any errors that are found anyway.
+ -->
+ <Match>
+ <Or>
+ <!-- we should probably still look at ParseCpsl but how? -->
+ <Package name="~gate\.jape\.parser.*" />
+
+ <Package name="~gate\.resources\.img\.svg.*" />
+ </Or>
+ </Match>
+</FindBugsFilter>
Modified:
gate/branches/sawdust2/plugins/ANNIE/src/main/java/com/ontotext/gate/gazetteer/HashGazetteer.java
===================================================================
---
gate/branches/sawdust2/plugins/ANNIE/src/main/java/com/ontotext/gate/gazetteer/HashGazetteer.java
2016-11-15 02:22:49 UTC (rev 19737)
+++
gate/branches/sawdust2/plugins/ANNIE/src/main/java/com/ontotext/gate/gazetteer/HashGazetteer.java
2016-11-15 15:15:06 UTC (rev 19738)
@@ -69,7 +69,8 @@
fireProgressChanged((++j * 100) / i);
}
fireProcessFinished();
- } catch(Exception exception) {
+ }
+ catch(GazetteerException exception) {
throw new ResourceInstantiationException(exception);
}
}
@@ -259,7 +260,7 @@
featuremap.put("language", lookup1.languages);
}
try {
- annotationSet.add(new Long(i), new Long(documentPosition), "Lookup",
+ annotationSet.add(Long.valueOf(i), Long.valueOf(documentPosition),
"Lookup",
featuremap);
} catch(InvalidOffsetException invalidoffsetexception) {
throw new LuckyException(invalidoffsetexception.toString());
Modified:
gate/branches/sawdust2/plugins/ANNIE/src/main/java/gate/creole/POSTagger.java
===================================================================
---
gate/branches/sawdust2/plugins/ANNIE/src/main/java/gate/creole/POSTagger.java
2016-11-15 02:22:49 UTC (rev 19737)
+++
gate/branches/sawdust2/plugins/ANNIE/src/main/java/gate/creole/POSTagger.java
2016-11-15 15:15:06 UTC (rev 19738)
@@ -14,6 +14,17 @@
package gate.creole;
+import java.text.NumberFormat;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Iterator;
+import java.util.List;
+import java.util.ListIterator;
+
+import org.apache.log4j.Level;
+import org.apache.log4j.Logger;
+
import gate.Annotation;
import gate.AnnotationSet;
import gate.Factory;
@@ -26,24 +37,13 @@
import gate.creole.metadata.RunTime;
import gate.util.GateRuntimeException;
import gate.util.OffsetComparator;
-
-import java.text.NumberFormat;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.Iterator;
-import java.util.List;
-import java.util.ListIterator;
-
-import org.apache.log4j.Level;
-import org.apache.log4j.Logger;
/**
* This class is a wrapper for HepTag, Mark Hepple's POS tagger.
*/
@CreoleResource(name = "ANNIE POS Tagger",
helpURL = "http://gate.ac.uk/userguide/sec:annie:tagger",
comment = "Mark Hepple's Brill-style POS tagger", icon="pos-tagger")
-public class POSTagger extends AbstractLanguageAnalyser {
+public class POSTagger extends AbstractLanguageAnalyser implements
ANNIEConstants {
private static final long serialVersionUID = 7680938864165071808L;
@@ -198,7 +198,7 @@
}
//run the POS tagger
List<List<String[]>> taggerList = tagger.runTagger(sentencesForTagger);
- if(taggerList != null && taggerList.size() > 0){
+ if(taggerList.size() > 0){
List<String[]> taggerResults = taggerList.get(0);
//add the results
//make sure no malfunction occurred
@@ -349,8 +349,8 @@
annot.getFeatures().put(featureName, featureValue);
return;
} else {
- int start = annot.getStartNode().getOffset().intValue();
- int end = annot.getEndNode().getOffset().intValue();
+ Long start = annot.getStartNode().getOffset();
+ Long end = annot.getEndNode().getOffset();
// get the annotations of type outputAnnotationType
AnnotationSet outputAS = (outputASName == null) ?
@@ -362,7 +362,7 @@
FeatureMap features = Factory.newFeatureMap();
features.put(featureName, featureValue);
try {
- outputAS.add(new Long(start), new Long(end),
outputAnnotationType, features);
+ outputAS.add(start, end, outputAnnotationType, features);
} catch(Exception e) {
throw new GateRuntimeException("Invalid Offsets");
}
@@ -372,7 +372,7 @@
boolean found = false;
for(int i=0;i<tempList.size();i++) {
Annotation annotation = tempList.get(i);
- if(annotation.getStartNode().getOffset().intValue() == start
&& annotation.getEndNode().getOffset().intValue() == end) {
+ if(annotation.getStartNode().getOffset().equals(start) &&
annotation.getEndNode().getOffset().equals(end)) {
// this is the one
annotation.getFeatures().put(featureName, featureValue);
found = true;
@@ -385,7 +385,7 @@
FeatureMap features = Factory.newFeatureMap();
features.put(featureName, featureValue);
try {
- outputAS.add(new Long(start), new Long(end),
outputAnnotationType, features);
+ outputAS.add(start, end, outputAnnotationType, features);
} catch(Exception e) {
throw new GateRuntimeException("Invalid Offsets");
}
Modified:
gate/branches/sawdust2/plugins/ANNIE/src/main/java/gate/creole/Transducer.java
===================================================================
---
gate/branches/sawdust2/plugins/ANNIE/src/main/java/gate/creole/Transducer.java
2016-11-15 02:22:49 UTC (rev 19737)
+++
gate/branches/sawdust2/plugins/ANNIE/src/main/java/gate/creole/Transducer.java
2016-11-15 15:15:06 UTC (rev 19738)
@@ -13,6 +13,18 @@
*/
package gate.creole;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.swing.Action;
+import javax.swing.JFileChooser;
+import javax.swing.JOptionPane;
+
import gate.Controller;
import gate.Gate;
import gate.Resource;
@@ -30,18 +42,6 @@
import gate.util.Benchmarkable;
import gate.util.Err;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.swing.Action;
-import javax.swing.JFileChooser;
-import javax.swing.JOptionPane;
-
/**
* A cascaded multi-phase transducer using the Jape language which is a variant
* of the CPSL language.
@@ -108,9 +108,10 @@
initCustomConstraints();
if(binaryGrammarURL != null) {
- ObjectInputStream s = new ObjectInputStream(binaryGrammarURL
- .openStream());
+ try (ObjectInputStream s = new ObjectInputStream(binaryGrammarURL
+ .openStream());){
batch = (gate.jape.Batch)s.readObject();
+ }
} else if(grammarURL != null) {
if(encoding != null) {
batch = new Batch(grammarURL, encoding, new
InternalStatusListener());
@@ -127,7 +128,8 @@
throw new ResourceInstantiationException(
"Neither grammarURL or binaryGrammarURL parameters are set!");
}
- } catch(Exception e) {
+ }
+ catch(ClassNotFoundException | IOException | JapeException e) {
String message = "Error while parsing the grammar ";
if(grammarURL != null) message += "(" + grammarURL.toExternalForm() +
")";
message += ":";
@@ -263,7 +265,7 @@
//now store it in ConstraintFactory
JapeFactory.getConstraintFactory().addMetaProperty(accSymbol, clazz);
}
- catch(Exception e) {
+ catch(IllegalAccessException | InstantiationException e) {
throw new ResourceInstantiationException("Cannot instantiate class
for accessor: " + accessorName, e);
}
@@ -306,13 +308,9 @@
fileChooser.setMultiSelectionEnabled(false);
if(fileChooser.showSaveDialog(null) == JFileChooser.APPROVE_OPTION) {
File file = fileChooser.getSelectedFile();
- try {
+ try (ObjectOutputStream s = new ObjectOutputStream(new
FileOutputStream(file));) {
MainFrame.lockGUI("Serializing JAPE Transducer...");
- FileOutputStream out = new FileOutputStream(file);
- ObjectOutputStream s = new ObjectOutputStream(out);
- serialize(s);
- s.close();
- out.close();
+ serialize(s);
} catch(IOException ioe) {
JOptionPane.showMessageDialog(MainFrame.getInstance(),
"Error!\n" + ioe.toString(),
"GATE", JOptionPane.ERROR_MESSAGE);
Modified:
gate/branches/sawdust2/plugins/ANNIE/src/main/java/gate/creole/annotdelete/AnnotationDeletePR.java
===================================================================
---
gate/branches/sawdust2/plugins/ANNIE/src/main/java/gate/creole/annotdelete/AnnotationDeletePR.java
2016-11-15 02:22:49 UTC (rev 19737)
+++
gate/branches/sawdust2/plugins/ANNIE/src/main/java/gate/creole/annotdelete/AnnotationDeletePR.java
2016-11-15 15:15:06 UTC (rev 19738)
@@ -16,10 +16,15 @@
package gate.creole.annotdelete;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
import gate.Annotation;
import gate.AnnotationSet;
import gate.GateConstants;
-import gate.ProcessingResource;
import gate.Resource;
import gate.creole.ANNIEConstants;
import gate.creole.AbstractLanguageAnalyser;
@@ -31,12 +36,6 @@
import gate.creole.metadata.RunTime;
import gate.util.GateRuntimeException;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
/**
* This class is the implementation of a processing resource which
* deletes all annotations and sets other than 'original markups'.
@@ -46,8 +45,7 @@
@CreoleResource(name = "Document Reset PR", icon = "document-reset",
comment = "Remove named annotation sets or reset the default
annotation set",
helpURL = "http://gate.ac.uk/userguide/sec:misc-creole:reset")
-public class AnnotationDeletePR extends AbstractLanguageAnalyser
- implements ProcessingResource {
+public class AnnotationDeletePR extends AbstractLanguageAnalyser {
private static final long serialVersionUID = 4738446480871610387L;
Modified:
gate/branches/sawdust2/plugins/ANNIE/src/main/java/gate/creole/coref/AbstractCoreferencer.java
===================================================================
---
gate/branches/sawdust2/plugins/ANNIE/src/main/java/gate/creole/coref/AbstractCoreferencer.java
2016-11-15 02:22:49 UTC (rev 19737)
+++
gate/branches/sawdust2/plugins/ANNIE/src/main/java/gate/creole/coref/AbstractCoreferencer.java
2016-11-15 15:15:06 UTC (rev 19738)
@@ -14,26 +14,25 @@
package gate.creole.coref;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
import gate.Annotation;
import gate.AnnotationSet;
import gate.Document;
import gate.FeatureMap;
-import gate.ProcessingResource;
import gate.Resource;
+import gate.creole.ANNIEConstants;
import gate.creole.AbstractLanguageAnalyser;
import gate.creole.ResourceInstantiationException;
import gate.util.GateRuntimeException;
import gate.util.SimpleFeatureMapImpl;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
+public abstract class AbstractCoreferencer extends AbstractLanguageAnalyser
implements ANNIEConstants {
-public abstract class AbstractCoreferencer extends AbstractLanguageAnalyser
- implements ProcessingResource{
-
private static final long serialVersionUID = 7077378848676784207L;
public static final String COREF_DOCUMENT_PARAMETER_NAME = "document";
Modified:
gate/branches/sawdust2/plugins/ANNIE/src/main/java/gate/creole/coref/Coreferencer.java
===================================================================
---
gate/branches/sawdust2/plugins/ANNIE/src/main/java/gate/creole/coref/Coreferencer.java
2016-11-15 02:22:49 UTC (rev 19737)
+++
gate/branches/sawdust2/plugins/ANNIE/src/main/java/gate/creole/coref/Coreferencer.java
2016-11-15 15:15:06 UTC (rev 19738)
@@ -16,13 +16,21 @@
package gate.creole.coref;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.log4j.Logger;
+
import gate.Annotation;
import gate.AnnotationSet;
import gate.Document;
import gate.Factory;
import gate.FeatureMap;
-import gate.ProcessingResource;
import gate.Resource;
+import gate.creole.ANNIEConstants;
import gate.creole.AbstractLanguageAnalyser;
import gate.creole.ExecutionException;
import gate.creole.ResourceInstantiationException;
@@ -33,17 +41,8 @@
import gate.util.GateRuntimeException;
import gate.util.SimpleFeatureMapImpl;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.log4j.Logger;
-
@CreoleResource(name="ANNIE Pronominal Coreferencer", comment="Pronominal
Coreference resolution component.",
helpURL="http://gate.ac.uk/userguide/sec:annie:pronom-coref",
icon="pronominal-coreferencer")
-public class Coreferencer extends AbstractLanguageAnalyser implements
- ProcessingResource {
+public class Coreferencer extends AbstractLanguageAnalyser implements
ANNIEConstants {
private static final long serialVersionUID = -2343178168872843239L;
Modified:
gate/branches/sawdust2/plugins/ANNIE/src/main/java/gate/creole/coref/NominalCoref.java
===================================================================
---
gate/branches/sawdust2/plugins/ANNIE/src/main/java/gate/creole/coref/NominalCoref.java
2016-11-15 02:22:49 UTC (rev 19737)
+++
gate/branches/sawdust2/plugins/ANNIE/src/main/java/gate/creole/coref/NominalCoref.java
2016-11-15 15:15:06 UTC (rev 19738)
@@ -14,11 +14,17 @@
package gate.creole.coref;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+
import gate.Annotation;
import gate.AnnotationSet;
import gate.Document;
import gate.FeatureMap;
-import gate.ProcessingResource;
import gate.Resource;
import gate.creole.ANNIEConstants;
import gate.creole.ExecutionException;
@@ -31,16 +37,9 @@
import gate.util.OffsetComparator;
import gate.util.SimpleFeatureMapImpl;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-
@CreoleResource(name="ANNIE Nominal Coreferencer", comment="Nominal
Coreference resolution component",
helpURL="http://gate.ac.uk/userguide/sec:annie:pronom-coref",
icon="nominal-coreferencer")
public class NominalCoref extends AbstractCoreferencer
- implements ProcessingResource, ANNIEConstants {
+ implements ANNIEConstants {
private static final long serialVersionUID = 1497388811557744017L;
Modified:
gate/branches/sawdust2/plugins/ANNIE/src/main/java/gate/creole/gazetteer/DefaultGazetteer.java
===================================================================
---
gate/branches/sawdust2/plugins/ANNIE/src/main/java/gate/creole/gazetteer/DefaultGazetteer.java
2016-11-15 02:22:49 UTC (rev 19737)
+++
gate/branches/sawdust2/plugins/ANNIE/src/main/java/gate/creole/gazetteer/DefaultGazetteer.java
2016-11-15 15:15:06 UTC (rev 19738)
@@ -17,11 +17,19 @@
*/
package gate.creole.gazetteer;
+import java.io.Serializable;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+
import gate.AnnotationSet;
import gate.Factory;
import gate.FeatureMap;
import gate.Resource;
import gate.Utils;
+import gate.creole.ANNIEConstants;
import gate.creole.CustomDuplication;
import gate.creole.ExecutionException;
import gate.creole.ExecutionInterruptedException;
@@ -33,13 +41,6 @@
import gate.util.InvalidOffsetException;
import gate.util.Strings;
-import java.io.Serializable;
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-
/** This component is responsible for doing lists lookup. The implementation is
* based on finite state machines.
* The phrases to be recognised should be listed in a set of files, one for
@@ -65,7 +66,7 @@
*/
@CreoleResource(name="ANNIE Gazetteer", comment="A list lookup component.",
icon="gazetteer", helpURL="http://gate.ac.uk/userguide/sec:annie:gazetteer")
public class DefaultGazetteer extends AbstractGazetteer
- implements CustomDuplication {
+ implements CustomDuplication, ANNIEConstants {
private static final long serialVersionUID = -8976141132455436099L;
Modified:
gate/branches/sawdust2/plugins/ANNIE/src/main/java/gate/creole/orthomatcher/BasicAnnotationOrthography.java
===================================================================
---
gate/branches/sawdust2/plugins/ANNIE/src/main/java/gate/creole/orthomatcher/BasicAnnotationOrthography.java
2016-11-15 02:22:49 UTC (rev 19737)
+++
gate/branches/sawdust2/plugins/ANNIE/src/main/java/gate/creole/orthomatcher/BasicAnnotationOrthography.java
2016-11-15 15:15:06 UTC (rev 19738)
@@ -1,18 +1,7 @@
package gate.creole.orthomatcher;
-import static gate.creole.ANNIEConstants.ANNOTATION_COREF_FEATURE_NAME;
-import static gate.creole.ANNIEConstants.LOOKUP_ANNOTATION_TYPE;
import static gate.creole.orthomatcher.OrthoMatcherHelper.getStringForSpan;
import static gate.creole.orthomatcher.OrthoMatcherHelper.round2Places;
-import gate.Annotation;
-import gate.AnnotationSet;
-import gate.Document;
-import gate.Factory;
-import gate.FeatureMap;
-import gate.creole.ExecutionException;
-import gate.util.BomStrippingInputStreamReader;
-import gate.util.Err;
-import gate.util.InvalidOffsetException;
import java.io.BufferedReader;
import java.io.IOException;
@@ -31,6 +20,17 @@
import org.apache.commons.io.IOUtils;
import org.apache.log4j.Logger;
+import gate.Annotation;
+import gate.AnnotationSet;
+import gate.Document;
+import gate.Factory;
+import gate.FeatureMap;
+import gate.creole.ANNIEConstants;
+import gate.creole.ExecutionException;
+import gate.util.BomStrippingInputStreamReader;
+import gate.util.Err;
+import gate.util.InvalidOffsetException;
+
/*
* This class defines an orthography which defines the primary behaviour of the
* Orthomatcher processing resource in GATE.
@@ -181,7 +181,7 @@
// contains the id of the second
@SuppressWarnings("unchecked")
List<Integer> matchesList =
- (List<Integer>)annot1.getFeatures().get(ANNOTATION_COREF_FEATURE_NAME);
+
(List<Integer>)annot1.getFeatures().get(OrthoMatcher.ANNOTATION_COREF_FEATURE_NAME);
if((matchesList == null) || matchesList.isEmpty())
return false;
else if(matchesList.contains(annot2.getId())) return true;
@@ -227,12 +227,12 @@
if(matchedAnnot == null) return null;
@SuppressWarnings("unchecked")
List<Integer> matchesList =
-
(List<Integer>)matchedAnnot.getFeatures().get(ANNOTATION_COREF_FEATURE_NAME);
+
(List<Integer>)matchedAnnot.getFeatures().get(OrthoMatcher.ANNOTATION_COREF_FEATURE_NAME);
if((matchesList == null) || matchesList.isEmpty()) {
// no previous matches, so need to add
if(matchesList == null) {
matchesList = new ArrayList<Integer>();
- matchedAnnot.getFeatures().put(ANNOTATION_COREF_FEATURE_NAME,
+
matchedAnnot.getFeatures().put(OrthoMatcher.ANNOTATION_COREF_FEATURE_NAME,
matchesList);
matchesDocFeature.add(matchesList);
}// if
@@ -307,7 +307,7 @@
"cdg");
// now get all lookup annotations which are cdg
AnnotationSet nameAnnots =
- nameAllAnnots.get(LOOKUP_ANNOTATION_TYPE, tempMap);
+ nameAllAnnots.get(OrthoMatcher.LOOKUP_ANNOTATION_TYPE, tempMap);
if((nameAnnots == null) || nameAnnots.isEmpty()) return cdg;
Iterator<Annotation> iter = nameAnnots.iterator();
while(iter.hasNext()) {
Modified:
gate/branches/sawdust2/plugins/ANNIE/src/main/java/gate/creole/orthomatcher/OrthoMatcher.java
===================================================================
---
gate/branches/sawdust2/plugins/ANNIE/src/main/java/gate/creole/orthomatcher/OrthoMatcher.java
2016-11-15 02:22:49 UTC (rev 19737)
+++
gate/branches/sawdust2/plugins/ANNIE/src/main/java/gate/creole/orthomatcher/OrthoMatcher.java
2016-11-15 15:15:06 UTC (rev 19738)
@@ -30,22 +30,6 @@
package gate.creole.orthomatcher;
-import gate.Annotation;
-import gate.AnnotationSet;
-import gate.Resource;
-import gate.creole.AbstractLanguageAnalyser;
-import gate.creole.ExecutionException;
-import gate.creole.ResourceInstantiationException;
-import gate.creole.metadata.CreoleParameter;
-import gate.creole.metadata.CreoleResource;
-import gate.creole.metadata.Optional;
-import gate.creole.metadata.RunTime;
-import gate.util.BomStrippingInputStreamReader;
-import gate.util.GateRuntimeException;
-import gate.util.InvalidOffsetException;
-import gate.util.OffsetComparator;
-import gate.util.Out;
-
import java.io.BufferedReader;
import java.io.IOException;
import java.net.URL;
@@ -62,8 +46,25 @@
import org.apache.commons.io.IOUtils;
import org.apache.log4j.Logger;
+
+import gate.Annotation;
+import gate.AnnotationSet;
+import gate.Resource;
+import gate.creole.ANNIEConstants;
+import gate.creole.AbstractLanguageAnalyser;
+import gate.creole.ExecutionException;
+import gate.creole.ResourceInstantiationException;
+import gate.creole.metadata.CreoleParameter;
+import gate.creole.metadata.CreoleResource;
+import gate.creole.metadata.Optional;
+import gate.creole.metadata.RunTime;
+import gate.util.BomStrippingInputStreamReader;
+import gate.util.GateRuntimeException;
+import gate.util.InvalidOffsetException;
+import gate.util.OffsetComparator;
+import gate.util.Out;
@CreoleResource(name="ANNIE OrthoMatcher", comment="ANNIE orthographical
coreference component.",
helpURL="http://gate.ac.uk/userguide/sec:annie:orthomatcher",
icon="ortho-matcher")
-public class OrthoMatcher extends AbstractLanguageAnalyser {
+public class OrthoMatcher extends AbstractLanguageAnalyser implements
ANNIEConstants {
private static final long serialVersionUID = -6258229350677707465L;
Modified:
gate/branches/sawdust2/plugins/ANNIE/src/main/java/gate/creole/splitter/SentenceSplitter.java
===================================================================
---
gate/branches/sawdust2/plugins/ANNIE/src/main/java/gate/creole/splitter/SentenceSplitter.java
2016-11-15 02:22:49 UTC (rev 19737)
+++
gate/branches/sawdust2/plugins/ANNIE/src/main/java/gate/creole/splitter/SentenceSplitter.java
2016-11-15 15:15:06 UTC (rev 19738)
@@ -19,6 +19,7 @@
import gate.FeatureMap;
import gate.Gate;
import gate.Resource;
+import gate.creole.ANNIEConstants;
import gate.creole.AbstractLanguageAnalyser;
import gate.creole.ExecutionException;
import gate.creole.ExecutionInterruptedException;
@@ -44,7 +45,7 @@
* results in a usable form.
*/
@CreoleResource(name="ANNIE Sentence Splitter", comment="ANNIE sentence
splitter.", helpURL="http://gate.ac.uk/userguide/sec:annie:splitter",
icon="sentence-splitter")
-public class SentenceSplitter extends AbstractLanguageAnalyser implements
Benchmarkable{
+public class SentenceSplitter extends AbstractLanguageAnalyser implements
Benchmarkable, ANNIEConstants {
private static final long serialVersionUID = -5335682060379173111L;
Modified:
gate/branches/sawdust2/plugins/ANNIE/src/main/java/gate/creole/tokeniser/SimpleTokeniser.java
===================================================================
---
gate/branches/sawdust2/plugins/ANNIE/src/main/java/gate/creole/tokeniser/SimpleTokeniser.java
2016-11-15 02:22:49 UTC (rev 19737)
+++
gate/branches/sawdust2/plugins/ANNIE/src/main/java/gate/creole/tokeniser/SimpleTokeniser.java
2016-11-15 15:15:06 UTC (rev 19738)
@@ -16,11 +16,29 @@
package gate.creole.tokeniser;
+import java.io.BufferedReader;
+import java.lang.reflect.Field;
+import java.lang.reflect.Modifier;
+import java.util.AbstractSet;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.StringTokenizer;
+
+import org.apache.commons.io.IOUtils;
+
import gate.AnnotationSet;
import gate.Factory;
import gate.FeatureMap;
import gate.Gate;
import gate.Resource;
+import gate.creole.ANNIEConstants;
import gate.creole.AbstractLanguageAnalyser;
import gate.creole.ExecutionException;
import gate.creole.ExecutionInterruptedException;
@@ -35,23 +53,6 @@
import gate.util.InvalidOffsetException;
import gate.util.LuckyException;
-import java.io.BufferedReader;
-import java.lang.reflect.Field;
-import java.lang.reflect.Modifier;
-import java.util.AbstractSet;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.StringTokenizer;
-
-import org.apache.commons.io.IOUtils;
-
/** Implementation of a Unicode rule based tokeniser.
* The tokeniser gets its rules from a file an {@link java.io.InputStream
* InputStream} or a {@link java.io.Reader Reader} which should be sent to one
@@ -119,7 +120,7 @@
*
*/
@CreoleResource(name="GATE Unicode Tokeniser", comment="A customisable Unicode
tokeniser.", helpURL="http://gate.ac.uk/userguide/sec:annie:tokeniser",
icon="tokeniser")
-public class SimpleTokeniser extends AbstractLanguageAnalyser{
+public class SimpleTokeniser extends AbstractLanguageAnalyser implements
ANNIEConstants {
private static final long serialVersionUID = 1411111968361716069L;
Modified:
gate/branches/sawdust2/plugins/ANNIE/src/main/java/gate/util/compilers/Eclipse.java
===================================================================
---
gate/branches/sawdust2/plugins/ANNIE/src/main/java/gate/util/compilers/Eclipse.java
2016-11-15 02:22:49 UTC (rev 19737)
+++
gate/branches/sawdust2/plugins/ANNIE/src/main/java/gate/util/compilers/Eclipse.java
2016-11-15 15:15:06 UTC (rev 19738)
@@ -166,14 +166,14 @@
*/
@Override
public NameEnvironmentAnswer findType(char[][] compoundTypeName) {
- String result = "";
+ StringBuilder result = new StringBuilder();
String sep = "";
for (int i = 0; i < compoundTypeName.length; i++) {
- result += sep;
- result += new String(compoundTypeName[i]);
+ result.append(sep);
+ result.append(compoundTypeName[i]);
sep = ".";
}
- return findType(result);
+ return findType(result.toString());
}
/**
@@ -184,16 +184,16 @@
@Override
public NameEnvironmentAnswer findType(char[] typeName,
char[][] packageName) {
- String result = "";
+ StringBuilder result = new StringBuilder();
String sep = "";
for (int i = 0; i < packageName.length; i++) {
- result += sep;
- result += new String(packageName[i]);
+ result.append(sep);
+ result.append(packageName[i]);
sep = ".";
}
- result += sep;
- result += new String(typeName);
- return findType(result);
+ result.append(sep);
+ result.append(typeName);
+ return findType(result.toString());
}
/**
@@ -284,25 +284,24 @@
@Override
public boolean isPackage(char[][] parentPackageName,
char[] packageName) {
- String result = "";
+ StringBuilder result = new StringBuilder();
String sep = "";
if (parentPackageName != null) {
for (int i = 0; i < parentPackageName.length; i++) {
- result += sep;
- String str = new String(parentPackageName[i]);
- result += str;
+ result.append(sep);
+ result.append(parentPackageName[i]);
sep = ".";
}
}
- String str = new String(packageName);
- if (Character.isUpperCase(str.charAt(0))) {
- if (!isPackage(result)) {
+
+ if (Character.isUpperCase(packageName[0])) {
+ if (!isPackage(result.toString())) {
return false;
}
}
- result += sep;
- result += str;
- return isPackage(result);
+ result.append(sep);
+ result.append(packageName);
+ return isPackage(result.toString());
}
@Override
@@ -369,15 +368,15 @@
for (int i = 0; i < classFiles.length; i++) {
ClassFile classFile = classFiles[i];
char[][] compoundName = classFile.getCompoundName();
- String className = "";
+ StringBuilder className = new StringBuilder();
String sep = "";
for (int j = 0; j < compoundName.length; j++) {
- className += sep;
- className += new String(compoundName[j]);
+ className.append(sep);
+ className.append(compoundName[j]);
sep = ".";
}
byte[] bytes = classFile.getBytes();
- classLoader.defineGateClass(className, bytes,
+ classLoader.defineGateClass(className.toString(), bytes,
0, bytes.length);
}
}
@@ -386,7 +385,7 @@
private void addProblem(IProblem problem) {
String name = new String(problem.getOriginatingFileName());
List<IProblem> problemsForName = problems.get(name);
- if(problemsForName == null) {
+ if(problemsForName == null) {
problemsForName = new ArrayList<IProblem>();
problems.put(name, problemsForName);
}
Modified:
gate/branches/sawdust2/plugins/Tools/src/main/java/gate/creole/morph/Morph.java
===================================================================
---
gate/branches/sawdust2/plugins/Tools/src/main/java/gate/creole/morph/Morph.java
2016-11-15 02:22:49 UTC (rev 19737)
+++
gate/branches/sawdust2/plugins/Tools/src/main/java/gate/creole/morph/Morph.java
2016-11-15 15:15:06 UTC (rev 19738)
@@ -1,6 +1,12 @@
package gate.creole.morph;
+import java.net.URL;
+import java.util.Iterator;
+
+import org.apache.log4j.Level;
+import org.apache.log4j.Logger;
+
/*
* Morph.java
*
@@ -27,6 +33,7 @@
import gate.ProcessingResource;
import gate.Resource;
import gate.Utils;
+import gate.creole.ANNIEConstants;
import gate.creole.AbstractLanguageAnalyser;
import gate.creole.CustomDuplication;
import gate.creole.ExecutionException;
@@ -37,12 +44,6 @@
import gate.creole.metadata.RunTime;
import gate.util.GateRuntimeException;
-import java.net.URL;
-import java.util.Iterator;
-
-import org.apache.log4j.Level;
-import org.apache.log4j.Logger;
-
/**
* Description: This class is a wrapper for {@link
gate.creole.morph.Interpret},
* the Morphological Analyzer.
@@ -52,7 +53,7 @@
comment = "Morphological Analyzer for the English Language")
public class Morph
extends AbstractLanguageAnalyser
- implements ProcessingResource, CustomDuplication {
+ implements ANNIEConstants, ProcessingResource, CustomDuplication {
private static final long serialVersionUID = 6964689654685956128L;
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
_______________________________________________
GATE-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gate-cvs