Revision: 19911
http://sourceforge.net/p/gate/code/19911
Author: markagreenwood
Date: 2017-01-04 13:06:20 +0000 (Wed, 04 Jan 2017)
Log Message:
-----------
removed what is probably the worst bit of hacky code I'll see all year,
possibly all decade
Modified Paths:
--------------
gate/trunk/plugins/Stanford_CoreNLP/build.xml
gate/trunk/plugins/Stanford_CoreNLP/src/gate/stanford/NER.java
gate/trunk/plugins/Stanford_CoreNLP/src/gate/stanford/Parser.java
Modified: gate/trunk/plugins/Stanford_CoreNLP/build.xml
===================================================================
--- gate/trunk/plugins/Stanford_CoreNLP/build.xml 2017-01-04 02:23:20 UTC
(rev 19910)
+++ gate/trunk/plugins/Stanford_CoreNLP/build.xml 2017-01-04 13:06:20 UTC
(rev 19911)
@@ -73,7 +73,7 @@
<target name="compile" depends="prepare" description="Compile Java sources">
- <javac srcdir="src" destdir="${classes.dir}" debug="true" source="1.7"
target="1.7" debuglevel="lines,vars,source" deprecation="on" optimize="off"
encoding="UTF-8" classpathref="compile.classpath">
+ <javac srcdir="src" destdir="${classes.dir}" debug="true" source="1.8"
target="1.8" debuglevel="lines,vars,source" deprecation="on" optimize="off"
encoding="UTF-8" classpathref="compile.classpath">
<compilerarg value="-Xlint:unchecked"/>
</javac>
</target>
Modified: gate/trunk/plugins/Stanford_CoreNLP/src/gate/stanford/NER.java
===================================================================
--- gate/trunk/plugins/Stanford_CoreNLP/src/gate/stanford/NER.java
2017-01-04 02:23:20 UTC (rev 19910)
+++ gate/trunk/plugins/Stanford_CoreNLP/src/gate/stanford/NER.java
2017-01-04 13:06:20 UTC (rev 19911)
@@ -22,6 +22,19 @@
package gate.stanford;
+import java.io.InputStream;
+import java.net.URL;
+import java.text.NumberFormat;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import java.util.ListIterator;
+import java.util.zip.GZIPInputStream;
+
+import org.apache.log4j.Level;
+import org.apache.log4j.Logger;
+
import edu.stanford.nlp.ie.AbstractSequenceClassifier;
import edu.stanford.nlp.ie.crf.CRFClassifier;
import edu.stanford.nlp.ling.CoreAnnotations;
@@ -42,17 +55,6 @@
import gate.util.OffsetComparator;
import gate.util.SimpleFeatureMapImpl;
-import java.net.URL;
-import java.text.NumberFormat;
-import java.util.ArrayList;
-import java.util.Collections;
-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 the Stanford NER tool v3.2.0.
*/
@@ -96,9 +98,9 @@
public Resource init() throws ResourceInstantiationException {
if(tagger == null) {
fireStatusChanged("Loading Stanford NER model");
- try {
- // nasty workaround for stanford NER's path format inconsistency -
tagger is content with uris beginning file:, ner labeller is not
- tagger =
CRFClassifier.getClassifier(modelFile.toString().substring(5));
+ try (InputStream in = modelFile.openStream();
+ GZIPInputStream gzipIn = new GZIPInputStream(in)){
+ tagger = CRFClassifier.getClassifier(gzipIn);
} catch(Exception e) {
throw new ResourceInstantiationException(e);
}
Modified: gate/trunk/plugins/Stanford_CoreNLP/src/gate/stanford/Parser.java
===================================================================
--- gate/trunk/plugins/Stanford_CoreNLP/src/gate/stanford/Parser.java
2017-01-04 02:23:20 UTC (rev 19910)
+++ gate/trunk/plugins/Stanford_CoreNLP/src/gate/stanford/Parser.java
2017-01-04 13:06:20 UTC (rev 19911)
@@ -514,8 +514,8 @@
if(stanfordParser != null) return;
try {
- String filepath = Files.fileFromURL(parserFile).getAbsolutePath();
- stanfordParser = LexicalizedParser.getParserFromSerializedFile(filepath);
+ //String filepath = Files.fileFromURL(parserFile).getAbsolutePath();
+ stanfordParser =
LexicalizedParser.getParserFromSerializedFile(parserFile.toExternalForm());
}
catch(Exception e) {
throw new ResourceInstantiationException(e);
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
GATE-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gate-cvs