From: <jen...@us...> - 2007-12-02 14:34:18
|
Revision: 302 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=302&view=rev Author: jenslehmann Date: 2007-12-02 06:34:12 -0800 (Sun, 02 Dec 2007) Log Message: ----------- more code cleanup Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/kb/sparql/ClassNode.java trunk/src/dl-learner/org/dllearner/kb/sparql/ExtractionAlgorithm.java trunk/src/dl-learner/org/dllearner/kb/sparql/InstanceNode.java trunk/src/dl-learner/org/dllearner/kb/sparql/Manager.java trunk/src/dl-learner/org/dllearner/kb/sparql/Node.java trunk/src/dl-learner/org/dllearner/kb/sparql/PredefinedConfigurations.java trunk/src/dl-learner/org/dllearner/kb/sparql/PropertyNode.java trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlQueryMaker.java trunk/src/dl-learner/org/dllearner/kb/sparql/SpecificSparqlEndpoint.java trunk/src/dl-learner/org/dllearner/kb/sparql/TypedSparqlQuery.java Modified: trunk/src/dl-learner/org/dllearner/kb/sparql/ClassNode.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/sparql/ClassNode.java 2007-12-02 14:19:48 UTC (rev 301) +++ trunk/src/dl-learner/org/dllearner/kb/sparql/ClassNode.java 2007-12-02 14:34:12 UTC (rev 302) @@ -16,7 +16,7 @@ @Override public Vector<Node> expand(TypedSparqlQuery tsq, Manipulator m) { - Set<Tupel> s = tsq.query(this.URI); + Set<Tupel> s = tsq.query(this.uri); s = m.check(s, this); Vector<Node> Nodes = new Vector<Node>(); // Manipulation @@ -47,11 +47,11 @@ @Override public Set<String> toNTriple() { Set<String> s = new HashSet<String>(); - s.add("<" + this.URI + "><" + "http://www.w3.org/1999/02/22-rdf-syntax-ns#type" + "><" + s.add("<" + this.uri + "><" + "http://www.w3.org/1999/02/22-rdf-syntax-ns#type" + "><" + "http://www.w3.org/2002/07/owl#Class" + ">."); for (PropertyNode one : properties) { - s.add("<" + this.URI + "><" + one.getURI() + "><" + one.getB().getURI() + ">."); + s.add("<" + this.uri + "><" + one.getURI() + "><" + one.getB().getURI() + ">."); s.addAll(one.getB().toNTriple()); } Modified: trunk/src/dl-learner/org/dllearner/kb/sparql/ExtractionAlgorithm.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/sparql/ExtractionAlgorithm.java 2007-12-02 14:19:48 UTC (rev 301) +++ trunk/src/dl-learner/org/dllearner/kb/sparql/ExtractionAlgorithm.java 2007-12-02 14:34:12 UTC (rev 302) @@ -5,15 +5,15 @@ public class ExtractionAlgorithm { - private Configuration Configuration; - private Manipulator Manipulator; - private int recursiondepth = 2; + private Configuration configuration; + private Manipulator manipulator; + private int recursionDepth = 2; private boolean getAllBackground = true; public ExtractionAlgorithm(Configuration Configuration) { - this.Configuration = Configuration; - this.Manipulator = Configuration.getManipulator(); - this.recursiondepth=Configuration.getRecursiondepth(); + this.configuration = Configuration; + this.manipulator = Configuration.getManipulator(); + this.recursionDepth=Configuration.getRecursiondepth(); this.getAllBackground=Configuration.isGetAllBackground(); } @@ -37,14 +37,14 @@ System.out.println("StartVector: " + v); // n.expand(tsp, this.Manipulator); // Vector<Node> second= - for (int x = 1; x <= this.recursiondepth; x++) { + for (int x = 1; x <= this.recursionDepth; x++) { Vector<Node> tmp = new Vector<Node>(); while (v.size() > 0) { Node tmpNode = v.remove(0); System.out.println("Expanding " + tmpNode); //System.out.println(this.Manipulator); - Vector<Node> tmpVec = tmpNode.expand(tsp, this.Manipulator); + Vector<Node> tmpVec = tmpNode.expand(tsp, this.manipulator); tmp.addAll(tmpVec); } @@ -62,7 +62,7 @@ System.out.println(classes.size()); Node next=classes.remove(0); System.out.println(next); - classes.addAll(next.expand(tsp, this.Manipulator)); + classes.addAll(next.expand(tsp, this.manipulator)); } } Modified: trunk/src/dl-learner/org/dllearner/kb/sparql/InstanceNode.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/sparql/InstanceNode.java 2007-12-02 14:19:48 UTC (rev 301) +++ trunk/src/dl-learner/org/dllearner/kb/sparql/InstanceNode.java 2007-12-02 14:34:12 UTC (rev 302) @@ -21,7 +21,7 @@ @Override public Vector<Node> expand(TypedSparqlQuery tsq, Manipulator m) { - Set<Tupel> s = tsq.query(this.URI); + Set<Tupel> s = tsq.query(this.uri); // Manipulation m.check(s, this); //System.out.println("fffffff"+m); @@ -60,15 +60,15 @@ @Override public Set<String> toNTriple() { Set<String> s = new HashSet<String>(); - s.add("<" + this.URI + "><" + "http://www.w3.org/1999/02/22-rdf-syntax-ns#type" + "><" + s.add("<" + this.uri + "><" + "http://www.w3.org/1999/02/22-rdf-syntax-ns#type" + "><" + "http://www.w3.org/2002/07/owl#Thing" + ">."); for (ClassNode one : classes) { - s.add("<" + this.URI + "><" + "http://www.w3.org/1999/02/22-rdf-syntax-ns#type" + "><" + s.add("<" + this.uri + "><" + "http://www.w3.org/1999/02/22-rdf-syntax-ns#type" + "><" + one.getURI() + ">."); s.addAll(one.toNTriple()); } for (PropertyNode one : properties) { - s.add("<" + this.URI + "><" + one.getURI() + "><" + one.getB().getURI() + ">."); + s.add("<" + this.uri + "><" + one.getURI() + "><" + one.getB().getURI() + ">."); s.addAll(one.toNTriple()); s.addAll(one.getB().toNTriple()); } Modified: trunk/src/dl-learner/org/dllearner/kb/sparql/Manager.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/sparql/Manager.java 2007-12-02 14:19:48 UTC (rev 301) +++ trunk/src/dl-learner/org/dllearner/kb/sparql/Manager.java 2007-12-02 14:34:12 UTC (rev 302) @@ -6,9 +6,9 @@ public class Manager { - private Configuration Configuration; - private TypedSparqlQuery TypedSparqlQuery; - private ExtractionAlgorithm ExtractionAlgorithm; + private Configuration configuration; + private TypedSparqlQuery typedSparqlQuery; + private ExtractionAlgorithm extractionAlgorithm; /*public void usePredefinedConfiguration(URI uri) { @@ -19,23 +19,23 @@ public void usePredefinedConfiguration(int i) { - this.Configuration = PredefinedConfigurations.get(i); - this.TypedSparqlQuery = new TypedSparqlQuery(Configuration); - this.ExtractionAlgorithm = new ExtractionAlgorithm(Configuration); + this.configuration = PredefinedConfigurations.get(i); + this.typedSparqlQuery = new TypedSparqlQuery(configuration); + this.extractionAlgorithm = new ExtractionAlgorithm(configuration); } public void useConfiguration(SparqlQueryType SparqlQueryType, SpecificSparqlEndpoint SparqlEndpoint, int recursiondepth,boolean getAllBackground) { - this.Configuration = new Configuration(SparqlEndpoint, SparqlQueryType,recursiondepth,getAllBackground); - this.TypedSparqlQuery = new TypedSparqlQuery(Configuration); - this.ExtractionAlgorithm = new ExtractionAlgorithm(Configuration); + this.configuration = new Configuration(SparqlEndpoint, SparqlQueryType,recursiondepth,getAllBackground); + this.typedSparqlQuery = new TypedSparqlQuery(configuration); + this.extractionAlgorithm = new ExtractionAlgorithm(configuration); } public String extract(URI uri) { // this.TypedSparqlQuery.query(uri); // System.out.println(ExtractionAlgorithm.getFirstNode(uri)); System.out.println("Start extracting"); - Node n = this.ExtractionAlgorithm.expandNode(uri, this.TypedSparqlQuery); + Node n = this.extractionAlgorithm.expandNode(uri, this.typedSparqlQuery); Set<String> s = n.toNTriple(); String nt = ""; for (String str : s) { @@ -52,7 +52,7 @@ for (String one : instances) { try { - Node n = this.ExtractionAlgorithm.expandNode(new URI(one), this.TypedSparqlQuery); + Node n = this.extractionAlgorithm.expandNode(new URI(one), this.typedSparqlQuery); ret.addAll(n.toNTriple()); } catch (Exception e) { e.printStackTrace(); Modified: trunk/src/dl-learner/org/dllearner/kb/sparql/Node.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/sparql/Node.java 2007-12-02 14:19:48 UTC (rev 301) +++ trunk/src/dl-learner/org/dllearner/kb/sparql/Node.java 2007-12-02 14:34:12 UTC (rev 302) @@ -5,7 +5,7 @@ import java.util.Vector; public abstract class Node { - URI URI; + URI uri; protected String type; protected boolean expanded = false; @@ -14,7 +14,7 @@ // Hashtable<String,Node> datatype=new Hashtable<String,Node>();; public Node(URI u) { - this.URI = u; + this.uri = u; } @@ -31,7 +31,7 @@ @Override public String toString() { - return "Node: " + URI + ":" + type; + return "Node: " + uri + ":" + type; } @@ -48,7 +48,7 @@ } public URI getURI() { - return URI; + return uri; } } Modified: trunk/src/dl-learner/org/dllearner/kb/sparql/PredefinedConfigurations.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/sparql/PredefinedConfigurations.java 2007-12-02 14:19:48 UTC (rev 301) +++ trunk/src/dl-learner/org/dllearner/kb/sparql/PredefinedConfigurations.java 2007-12-02 14:34:12 UTC (rev 302) @@ -7,53 +7,51 @@ public class PredefinedConfigurations { - public static Configuration get(int i){ - - switch (i){ - case 0: return dbpediaYago(); - + public static Configuration get(int i) { + + switch (i) { + case 0: + return dbpediaYago(); + + } + return null; } - return null; - } - - public static Configuration dbpediaYago(){ - URL u=null; - HashMap<String, String>m=new HashMap<String, String>(); - m.put("default-graph-uri","http://dbpedia.org"); - m.put("format","application/sparql-results.xml"); - try{ - u=new URL("http://dbpedia.openlinksw.com:8890/sparql"); - }catch (Exception e) {e.printStackTrace();} - SpecificSparqlEndpoint sse=new SpecificSparqlEndpoint( - u,"dbpedia.openlinksw.com",m); - //System.out.println(u); - Set<String>pred=new HashSet<String>(); - pred.add("http://www.w3.org/2004/02/skos/core"); - pred.add("http://www.w3.org/2002/07/owl#sameAs"); - pred.add("http://xmlns.com/foaf/0.1/"); - pred.add("http://dbpedia.org/property/reference"); - pred.add("http://dbpedia.org/property/website"); - pred.add("http://dbpedia.org/property/wikipage"); - - - Set<String>obj=new HashSet<String>(); - obj.add("http://dbpedia.org/resource/Category:Wikipedia_"); - obj.add("http://dbpedia.org/resource/Category:Articles_"); - obj.add("http://xmlns.com/foaf/0.1/"); - obj.add("http://upload.wikimedia.org/wikipedia/commons"); - obj.add("http://upload.wikimedia.org/wikipedia"); - obj.add("http://www.geonames.org"); - obj.add("http://www.w3.org/2006/03/wn/wn20/instances/synset"); - obj.add("http://www4.wiwiss.fu-berlin.de/flickrwrappr"); - obj.add("http://www.w3.org/2004/02/skos/core"); - - SparqlQueryType sqt=new SparqlQueryType("forbid",obj,pred,"false"); - - - - return new Configuration(sse,sqt,2,true); - - } - - + + public static Configuration dbpediaYago() { + URL u = null; + HashMap<String, String> m = new HashMap<String, String>(); + m.put("default-graph-uri", "http://dbpedia.org"); + m.put("format", "application/sparql-results.xml"); + try { + u = new URL("http://dbpedia.openlinksw.com:8890/sparql"); + } catch (Exception e) { + e.printStackTrace(); + } + SpecificSparqlEndpoint sse = new SpecificSparqlEndpoint(u, "dbpedia.openlinksw.com", m); + // System.out.println(u); + Set<String> pred = new HashSet<String>(); + pred.add("http://www.w3.org/2004/02/skos/core"); + pred.add("http://www.w3.org/2002/07/owl#sameAs"); + pred.add("http://xmlns.com/foaf/0.1/"); + pred.add("http://dbpedia.org/property/reference"); + pred.add("http://dbpedia.org/property/website"); + pred.add("http://dbpedia.org/property/wikipage"); + + Set<String> obj = new HashSet<String>(); + obj.add("http://dbpedia.org/resource/Category:Wikipedia_"); + obj.add("http://dbpedia.org/resource/Category:Articles_"); + obj.add("http://xmlns.com/foaf/0.1/"); + obj.add("http://upload.wikimedia.org/wikipedia/commons"); + obj.add("http://upload.wikimedia.org/wikipedia"); + obj.add("http://www.geonames.org"); + obj.add("http://www.w3.org/2006/03/wn/wn20/instances/synset"); + obj.add("http://www4.wiwiss.fu-berlin.de/flickrwrappr"); + obj.add("http://www.w3.org/2004/02/skos/core"); + + SparqlQueryType sqt = new SparqlQueryType("forbid", obj, pred, "false"); + + return new Configuration(sse, sqt, 2, true); + + } + } Modified: trunk/src/dl-learner/org/dllearner/kb/sparql/PropertyNode.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/sparql/PropertyNode.java 2007-12-02 14:19:48 UTC (rev 301) +++ trunk/src/dl-learner/org/dllearner/kb/sparql/PropertyNode.java 2007-12-02 14:34:12 UTC (rev 302) @@ -10,7 +10,7 @@ private Node a; private Node b; - private Set<String> SpecialTypes; + private Set<String> specialTypes; public PropertyNode(URI u) { super(u); @@ -23,12 +23,12 @@ this.type = "property"; this.a = a; this.b = b; - this.SpecialTypes = new HashSet<String>(); + this.specialTypes = new HashSet<String>(); } @Override public Vector<Node> expand(TypedSparqlQuery tsq, Manipulator m) { - Set<Tupel> s = tsq.query(this.URI); + Set<Tupel> s = tsq.query(this.uri); Vector<Node> Nodes = new Vector<Node>(); // Manipulation @@ -37,7 +37,7 @@ Tupel t = (Tupel) it.next(); try { if (t.a.equals(m.type)) { - SpecialTypes.add(t.b); + specialTypes.add(t.b); } } catch (Exception e) { System.out.println(t); @@ -60,10 +60,10 @@ @Override public Set<String> toNTriple() { Set<String> s = new HashSet<String>(); - s.add("<" + this.URI + "><" + "http://www.w3.org/1999/02/22-rdf-syntax-ns#type" + "><" + s.add("<" + this.uri + "><" + "http://www.w3.org/1999/02/22-rdf-syntax-ns#type" + "><" + "http://www.w3.org/2002/07/owl#ObjectProperty" + ">."); - for (String one : SpecialTypes) { - s.add("<" + this.URI + "><" + "http://www.w3.org/1999/02/22-rdf-syntax-ns#type" + "><" + for (String one : specialTypes) { + s.add("<" + this.uri + "><" + "http://www.w3.org/1999/02/22-rdf-syntax-ns#type" + "><" + one + ">."); } Modified: trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlQueryMaker.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlQueryMaker.java 2007-12-02 14:19:48 UTC (rev 301) +++ trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlQueryMaker.java 2007-12-02 14:34:12 UTC (rev 302) @@ -2,22 +2,22 @@ public class SparqlQueryMaker { - private SparqlQueryType SparqlQueryType; + private SparqlQueryType sparqlQueryType; public SparqlQueryMaker(SparqlQueryType SparqlQueryType) { - this.SparqlQueryType = SparqlQueryType; + this.sparqlQueryType = SparqlQueryType; } public String makeQueryUsingFilters(String subject) { String lineend = "\n"; String Filter = ""; - if (!this.SparqlQueryType.isLiterals()) + if (!this.sparqlQueryType.isLiterals()) Filter += "!isLiteral(?object))"; - for (String p : this.SparqlQueryType.getPredicatefilterlist()) { + for (String p : this.sparqlQueryType.getPredicatefilterlist()) { Filter += lineend + filterPredicate(p); } - for (String o : this.SparqlQueryType.getObjectfilterlist()) { + for (String o : this.sparqlQueryType.getObjectfilterlist()) { Filter += lineend + filterObject(o); } Modified: trunk/src/dl-learner/org/dllearner/kb/sparql/SpecificSparqlEndpoint.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/sparql/SpecificSparqlEndpoint.java 2007-12-02 14:19:48 UTC (rev 301) +++ trunk/src/dl-learner/org/dllearner/kb/sparql/SpecificSparqlEndpoint.java 2007-12-02 14:34:12 UTC (rev 302) @@ -9,14 +9,14 @@ String host; String hasQueryParameter; - URL URL; + URL url; public HashMap<String, String> parameters = new HashMap<String, String>(); public SpecificSparqlEndpoint(URL url,String host, HashMap<String, String> parameters) { super(); this.host=host; - this.URL = url; + this.url = url; this.hasQueryParameter = "query"; this.parameters = parameters; } @@ -47,7 +47,7 @@ } public URL getURL() { - return this.URL; + return this.url; } } Modified: trunk/src/dl-learner/org/dllearner/kb/sparql/TypedSparqlQuery.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/sparql/TypedSparqlQuery.java 2007-12-02 14:19:48 UTC (rev 301) +++ trunk/src/dl-learner/org/dllearner/kb/sparql/TypedSparqlQuery.java 2007-12-02 14:34:12 UTC (rev 302) @@ -14,22 +14,22 @@ import java.util.Set; public class TypedSparqlQuery { - private Configuration Configuration; + private Configuration configuration; // private SparqlHTTPRequest SparqlHTTPRequest; - private SparqlQueryMaker SparqlQueryMaker; + private SparqlQueryMaker sparqlQueryMaker; Cache Cache; public TypedSparqlQuery(Configuration Configuration) { - this.Configuration = Configuration; + this.configuration = Configuration; // this.SparqlHTTPRequest = new SparqlHTTPRequest(Configuration.getSparqlEndpoint()); - this.SparqlQueryMaker = new SparqlQueryMaker(Configuration.getSparqlQueryType()); + this.sparqlQueryMaker = new SparqlQueryMaker(Configuration.getSparqlQueryType()); this.Cache = new Cache("cache"); } public Set<Tupel> query(URI u) { // getQuery - String sparql = SparqlQueryMaker.makeQueryUsingFilters(u.toString()); + String sparql = sparqlQueryMaker.makeQueryUsingFilters(u.toString()); // check cache String FromCache = this.Cache.get(u.toString(), sparql); @@ -96,7 +96,7 @@ // String an Sparql-Endpoint schicken HttpURLConnection connection; - SpecificSparqlEndpoint se = Configuration.getSparqlEndpoint(); + SpecificSparqlEndpoint se = configuration.getSparqlEndpoint(); connection = (HttpURLConnection) se.getURL().openConnection(); connection.setDoOutput(true); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |