From: <lor...@us...> - 2011-07-25 09:05:30
|
Revision: 2961 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=2961&view=rev Author: lorenz_b Date: 2011-07-25 09:05:24 +0000 (Mon, 25 Jul 2011) Log Message: ----------- Setting Wordnet dictionary via properties file. Modified Paths: -------------- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/learning/SPARQLTemplateBasedLearner.java trunk/components-ext/src/test/java/org/dllearner/algorithm/tbsl/WordNetTest.java Modified: trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/learning/SPARQLTemplateBasedLearner.java =================================================================== --- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/learning/SPARQLTemplateBasedLearner.java 2011-07-25 09:03:10 UTC (rev 2960) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/learning/SPARQLTemplateBasedLearner.java 2011-07-25 09:05:24 UTC (rev 2961) @@ -60,7 +60,7 @@ LUCENE, SIMILARITY, NONE } - private static final String OPTIONS_FILE = "tbsl/tbsl.properties"; + private static final String OPTIONS_FILE = SPARQLTemplateBasedLearner.class.getClassLoader().getResource("tbsl/tbsl.properties").getPath(); private static final Logger logger = Logger.getLogger(SPARQLTemplateBasedLearner.class); private Monitor mon = MonitorFactory.getTimeMonitor("tbsl"); @@ -100,14 +100,16 @@ private Lemmatizer lemmatizer = new LingPipeLemmatizer();// StanfordLemmatizer(); - public SPARQLTemplateBasedLearner(){ - try { - init(new Options(this.getClass().getClassLoader().getResourceAsStream(OPTIONS_FILE))); - } catch (InvalidFileFormatException e) { - e.printStackTrace(); - } catch (IOException e) { - e.printStackTrace(); - } + public SPARQLTemplateBasedLearner() throws InvalidFileFormatException, FileNotFoundException, IOException{ + this(OPTIONS_FILE); + } + + public SPARQLTemplateBasedLearner(String optionsFile) throws InvalidFileFormatException, FileNotFoundException, IOException{ + this(new Options(new FileReader(new File(optionsFile)))); + } + + public SPARQLTemplateBasedLearner(Options options){ + init(options); Set<String> predicateFilters = new HashSet<String>(); predicateFilters.add("http://dbpedia.org/ontology/wikiPageWikiLink"); @@ -120,22 +122,6 @@ templateGenerator = new Templator(); } - public SPARQLTemplateBasedLearner(String optionsFile){ - try { - init(new Options(new FileReader(new File(optionsFile)))); - } catch (InvalidFileFormatException e) { - e.printStackTrace(); - } catch (FileNotFoundException e) { - e.printStackTrace(); - } catch (IOException e) { - e.printStackTrace(); - } - } - - public SPARQLTemplateBasedLearner(Options options){ - init(options); - } - private void init(Options options){ String resourcesIndexUrl = options.fetch("solr.resources.url"); resource_index = new SolrSearch(resourcesIndexUrl); @@ -153,6 +139,9 @@ useRemoteEndpointValidation = options.get("learning.validationType", "remote").equals("remote") ? true : false; stopIfQueryResultNotEmpty = Boolean.parseBoolean(options.get("learning.stopAfterFirstNonEmptyQueryResult", "true")); maxTestedQueriesPerTemplate = Integer.parseInt(options.get("learning.maxTestedQueriesPerTemplate", "20")); + + String wordnetPath = options.get("wordnet.dictionary", "tbsl/dict"); + System.setProperty("wordnet.database.dir", wordnetPath); } public void setEndpoint(SparqlEndpoint endpoint){ @@ -737,10 +726,12 @@ /** * @param args - * @throws MalformedURLException * @throws NoTemplateFoundException + * @throws IOException + * @throws FileNotFoundException + * @throws InvalidFileFormatException */ - public static void main(String[] args) throws MalformedURLException, NoTemplateFoundException { + public static void main(String[] args) throws NoTemplateFoundException, InvalidFileFormatException, FileNotFoundException, IOException { // Logger.getLogger(DefaultHttpParams.class).setLevel(Level.OFF); // Logger.getLogger(HttpClient.class).setLevel(Level.OFF); // Logger.getLogger(HttpMethodBase.class).setLevel(Level.OFF); Modified: trunk/components-ext/src/test/java/org/dllearner/algorithm/tbsl/WordNetTest.java =================================================================== --- trunk/components-ext/src/test/java/org/dllearner/algorithm/tbsl/WordNetTest.java 2011-07-25 09:03:10 UTC (rev 2960) +++ trunk/components-ext/src/test/java/org/dllearner/algorithm/tbsl/WordNetTest.java 2011-07-25 09:05:24 UTC (rev 2961) @@ -7,7 +7,6 @@ public static void main(String[] args) { WordNet wordnet = new WordNet(); - wordnet.init(); System.out.println(wordnet.getBestSynonyms("city")); System.out.println(wordnet.getAttributes("biggest")); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |