From: <lor...@us...> - 2012-06-01 09:28:08
|
Revision: 3724 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=3724&view=rev Author: lorenz_b Date: 2012-06-01 09:27:59 +0000 (Fri, 01 Jun 2012) Log Message: ----------- Added additional constructor. Modified Paths: -------------- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/learning/SPARQLTemplateBasedLearner2.java trunk/components-ext/src/main/java/org/dllearner/common/index/SPARQLIndex.java trunk/components-ext/src/main/java/org/dllearner/common/index/SPARQLPropertiesIndex.java Modified: trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/learning/SPARQLTemplateBasedLearner2.java =================================================================== --- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/learning/SPARQLTemplateBasedLearner2.java 2012-05-22 00:31:06 UTC (rev 3723) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/learning/SPARQLTemplateBasedLearner2.java 2012-06-01 09:27:59 UTC (rev 3724) @@ -140,12 +140,17 @@ } public SPARQLTemplateBasedLearner2(SparqlEndpoint endpoint, Index resourcesIndex, Index classesIndex, Index propertiesIndex, PartOfSpeechTagger posTagger, WordNet wordNet, Options options){ + this(endpoint, resourcesIndex, classesIndex, propertiesIndex, posTagger, wordNet, options, new ExtractionDBCache("cache")); + } + + public SPARQLTemplateBasedLearner2(SparqlEndpoint endpoint, Index resourcesIndex, Index classesIndex, Index propertiesIndex, PartOfSpeechTagger posTagger, WordNet wordNet, Options options, ExtractionDBCache cache){ this.endpoint = endpoint; this.resourcesIndex = resourcesIndex; this.classesIndex = classesIndex; this.propertiesIndex = propertiesIndex; this.posTagger = posTagger; this.wordNet = wordNet; + this.cache = cache; setOptions(options); } @@ -163,12 +168,17 @@ } public SPARQLTemplateBasedLearner2(Model model, Index resourcesIndex, Index classesIndex, Index propertiesIndex, PartOfSpeechTagger posTagger, WordNet wordNet, Options options){ + this(model, resourcesIndex, classesIndex, propertiesIndex, posTagger, wordNet, options, new ExtractionDBCache("cache")); + } + + public SPARQLTemplateBasedLearner2(Model model, Index resourcesIndex, Index classesIndex, Index propertiesIndex, PartOfSpeechTagger posTagger, WordNet wordNet, Options options, ExtractionDBCache cache){ this.model = model; this.resourcesIndex = resourcesIndex; this.classesIndex = classesIndex; this.propertiesIndex = propertiesIndex; this.posTagger = posTagger; this.wordNet = wordNet; + this.cache = cache; setOptions(options); } @@ -1406,31 +1416,6 @@ return rs; } - private List<String> getResultFromRemoteEndpoint(String query){ - List<String> resources = new ArrayList<String>(); - try { - String queryString = query; - if(!query.contains("LIMIT") && !query.contains("ASK")){ - queryString = query + " LIMIT 10"; - } - ResultSet rs = SparqlQuery.convertJSONtoResultSet(cache.executeSelectQuery(endpoint, queryString)); - QuerySolution qs; - String projectionVar; - while(rs.hasNext()){ - qs = rs.next(); - projectionVar = qs.varNames().next(); - if(qs.get(projectionVar).isLiteral()){ - resources.add(qs.get(projectionVar).asLiteral().getLexicalForm()); - } else if(qs.get(projectionVar).isURIResource()){ - resources.add(qs.get(projectionVar).asResource().getURI()); - } - - } - } catch (Exception e) {e.printStackTrace(); - logger.error("Query execution failed.", e); - } - return resources; - } public int getLearnedPosition() { if(learnedPos >= 0){ @@ -1438,15 +1423,7 @@ } return learnedPos; } - - - - - - - - @Override public void start() { } Modified: trunk/components-ext/src/main/java/org/dllearner/common/index/SPARQLIndex.java =================================================================== --- trunk/components-ext/src/main/java/org/dllearner/common/index/SPARQLIndex.java 2012-05-22 00:31:06 UTC (rev 3723) +++ trunk/components-ext/src/main/java/org/dllearner/common/index/SPARQLIndex.java 2012-06-01 09:27:59 UTC (rev 3724) @@ -72,7 +72,7 @@ QuerySolution qs; while(rs.hasNext()){ - qs = rs.next();System.out.println(qs); + qs = rs.next(); RDFNode uriNode = qs.get("uri"); if(uriNode.isURIResource()){ resources.add(uriNode.asResource().getURI()); Modified: trunk/components-ext/src/main/java/org/dllearner/common/index/SPARQLPropertiesIndex.java =================================================================== --- trunk/components-ext/src/main/java/org/dllearner/common/index/SPARQLPropertiesIndex.java 2012-05-22 00:31:06 UTC (rev 3723) +++ trunk/components-ext/src/main/java/org/dllearner/common/index/SPARQLPropertiesIndex.java 2012-06-01 09:27:59 UTC (rev 3724) @@ -15,8 +15,9 @@ "FILTER(REGEX(STR(?label), '%s', 'i'))}\n" + "LIMIT %d OFFSET %d"; - super.queryWithLabelTemplate = "SELECT DISTINCT * WHERE {\n" + - "?s ?uri ?o.\n" + + super.queryWithLabelTemplate = "PREFIX owl:<http://www.w3.org/2002/07/owl#> SELECT DISTINCT * WHERE {\n" + +// "?s ?uri ?o.\n" + + "{?uri a owl:DatatypeProperty.} UNION {?uri a owl:ObjectProperty.} " + "?uri <http://www.w3.org/2000/01/rdf-schema#label> ?label\n" + "FILTER(REGEX(STR(?label), '%s', 'i'))}\n" + "LIMIT %d OFFSET %d"; @@ -31,8 +32,9 @@ "FILTER(REGEX(STR(?label), '%s', 'i'))}\n" + "LIMIT %d OFFSET %d"; - super.queryWithLabelTemplate = "SELECT DISTINCT * WHERE {\n" + - "?s ?uri ?o.\n" + + super.queryWithLabelTemplate = "PREFIX owl:<http://www.w3.org/2002/07/owl#> SELECT DISTINCT * WHERE {\n" + +// "?s ?uri ?o.\n" + + "{?uri a owl:DatatypeProperty.} UNION {?uri a owl:ObjectProperty.} " + "?uri <http://www.w3.org/2000/01/rdf-schema#label> ?label\n" + "FILTER(REGEX(STR(?label), '%s', 'i'))}\n" + "LIMIT %d OFFSET %d"; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |