001 /**
002 * Copyright (C) 2007-2011, Jens Lehmann
003 *
004 * This file is part of DL-Learner.
005 *
006 * DL-Learner is free software; you can redistribute it and/or modify
007 * it under the terms of the GNU General Public License as published by
008 * the Free Software Foundation; either version 3 of the License, or
009 * (at your option) any later version.
010 *
011 * DL-Learner is distributed in the hope that it will be useful,
012 * but WITHOUT ANY WARRANTY; without even the implied warranty of
013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
014 * GNU General Public License for more details.
015 *
016 * You should have received a copy of the GNU General Public License
017 * along with this program. If not, see <http://www.gnu.org/licenses/>.
018 */
019
020 package org.dllearner.utilities.learn;
021
022 import org.dllearner.core.ComponentManager;
023 import org.dllearner.core.AbstractKnowledgeSource;
024 import org.dllearner.core.AbstractCELA;
025 import org.dllearner.core.AbstractLearningProblem;
026 import org.dllearner.core.AbstractReasonerComponent;
027 import org.dllearner.kb.sparql.Cache;
028 import org.dllearner.kb.sparql.SparqlEndpoint;
029
030 public class LearnSPARQLConfiguration extends LearnConfiguration {
031
032
033
034 // SparqlKnowledgeSource
035 public SparqlEndpoint sparqlEndpoint = SparqlEndpoint.getEndpointDBpedia();
036 public String predefinedEndpoint = null;
037 public int recursiondepth = 1;
038 public boolean closeAfterRecursion = true;
039 public boolean getAllSuperClasses = true;
040 public boolean useLits = false;
041 public boolean randomizeCache = false;
042 public String predefinedFilter = null;
043
044
045 @Override
046 public void applyConfigEntries(ComponentManager cm, AbstractKnowledgeSource ks, AbstractLearningProblem lp, AbstractReasonerComponent rs, AbstractCELA la) {
047 try {
048 super.applyConfigEntries(cm, ks, lp, rs, la);
049 // KNOWLEDGESOURCE
050 if(predefinedEndpoint ==null){
051 cm.applyConfigEntry(ks, "url", sparqlEndpoint.getURL().toString());
052 }else {
053 cm.applyConfigEntry(ks, "predefinedEndpoint", predefinedEndpoint);
054 }
055 if(predefinedFilter==null){
056 //todo manual
057 }else{
058 cm.applyConfigEntry(ks, "predefinedFilter", predefinedFilter);
059 }
060
061 cm.applyConfigEntry(ks, "useLits", useLits);
062 cm.applyConfigEntry(ks, "recursionDepth", recursiondepth);
063 cm.applyConfigEntry(ks, "closeAfterRecursion", closeAfterRecursion);
064 cm.applyConfigEntry(ks, "getAllSuperClasses", getAllSuperClasses);
065
066
067 if (randomizeCache)
068 cm.applyConfigEntry(ks, "cacheDir", "cache/"
069 + System.currentTimeMillis() + "");
070 else {
071 cm.applyConfigEntry(ks, "cacheDir", Cache.getDefaultCacheDir());
072 }
073
074
075 } catch (Exception e) {
076 e.printStackTrace();
077 }
078 // return null;
079
080 }
081 }