From: <ku...@us...> - 2008-08-15 17:55:47
|
Revision: 1094 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1094&view=rev Author: kurzum Date: 2008-08-15 17:55:39 +0000 (Fri, 15 Aug 2008) Log Message: ----------- added support fo datatypes, some options from the *.conf files might not work. everything else should be fine Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/kb/extraction/ClassNode.java trunk/src/dl-learner/org/dllearner/kb/extraction/InstanceNode.java trunk/src/dl-learner/org/dllearner/kb/extraction/LiteralNode.java trunk/src/dl-learner/org/dllearner/kb/extraction/Node.java trunk/src/dl-learner/org/dllearner/kb/manipulator/DBpediaNavigatorOtherRule.java trunk/src/dl-learner/org/dllearner/test/TestOneQueryForMusicRecommender.java trunk/src/dl-learner/org/dllearner/test/TripleTypeTest.java trunk/src/dl-learner/org/dllearner/utilities/owl/OWLVocabulary.java Added Paths: ----------- trunk/src/dl-learner/org/dllearner/kb/extraction/DatatypePropertyNode.java trunk/src/dl-learner/org/dllearner/kb/extraction/ObjectPropertyNode.java Removed Paths: ------------- trunk/src/dl-learner/org/dllearner/kb/extraction/PropertyNode.java Modified: trunk/src/dl-learner/org/dllearner/kb/extraction/ClassNode.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/extraction/ClassNode.java 2008-08-15 15:39:55 UTC (rev 1093) +++ trunk/src/dl-learner/org/dllearner/kb/extraction/ClassNode.java 2008-08-15 17:55:39 UTC (rev 1094) @@ -24,6 +24,7 @@ import java.util.SortedSet; import java.util.TreeSet; +import org.apache.log4j.Logger; import org.dllearner.kb.aquisitors.TupelAquisitor; import org.dllearner.kb.manipulator.Manipulator; import org.dllearner.utilities.datastructures.RDFNodeTuple; @@ -35,7 +36,13 @@ * @author Sebastian Hellmann */ public class ClassNode extends Node { - SortedSet<PropertyNode> properties = new TreeSet<PropertyNode>(); + + @SuppressWarnings("unused") + private static Logger logger = Logger + .getLogger(ClassNode.class); + + SortedSet<ObjectPropertyNode> classProperties = new TreeSet<ObjectPropertyNode>(); + SortedSet<DatatypePropertyNode> datatypeProperties = new TreeSet<DatatypePropertyNode>(); public ClassNode(String uri) { super(uri); @@ -50,54 +57,50 @@ newTuples = manipulator.manipulate(this, newTuples); List<Node> newNodes = new ArrayList<Node>(); + Node tmp; for (RDFNodeTuple tuple : newTuples) { - try { - String property = tuple.a.toString(); - // substitute rdf:type with owl:subclassof - if (property.equals(OWLVocabulary.RDF_TYPE) || property.equals(OWLVocabulary.RDFS_SUBCLASS_OF)) { - ClassNode tmp = new ClassNode(tuple.b.toString()); - properties.add(new PropertyNode( OWLVocabulary.RDFS_SUBCLASS_OF, this, tmp)); - newNodes.add(tmp); - } else { - // further expansion stops here - // Nodes.add(tmp); is missing on purpose - ClassNode tmp = new ClassNode(tuple.b.toString()); - properties.add(new PropertyNode(tuple.a.toString(), this, tmp)); - // System.out.println(m.blankNodeIdentifier); - // System.out.println("XXXXX"+t.b); - - // if o is a blank node expand further - // TODO this needs a lot more work - - // Nodes.add(tmp); - } - - - - - } catch (Exception e) { - System.out.println("ClassNode"); - e.printStackTrace(); - } + if((tmp = processTuple(tuple))!= null) { + newNodes.add(tmp); + } } return newNodes; } + + public Node processTuple( RDFNodeTuple tuple) { + try { + String property = tuple.a.toString(); + if(tuple.b.isLiteral()) { + datatypeProperties.add(new DatatypePropertyNode(tuple.a.toString(), this, new LiteralNode(tuple.b) )); + return null; + }else if(tuple.b.isAnon()){ + logger.warn("blanknodes not supported as of now"+ this +"in tuple" + tuple); + return null; + // substitute rdf:type with owl:subclassof + }else if (property.equals(OWLVocabulary.RDF_TYPE) || property.equals(OWLVocabulary.RDFS_SUBCLASS_OF)) { + ClassNode tmp = new ClassNode(tuple.b.toString()); + classProperties.add(new ObjectPropertyNode( OWLVocabulary.RDFS_SUBCLASS_OF, this, tmp)); + return tmp; + } else { + // further expansion stops here + ClassNode tmp = new ClassNode(tuple.b.toString()); + classProperties.add(new ObjectPropertyNode(tuple.a.toString(), this, tmp)); + // return tmp; is missing on purpose + } + } catch (Exception e) { + logger.warn("Problem with: " + this + " in tuple " + tuple); + e.printStackTrace(); + + } + return null; + } // gets the types for properties recursively @Override public void expandProperties(TupelAquisitor tupelAquisitor, Manipulator manipulator) { } - @Override - public List<Node> getAllNodesAsList(List<Node> l){ - l.add(this); - for (PropertyNode props : properties) { - l.addAll(props.getB().getAllNodesAsList(l)); - } - - return l; - } + /* * (non-Javadoc) * @@ -105,16 +108,20 @@ */ @Override public SortedSet<String> toNTriple() { - SortedSet<String> s = new TreeSet<String>(); - s.add("<" + this.uri + "><" + OWLVocabulary.RDF_TYPE + "><" + OWLVocabulary.OWL_CLASS + ">."); + SortedSet<String> returnSet = new TreeSet<String>(); + returnSet.add("<" + this.uri + "><" + OWLVocabulary.RDF_TYPE + "><" + OWLVocabulary.OWL_CLASS + ">."); - for (PropertyNode one : properties) { - s.add("<" + this.uri + "><" + one.getURI() + "><" + for (ObjectPropertyNode one : classProperties) { + returnSet.add("<" + this.uri + "><" + one.getURI() + "><" + one.getB().getURI() + ">."); - s.addAll(one.getB().toNTriple()); + returnSet.addAll(one.getB().toNTriple()); } + for (DatatypePropertyNode one : datatypeProperties) { + returnSet.add("<" + uri + "><" + one.getURI() + "> " + one.getNTripleFormOfB() + + " ."); + } - return s; + return returnSet; } @Override Added: trunk/src/dl-learner/org/dllearner/kb/extraction/DatatypePropertyNode.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/extraction/DatatypePropertyNode.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/kb/extraction/DatatypePropertyNode.java 2008-08-15 17:55:39 UTC (rev 1094) @@ -0,0 +1,101 @@ +/** + * 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.extraction; + +import java.util.List; +import java.util.SortedSet; +import java.util.TreeSet; + +import org.dllearner.kb.aquisitors.TupelAquisitor; +import org.dllearner.kb.manipulator.Manipulator; +import org.dllearner.utilities.owl.OWLVocabulary; + +/** + * Property node, has connection to a and b part + * + * @author Sebastian Hellmann + * + */ + +public class DatatypePropertyNode extends Node { + + // the a and b part of a property + private Node a; + private LiteralNode b; + + + public DatatypePropertyNode(String uri, Node a, LiteralNode b) { + super(uri); + // this.type = "property"; + this.a = a; + this.b = b; + } + + // Property Nodes are normally not expanded, + // this function is never called + @Override + public List<Node> expand(TupelAquisitor tupelAquisitor, Manipulator manipulator) { + return null; + } + + // gets the types for properties recursively + @Override + public void expandProperties(TupelAquisitor tupelAquisitor, Manipulator manipulator) { + } + + + + public Node getA() { + return a; + } + + public Node getB() { + return b; + } + + public String getNTripleFormOfB() { + return b.getNTripleForm(); + } + + @Override + public SortedSet<String> toNTriple() { + SortedSet<String> s = new TreeSet<String>(); + s.add("<" + uri + "><" + OWLVocabulary.RDF_TYPE + "><" + + OWLVocabulary.OWL_DATATYPPROPERTY + ">."); + + return s; + } + + //TODO check + @Override + public boolean equals(Node n) { + if (this.uri.equals(n.uri)) { + return true; + }else { + return false; + } + } + + @Override + public int compareTo(Node n) { + return super.compareTo(n); + } + +} Modified: trunk/src/dl-learner/org/dllearner/kb/extraction/InstanceNode.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/extraction/InstanceNode.java 2008-08-15 15:39:55 UTC (rev 1093) +++ trunk/src/dl-learner/org/dllearner/kb/extraction/InstanceNode.java 2008-08-15 17:55:39 UTC (rev 1094) @@ -38,13 +38,16 @@ */ public class InstanceNode extends Node { + @SuppressWarnings("unused") private static Logger logger = Logger .getLogger(InstanceNode.class); private SortedSet<ClassNode> classes = new TreeSet<ClassNode>(); //SortedSet<StringTuple> datatypes = new TreeSet<StringTuple>(); - private SortedSet<PropertyNode> properties = new TreeSet<PropertyNode>(); + private SortedSet<ObjectPropertyNode> objectProperties = new TreeSet<ObjectPropertyNode>(); + private SortedSet<DatatypePropertyNode> datatypeProperties = new TreeSet<DatatypePropertyNode>(); + public InstanceNode(String uri) { super(uri); @@ -60,54 +63,48 @@ List<Node> newNodes = new ArrayList<Node>(); + Node tmp; for (RDFNodeTuple tuple : newTuples) { - //QUALITY: needs proper handling of ressource, could be done one step lower in the onion - if(!tuple.b.toString().startsWith("http:"))continue; -// basically : if p is rdf:type then o is a class - // else it is an instance - try { - if (tuple.a.toString().equals(OWLVocabulary.RDF_TYPE)) { - ClassNode tmp = new ClassNode(tuple.b.toString()); - classes.add(tmp); - newNodes.add(tmp); - } else { - InstanceNode tmp = new InstanceNode(tuple.b.toString()); - properties.add(new PropertyNode(tuple.a.toString(), this, tmp)); - newNodes.add(tmp); - - } - } catch (Exception e) { - System.out.println("Problem with: " + tuple); - e.printStackTrace(); - } - - - + if((tmp = processTuple(tuple))!= null) { + newNodes.add(tmp); + } }//endfor expanded = true; return newNodes; - } - @Override - public List<Node> getAllNodesAsList(List<Node> l){ - l.add(this); - logger.trace(this+"\nclasses: "+classes.size()+"\nrelInstances: "+properties.size()); - for (ClassNode clazz : classes) { - l.addAll(clazz.getAllNodesAsList(l)); + public Node processTuple( RDFNodeTuple tuple) { + try { + if(tuple.b.isLiteral()) { + datatypeProperties.add(new DatatypePropertyNode(tuple.a.toString(), this, new LiteralNode(tuple.b) )); + return null; + }else if(tuple.b.isAnon()){ + logger.warn("blanknodes not supported as of now"+ this +"in tuple" + tuple); + return null; + + // basically : if p is rdf:type then o is a class + // else it is an instance + }else if (tuple.a.toString().equals(OWLVocabulary.RDF_TYPE)) { + ClassNode tmp = new ClassNode(tuple.b.toString()); + classes.add(tmp); + return tmp; + } else { + InstanceNode tmp = new InstanceNode(tuple.b.toString()); + objectProperties.add(new ObjectPropertyNode(tuple.a.toString(), this, tmp)); + return tmp; + } + } catch (Exception e) { + System.out.println("Problem with: " + tuple); + e.printStackTrace(); + return null; } - for (PropertyNode props : properties) { - l.addAll(props.getB().getAllNodesAsList(l)); - } - - return l; } - + // gets the types for properties recursively @Override public void expandProperties(TupelAquisitor tupelAquisitor, Manipulator manipulator) { - for (PropertyNode one : properties) { + for (ObjectPropertyNode one : objectProperties) { one.expandProperties(tupelAquisitor, manipulator); } @@ -121,12 +118,17 @@ returnSet.add("<" + uri + "><" + OWLVocabulary.RDF_TYPE + "><" + one.getURI() + ">."); returnSet.addAll(one.toNTriple()); } - for (PropertyNode one : properties) { + for (ObjectPropertyNode one : objectProperties) { returnSet.add("<" + uri + "><" + one.getURI() + "><" + one.getB().getURI() + ">."); returnSet.addAll(one.toNTriple()); returnSet.addAll(one.getB().toNTriple()); } + + for (DatatypePropertyNode one : datatypeProperties) { + returnSet.add("<" + uri + "><" + one.getURI() + "> " + one.getNTripleFormOfB() + + " ."); + } return returnSet; } Modified: trunk/src/dl-learner/org/dllearner/kb/extraction/LiteralNode.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/extraction/LiteralNode.java 2008-08-15 15:39:55 UTC (rev 1093) +++ trunk/src/dl-learner/org/dllearner/kb/extraction/LiteralNode.java 2008-08-15 17:55:39 UTC (rev 1094) @@ -28,6 +28,9 @@ import org.dllearner.kb.aquisitors.TupelAquisitor; import org.dllearner.kb.manipulator.Manipulator; +import com.hp.hpl.jena.rdf.model.Literal; +import com.hp.hpl.jena.rdf.model.RDFNode; + /** * A node in the graph that is a Literal. * @@ -36,6 +39,8 @@ */ public class LiteralNode extends Node { + private Literal l; + @SuppressWarnings("unused") private static Logger logger = Logger .getLogger(LiteralNode.class); @@ -46,6 +51,11 @@ // this.type = "instance"; } + + public LiteralNode(RDFNode node) { + super(node.toString()); + l = (Literal) node; + } // expands all directly connected nodes @Override @@ -53,11 +63,7 @@ return new ArrayList<Node>(); } - @Override - public List<Node> getAllNodesAsList(List<Node> l){ - l.add(this); - return l; - } + // gets the types for properties recursively @Override @@ -74,5 +80,21 @@ return super.compareTo(n); // } + + + public String getNTripleForm() { + String quote = "\\\""; + quote = """; + String retVal = l.getLexicalForm(); + retVal = retVal.replaceAll("\n", "\\n"); + retVal = retVal.replaceAll("\"", quote); + retVal = "\""+retVal+"\""; + if(l.getDatatypeURI()!=null) { + return retVal +"^^<"+l.getDatatypeURI()+">"; + }else { + return retVal+((l.getLanguage().length()==0)?"":"@"+l.getLanguage()); + } + + } } Modified: trunk/src/dl-learner/org/dllearner/kb/extraction/Node.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/extraction/Node.java 2008-08-15 15:39:55 UTC (rev 1093) +++ trunk/src/dl-learner/org/dllearner/kb/extraction/Node.java 2008-08-15 17:55:39 UTC (rev 1094) @@ -83,7 +83,7 @@ return uri; } - public abstract List<Node> getAllNodesAsList(List<Node> l); + public boolean equals(Node n) { if (this.uri.equals(n.uri)) Copied: trunk/src/dl-learner/org/dllearner/kb/extraction/ObjectPropertyNode.java (from rev 1093, trunk/src/dl-learner/org/dllearner/kb/extraction/PropertyNode.java) =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/extraction/ObjectPropertyNode.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/kb/extraction/ObjectPropertyNode.java 2008-08-15 17:55:39 UTC (rev 1094) @@ -0,0 +1,118 @@ +/** + * 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.extraction; + +import java.util.List; +import java.util.SortedSet; +import java.util.TreeSet; + +import org.dllearner.kb.aquisitors.TupelAquisitor; +import org.dllearner.kb.manipulator.Manipulator; +import org.dllearner.utilities.datastructures.RDFNodeTuple; +import org.dllearner.utilities.owl.OWLVocabulary; + +/** + * Property node, has connection to a and b part + * + * @author Sebastian Hellmann + * + */ + +public class ObjectPropertyNode extends Node { + + // the a and b part of a property + private Node a; + private Node b; + // specialtypes like owl:symmetricproperty + private SortedSet<String> specialTypes; + + public ObjectPropertyNode(String uri, Node a, Node b) { + super(uri); + // this.type = "property"; + this.a = a; + this.b = b; + this.specialTypes = new TreeSet<String>(); + } + + // Property Nodes are normally not expanded, + // this function is never called + @Override + public List<Node> expand(TupelAquisitor tupelAquisitor, Manipulator manipulator) { + return null; + } + + // gets the types for properties recursively + @Override + public void expandProperties(TupelAquisitor tupelAquisitor, Manipulator manipulator) { + b.expandProperties(tupelAquisitor, manipulator); + SortedSet<RDFNodeTuple> newTypes = tupelAquisitor.getTupelForResource(uri); + for (RDFNodeTuple tuple : newTypes) { + try { + if (tuple.a.equals(OWLVocabulary.RDF_TYPE)) { + specialTypes.add(tuple.b.toString()); + } + } catch (Exception e) { + System.out.println(tuple); + e.printStackTrace(); + } + } + + } + + + + + public Node getA() { + return a; + } + + public Node getB() { + return b; + } + + @Override + public SortedSet<String> toNTriple() { + SortedSet<String> s = new TreeSet<String>(); + s.add("<" + uri + "><" + OWLVocabulary.RDF_TYPE + "><" + + OWLVocabulary.OWL_OBJECTPROPERTY + ">."); + for (String one : specialTypes) { + s.add("<" + uri + "><" + OWLVocabulary.RDF_TYPE + "><" + + one + ">."); + } + + return s; + } + + //TODO check + @Override + public boolean equals(Node n) { + if (this.uri.equals(n.uri)) { + return true; + }else { + return false; + } + } + + @Override + public int compareTo(Node n) { + return super.compareTo(n); + } + +} Property changes on: trunk/src/dl-learner/org/dllearner/kb/extraction/ObjectPropertyNode.java ___________________________________________________________________ Added: svn:mergeinfo + Deleted: trunk/src/dl-learner/org/dllearner/kb/extraction/PropertyNode.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/extraction/PropertyNode.java 2008-08-15 15:39:55 UTC (rev 1093) +++ trunk/src/dl-learner/org/dllearner/kb/extraction/PropertyNode.java 2008-08-15 17:55:39 UTC (rev 1094) @@ -1,121 +0,0 @@ -/** - * 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.extraction; - -import java.util.List; -import java.util.SortedSet; -import java.util.TreeSet; - -import org.dllearner.kb.aquisitors.TupelAquisitor; -import org.dllearner.kb.manipulator.Manipulator; -import org.dllearner.utilities.datastructures.RDFNodeTuple; -import org.dllearner.utilities.owl.OWLVocabulary; - -/** - * Property node, has connection to a and b part - * - * @author Sebastian Hellmann - * - */ - -public class PropertyNode extends Node { - - // the a and b part of a property - private Node a; - private Node b; - // specialtypes like owl:symmetricproperty - private SortedSet<String> specialTypes; - - public PropertyNode(String uri, Node a, Node b) { - super(uri); - // this.type = "property"; - this.a = a; - this.b = b; - this.specialTypes = new TreeSet<String>(); - } - - // Property Nodes are normally not expanded, - // this function is never called - @Override - public List<Node> expand(TupelAquisitor tupelAquisitor, Manipulator manipulator) { - return null; - } - - // gets the types for properties recursively - @Override - public void expandProperties(TupelAquisitor tupelAquisitor, Manipulator manipulator) { - b.expandProperties(tupelAquisitor, manipulator); - SortedSet<RDFNodeTuple> newTypes = tupelAquisitor.getTupelForResource(uri); - for (RDFNodeTuple tuple : newTypes) { - try { - if (tuple.a.equals(OWLVocabulary.RDF_TYPE)) { - specialTypes.add(tuple.b.toString()); - } - } catch (Exception e) { - System.out.println(tuple); - e.printStackTrace(); - } - } - - } - - @Override - public List<Node> getAllNodesAsList(List<Node> l){ - throw new RuntimeException("PropertyNode.getAllNodesAsList() should never be called"); - } - - - public Node getA() { - return a; - } - - public Node getB() { - return b; - } - - @Override - public SortedSet<String> toNTriple() { - SortedSet<String> s = new TreeSet<String>(); - s.add("<" + uri + "><" + OWLVocabulary.RDF_TYPE + "><" - + OWLVocabulary.OWL_OBJECTPROPERTY + ">."); - for (String one : specialTypes) { - s.add("<" + uri + "><" + OWLVocabulary.RDF_TYPE + "><" - + one + ">."); - } - - return s; - } - - //TODO check - @Override - public boolean equals(Node n) { - if (this.uri.equals(n.uri)) { - return true; - }else { - return false; - } - } - - @Override - public int compareTo(Node n) { - return super.compareTo(n); - } - -} Modified: trunk/src/dl-learner/org/dllearner/kb/manipulator/DBpediaNavigatorOtherRule.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/manipulator/DBpediaNavigatorOtherRule.java 2008-08-15 15:39:55 UTC (rev 1093) +++ trunk/src/dl-learner/org/dllearner/kb/manipulator/DBpediaNavigatorOtherRule.java 2008-08-15 17:55:39 UTC (rev 1094) @@ -21,11 +21,11 @@ import java.util.SortedSet; - import org.dllearner.kb.extraction.Node; import org.dllearner.utilities.datastructures.RDFNodeTuple; import org.dllearner.utilities.owl.OWLVocabulary; +import com.hp.hpl.jena.rdf.model.Literal; import com.hp.hpl.jena.rdf.model.RDFNode; import com.hp.hpl.jena.rdf.model.impl.ResourceImpl; @@ -53,14 +53,16 @@ //TODO this doesn't work, because it is unclear what toString() method returns - if (tuple.a.toString().equals("http://www.w3.org/2003/01/geo/wgs84_pos#lat")){ - lat=Float.parseFloat(tuple.b.toString().substring(0,tuple.b.toString().indexOf("^^"))); + if (tuple.a.toString().equals("http://www.w3.org/2003/01/geo/wgs84_pos#lat") && tuple.b.isLiteral()){ + lat = ((Literal) tuple.b).getFloat(); + //lat=Float.parseFloat(tuple.b.toString().substring(0,tuple.b.toString().indexOf("^^"))); } - if (tuple.a.toString().equals("http://www.w3.org/2003/01/geo/wgs84_pos#long")) { - lng=Float.parseFloat(tuple.b.toString().substring(0,tuple.b.toString().indexOf("^^"))); + if (tuple.a.toString().equals("http://www.w3.org/2003/01/geo/wgs84_pos#long") && tuple.b.isLiteral()) { + lng = ((Literal) tuple.b).getFloat(); + //lng=Float.parseFloat(tuple.b.toString().substring(0,tuple.b.toString().indexOf("^^"))); } - } + }//end for if (clazz.toString().equals("http://dbpedia.org/class/yago/City108524735")){ String newType = getTypeToCoordinates(lat, lng); tuples.add(new RDFNodeTuple(new ResourceImpl(OWLVocabulary.RDF_TYPE),new ResourceImpl(newType))); Modified: trunk/src/dl-learner/org/dllearner/test/TestOneQueryForMusicRecommender.java =================================================================== --- trunk/src/dl-learner/org/dllearner/test/TestOneQueryForMusicRecommender.java 2008-08-15 15:39:55 UTC (rev 1093) +++ trunk/src/dl-learner/org/dllearner/test/TestOneQueryForMusicRecommender.java 2008-08-15 17:55:39 UTC (rev 1094) @@ -53,6 +53,7 @@ ResultSet rs = ResultSetFactory.fromXML(xml); + @SuppressWarnings("unchecked") List<ResultBinding> l = ResultSetFormatter.toList(rs); for (ResultBinding binding : l) { Modified: trunk/src/dl-learner/org/dllearner/test/TripleTypeTest.java =================================================================== --- trunk/src/dl-learner/org/dllearner/test/TripleTypeTest.java 2008-08-15 15:39:55 UTC (rev 1093) +++ trunk/src/dl-learner/org/dllearner/test/TripleTypeTest.java 2008-08-15 17:55:39 UTC (rev 1094) @@ -23,6 +23,7 @@ SPARQLTasks st = new SPARQLTasks (Cache.getDefaultCache(), SparqlEndpoint.getEndpointDBpedia()); ResultSetRewindable rsw = st.queryAsResultSet(sparqlQueryString); + @SuppressWarnings("unchecked") List<ResultBinding> l = ResultSetFormatter.toList(rsw); for (ResultBinding binding : l) { Modified: trunk/src/dl-learner/org/dllearner/utilities/owl/OWLVocabulary.java =================================================================== --- trunk/src/dl-learner/org/dllearner/utilities/owl/OWLVocabulary.java 2008-08-15 15:39:55 UTC (rev 1093) +++ trunk/src/dl-learner/org/dllearner/utilities/owl/OWLVocabulary.java 2008-08-15 17:55:39 UTC (rev 1094) @@ -28,6 +28,7 @@ public static final String OWL_SAME_AS = "http://www.w3.org/2002/07/owl#sameAs"; public static final String OWL_OBJECTPROPERTY = "http://www.w3.org/2002/07/owl#ObjectProperty"; + public static final String OWL_DATATYPPROPERTY = "http://www.w3.org/2002/07/owl#DataTypeProperty"; public static final String OWL_CLASS = "http://www.w3.org/2002/07/owl#Class"; public static final String OWL_THING = "http://www.w3.org/2002/07/owl#Thing"; //OWL2 Namespace: http://www.w3.org/2006/12/owl2# This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |