Revision: 20024 http://sourceforge.net/p/gate/code/20024 Author: markagreenwood Date: 2017-01-31 11:30:47 +0000 (Tue, 31 Jan 2017) Log Message: ----------- Gazetteers now use ResourceReferences instead of URLs as well
Modified Paths: -------------- gate/branches/sawdust2/plugins/ANNIE/src/main/java/com/ontotext/gate/gazetteer/HashGazetteer.java gate/branches/sawdust2/plugins/ANNIE/src/main/java/gate/creole/gazetteer/AbstractGazetteer.java gate/branches/sawdust2/plugins/ANNIE/src/main/java/gate/creole/gazetteer/DefaultGazetteer.java gate/branches/sawdust2/plugins/ANNIE/src/main/java/gate/creole/gazetteer/Gazetteer.java gate/branches/sawdust2/plugins/ANNIE/src/main/java/gate/gui/GazetteerEditor.java 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 2017-01-31 11:13:40 UTC (rev 20023) +++ gate/branches/sawdust2/plugins/ANNIE/src/main/java/com/ontotext/gate/gazetteer/HashGazetteer.java 2017-01-31 11:30:47 UTC (rev 20024) @@ -23,6 +23,7 @@ import gate.util.InvalidOffsetException; import gate.util.LuckyException; +import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; @@ -55,7 +56,12 @@ try { mapsList = new HashMap[1000]; definition = new LinearDefinition(); - definition.setURL(listsURL); + try { + definition.setURL(listsURL.toURL()); + } + catch (IOException e) { + throw new ResourceInstantiationException(e); + } definition.load(); int i = definition.size(); listsByNode = definition.loadLists(); Modified: gate/branches/sawdust2/plugins/ANNIE/src/main/java/gate/creole/gazetteer/AbstractGazetteer.java =================================================================== --- gate/branches/sawdust2/plugins/ANNIE/src/main/java/gate/creole/gazetteer/AbstractGazetteer.java 2017-01-31 11:13:40 UTC (rev 20023) +++ gate/branches/sawdust2/plugins/ANNIE/src/main/java/gate/creole/gazetteer/AbstractGazetteer.java 2017-01-31 11:30:47 UTC (rev 20024) @@ -15,16 +15,17 @@ */ package gate.creole.gazetteer; +import java.util.HashSet; +import java.util.Iterator; +import java.util.Set; + import gate.creole.AbstractLanguageAnalyser; import gate.creole.ResourceInstantiationException; +import gate.creole.ResourceReference; import gate.creole.metadata.CreoleParameter; import gate.creole.metadata.Optional; import gate.creole.metadata.RunTime; -import java.util.HashSet; -import java.util.Iterator; -import java.util.Set; - /**AbstractGazetteer * This class implements the common-for-all methods of the Gazetteer interface*/ public abstract class AbstractGazetteer @@ -46,7 +47,7 @@ * The value of this property is the URL that will be used for reading the * lists that define this Gazetteer */ - protected java.net.URL listsURL; + protected ResourceReference listsURL; /** * Should this gazetteer be case sensitive. The default value is true. @@ -112,13 +113,13 @@ } @Override - public java.net.URL getListsURL() { + public ResourceReference getListsURL() { return listsURL; } @Override @CreoleParameter(comment="The URL to the file with list of lists", suffixes="def", defaultValue="resources/gazetteer/lists.def") - public void setListsURL(java.net.URL newListsURL) { + public void setListsURL(ResourceReference newListsURL) { listsURL = newListsURL; } 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 2017-01-31 11:13:40 UTC (rev 20023) +++ gate/branches/sawdust2/plugins/ANNIE/src/main/java/gate/creole/gazetteer/DefaultGazetteer.java 2017-01-31 11:30:47 UTC (rev 20024) @@ -17,6 +17,8 @@ */ package gate.creole.gazetteer; +import java.io.IOException; +import java.io.IOException; import java.io.Serializable; import java.util.Arrays; import java.util.HashSet; @@ -115,7 +117,13 @@ } definition = new LinearDefinition(); definition.setSeparator(Strings.unescape(gazetteerFeatureSeparator)); - definition.setURL(listsURL); + try { + definition.setURL(listsURL.toURL()); + } + catch (IOException e) { + throw new ResourceInstantiationException(e); + } + definition.load(); int linesCnt = definition.size(); listsByNode = definition.loadLists(); Modified: gate/branches/sawdust2/plugins/ANNIE/src/main/java/gate/creole/gazetteer/Gazetteer.java =================================================================== --- gate/branches/sawdust2/plugins/ANNIE/src/main/java/gate/creole/gazetteer/Gazetteer.java 2017-01-31 11:13:40 UTC (rev 20023) +++ gate/branches/sawdust2/plugins/ANNIE/src/main/java/gate/creole/gazetteer/Gazetteer.java 2017-01-31 11:30:47 UTC (rev 20024) @@ -17,6 +17,8 @@ import java.util.Set; +import gate.creole.ResourceReference; + /**The Gazetteer interface defines the mandatory methods of a gazetteer PR. */ public interface Gazetteer extends gate.LanguageAnalyser,gate.ProcessingResource { @@ -47,11 +49,11 @@ /**Gets the url of the lists.def file * @return the url of the lists.def file */ - public java.net.URL getListsURL() ; + public ResourceReference getListsURL() ; /**Sets the url of the lists.def file * @param newListsURL the url of the lists.def file to be set */ - public void setListsURL(java.net.URL newListsURL) ; + public void setListsURL(ResourceReference newListsURL) ; /**Triggers case sensitive * @param newCaseSensitive turn on or off case sensitivity */ Modified: gate/branches/sawdust2/plugins/ANNIE/src/main/java/gate/gui/GazetteerEditor.java =================================================================== --- gate/branches/sawdust2/plugins/ANNIE/src/main/java/gate/gui/GazetteerEditor.java 2017-01-31 11:13:40 UTC (rev 20023) +++ gate/branches/sawdust2/plugins/ANNIE/src/main/java/gate/gui/GazetteerEditor.java 2017-01-31 11:30:47 UTC (rev 20024) @@ -825,8 +825,15 @@ } // update file list name in the drop down list - File gazetteerDirectory = new File( - Files.fileFromURL(gazetteer.getListsURL()).getParent()); + File defFile = null; + try { + Files.fileFromURL(gazetteer.getListsURL().toURL()); + } + catch (IOException ioe) { + ioe.printStackTrace(); + return; + } + File gazetteerDirectory = new File(defFile.getParent()); File[] files = gazetteerDirectory.listFiles(new FilenameFilter() { @Override public boolean accept(File dir, String name) { 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 GATE-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gate-cvs