From: <ku...@us...> - 2008-01-19 02:08:22
|
Revision: 397 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=397&view=rev Author: kurzum Date: 2008-01-18 18:08:16 -0800 (Fri, 18 Jan 2008) Log Message: ----------- I made some test classes, problem with TestStaticQueries everything in .sparql.old can be removed the extraction algorithm might not be working, because of problems with the cache or so check also how to return literals and such Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/kb/sparql/query/SparqlQuery.java Added Paths: ----------- trunk/src/dl-learner/org/dllearner/kb/sparql/test/TestExtraction.java trunk/src/dl-learner/org/dllearner/kb/sparql/test/TestStaticQueries.java Removed Paths: ------------- trunk/src/dl-learner/org/dllearner/kb/sparql/test/Test.java Modified: trunk/src/dl-learner/org/dllearner/kb/sparql/query/SparqlQuery.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/sparql/query/SparqlQuery.java 2008-01-19 01:26:40 UTC (rev 396) +++ trunk/src/dl-learner/org/dllearner/kb/sparql/query/SparqlQuery.java 2008-01-19 02:08:16 UTC (rev 397) @@ -155,9 +155,13 @@ public Vector<StringTuple> getAsVectorOfTupels(String varName1, String varName2) { ResultSet rs = send(); + Vector<StringTuple> vret = new Vector<StringTuple>(); List<ResultBinding> l = ResultSetFormatter.toList(rs); + //System.out.println(l); + //System.out.println(ResultSetFormatter.asXMLString(rs)); for (ResultBinding resultBinding : l) { + vret.add(new StringTuple(resultBinding.get(varName1).toString(), resultBinding.get(varName2).toString())); } @@ -200,7 +204,7 @@ //TODO maybe use http://xmlns:com/foaf/0.1/page String queryString= "SELECT DISTINCT ?subject\n"+ - "WHERE { ?subject <http://www.w3.org/2000/01/rdf-schema#label> ?object.?object bif:contains '\""+label+"\"'@en}\n"+ + "WHERE { ?subject <http://www.w3.org/2000/01/rdf-schema#label> ?object. ?object bif:contains '\""+label+"\"'@en}\n"+ "LIMIT "+limit; return new SparqlQuery( queryString,endpoint); } @@ -225,7 +229,7 @@ */ public static SparqlQuery makeArticleQuery(String subject,SparqlEndpoint endpoint){ String queryString = - "SELECT ?predicate,?object\n"+ + "SELECT ?predicate ?object\n"+ "WHERE { <"+subject+"> ?predicate ?object}\n"; return new SparqlQuery( queryString,endpoint); } Deleted: trunk/src/dl-learner/org/dllearner/kb/sparql/test/Test.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/sparql/test/Test.java 2008-01-19 01:26:40 UTC (rev 396) +++ trunk/src/dl-learner/org/dllearner/kb/sparql/test/Test.java 2008-01-19 02:08:16 UTC (rev 397) @@ -1,58 +0,0 @@ -/** - * Copyright (C) 2007, Sebastian Hellmann - * - * This file is part of DL-Learner. - * - * DL-Learner is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * DL-Learner is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - */ -package org.dllearner.kb.sparql.test; - -import java.io.File; -import java.io.FileWriter; -import java.net.URI; - -import org.dllearner.kb.sparql.Manager; - -/** - * Test class, uses the whole thing - * - * @author Sebastian Hellmann - * - */ -public class Test { - - public static void main(String[] args) { - System.out.println("Start"); - // String test2 = "http://www.extraction.org/config#dbpediatest"; - // String test = "http://www.extraction.org/config#localjoseki"; - try { - // URI u = new URI(test); - Manager m = new Manager(); - // m.usePredefinedConfiguration(u); - - URI u2 = new URI("http://dbpedia.org/resource/Angela_Merkel"); - - String filename = System.currentTimeMillis() + ".nt"; - FileWriter fw = new FileWriter(new File(filename), true); - fw.write(m.extract(u2)); - fw.flush(); - fw.close(); - - } catch (Exception e) { - e.printStackTrace(); - } - } - -} Added: trunk/src/dl-learner/org/dllearner/kb/sparql/test/TestExtraction.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/sparql/test/TestExtraction.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/kb/sparql/test/TestExtraction.java 2008-01-19 02:08:16 UTC (rev 397) @@ -0,0 +1,69 @@ +/** + * Copyright (C) 2007, Sebastian Hellmann + * + * This file is part of DL-Learner. + * + * DL-Learner is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * DL-Learner is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ +package org.dllearner.kb.sparql.test; + +import java.io.File; +import java.io.FileWriter; +import java.net.URI; +import java.util.LinkedList; + +import org.dllearner.kb.sparql.Manager; +import org.dllearner.kb.sparql.Manipulator; +import org.dllearner.kb.sparql.configuration.SparqlEndpoint; +import org.dllearner.kb.sparql.configuration.SparqlQueryType; +import org.dllearner.utilities.StringTuple; + +/** + * Test class, uses the whole thing + * + * @author Sebastian Hellmann + * + */ +public class TestExtraction { + + public static void main(String[] args) { + System.out.println("Start"); + // String test2 = "http://www.extraction.org/config#dbpediatest"; + // String test = "http://www.extraction.org/config#localjoseki"; + try { + // URI u = new URI(test); + Manager m = new Manager(); + // m.usePredefinedConfiguration(u); + + URI u2 = new URI("http://dbpedia.org/resource/Angela_Merkel"); + m.useConfiguration( + SparqlQueryType.getFilterByNumber(1),SparqlEndpoint.getEndpointByNumber(1), + new Manipulator("",200,new LinkedList<StringTuple>(),new LinkedList<StringTuple>()), + 1,true,true); + //, , + //manipulator, recursiondepth, getAllSuperClasses, closeAfterRecursion) + + String filename = System.currentTimeMillis() + ".nt"; + FileWriter fw = new FileWriter(new File(filename), true); + fw.write(m.extract(u2)); + fw.flush(); + fw.close(); + + } catch (Exception e) { + e.printStackTrace(); + } + } + +} Added: trunk/src/dl-learner/org/dllearner/kb/sparql/test/TestStaticQueries.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/sparql/test/TestStaticQueries.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/kb/sparql/test/TestStaticQueries.java 2008-01-19 02:08:16 UTC (rev 397) @@ -0,0 +1,72 @@ +/** + * Copyright (C) 2007-2008, Jens Lehmann + * + * This file is part of DL-Learner. + * + * DL-Learner is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * DL-Learner is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ +package org.dllearner.kb.sparql.test; + +import org.dllearner.kb.sparql.configuration.SparqlEndpoint; +import org.dllearner.kb.sparql.query.SparqlQuery; + +public class TestStaticQueries { + + // tests makeArticleQuery + // + // + public static void main(String[] args) { + String test1="http://dbpedia.org/resource/Angela_Merkel"; + String test2="http://dbpedia.org/resource/Leipzig"; + String test3="http://dbpedia.org/class/yago/Woman110787470"; + boolean one=false; + boolean two=true; + boolean three=false; + try { + if(one){ + //System.out.println(SparqlQuery.makeArticleQuery(test1, + // SparqlEndpoint.getEndpointByNumber(1)).getAsXMLString()); + //System.out.println(SparqlQuery.makeArticleQuery(test1, + // SparqlEndpoint.getEndpointByNumber(1)).getAsList()); + System.out.println(SparqlQuery.makeArticleQuery(test1, + SparqlEndpoint.getEndpointByNumber(1)).getAsVectorOfTupels("predicate", "object")); + } + + if(two){ + System.out.println(SparqlQuery.makeLabelQuery(test2,10, + SparqlEndpoint.getEndpointByNumber(1)).getAsXMLString()); + System.out.println(SparqlQuery.makeLabelQuery(test2,10, + SparqlEndpoint.getEndpointByNumber(1)).getAsList()); + System.out.println(SparqlQuery.makeLabelQuery(test2,10, + SparqlEndpoint.getEndpointByNumber(1)).getAsVector("subject")); + } + if(three){ + System.out.println(SparqlQuery.makeConceptQuery(test3, + SparqlEndpoint.getEndpointByNumber(1)).getAsXMLString()); + System.out.println(SparqlQuery.makeConceptQuery(test3, + SparqlEndpoint.getEndpointByNumber(1)).getAsList()); + System.out.println(SparqlQuery.makeConceptQuery(test3, + SparqlEndpoint.getEndpointByNumber(1)).getAsVector("subject")); + } + + + + } catch (Exception e) { + e.printStackTrace(); + } + + } + +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |