On Aug 26, 2010, at 12:08 PM, Kingsley Idehen wrote: > On 8/26/10 11:13 AM, Timo Kouwenhoven wrote: >> Dear all, >> >> My question might be on the silly side, but then again answering it will be >> easy, so here goes: >> >> I'm using http://dbpedia.org/snorql to query dbpedia in order to get a list >> of Airports in the United States (ICAO code starting with "K") and their >> elevation and IATA code. Query included below. Works fine. >> >> SELECT ?resource ?hasValue ?isValueOf ?elevation ?icao ?iata >> WHERE { >> { <http://dbpedia.org/ontology/Elevation> ?resource ?hasValue } >> UNION >> { ?isValueOf ?resource <http://dbpedia.org/ontology/Airport> }. >> { ?isValueOf <http://dbpedia.org/ontology/elevation> ?elevation. } >> { ?isValueOf <http://dbpedia.org/ontology/icaoLocationIdentifier> ?icao. } >> OPTIONAL { ?isValueOf <http://dbpedia.org/ontology/iataLocationIdentifier> >> ?iata. } >> FILTER regex(?icao, "^K") >> } >> >> The problem is that DBPedia returns every airport twice, once with elevation >> as a decimal and once with elevation as a more exact decimal. Example below: >> >> resource hasValue isValueOf elevation icao iata >> http://www.w3.org/1999/02/22-rdf-syntax-ns#type >> http://dbpedia.org/resource/Los_Angeles_International_Airport 38 >> KLAX LAX >> http://www.w3.org/1999/02/22-rdf-syntax-ns#type >> http://dbpedia.org/resource/Los_Angeles_International_Airport 38.4048 >> KLAX LAX >> http://www.w3.org/1999/02/22-rdf-syntax-ns#type >> http://dbpedia.org/resource/Washington_Dulles_International_Airport 95 >> KIAD IAD >> http://www.w3.org/1999/02/22-rdf-syntax-ns#type >> http://dbpedia.org/resource/Washington_Dulles_International_Airport 95.4024 >> KIAD IAD >> http://www.w3.org/1999/02/22-rdf-syntax-ns#type >> http://dbpedia.org/resource/Van_Nuys_Airport 244.4 KVNY VNY >> http://www.w3.org/1999/02/22-rdf-syntax-ns#type >> http://dbpedia.org/resource/Van_Nuys_Airport 244.4496 KVNY VNY >> The question is how do I get a list with the exact decimals only? >> >> FILTER with regex on ?elevation in the decimal point doesn't work... >> >> Any ideas? >> >> Thanks in advance, >> >> Timo Kouwenhoven >> http://www.skybrary.aero (aviation safety knowledge) >> > > Try: > > SELECT distinct ?resource ?hasValue ?isValueOf bif:round(?elevation) ?icao > ?iata > WHERE { > { <http://dbpedia.org/ontology/Elevation> ?resource ?hasValue } > UNION > { ?isValueOf ?resource <http://dbpedia.org/ontology/Airport> }. > { ?isValueOf <http://dbpedia.org/ontology/elevation> ?elevation. } > { ?isValueOf <http://dbpedia.org/ontology/icaoLocationIdentifier> ?icao. } > OPTIONAL { ?isValueOf <http://dbpedia.org/ontology/iataLocationIdentifier> > ?iata. } > FILTER regex(?icao, "^K") > }
I think you misunderstood Timo's goal, Kingsley. I think the goal is to get the most-precise of the available values. The big challenge I see there is -- the less-precise values aren't all integers. See this query's result -- http://bit.ly/cfqUAo SELECT DISTINCT ?resource ?hasValue ?isValueOf bif:min(?elevation) as ?minelev bif:max(?elevation) as ?maxelev ?icao ?iata WHERE { { <http://dbpedia.org/ontology/Elevation> ?resource ?hasValue } UNION { ?isValueOf ?resource <http://dbpedia.org/ontology/Airport> } { ?isValueOf <http://dbpedia.org/ontology/elevation> ?elevation } { ?isValueOf <http://dbpedia.org/ontology/icaoLocationIdentifier> ?icao } OPTIONAL { ?isValueOf <http://dbpedia.org/ontology/iataLocationIdentifier> ?iata } FILTER regex(?icao, "^K") } I'm sure there's a clever way to select only the "longer" value from ?minelev and ?maxelev (or perhaps the "longest" value of ?elevation), but the right clause isn't coming to mind. (It might require a new function/stored-procedure....) Perhaps the suggestion will be enough for someone else to finish the exercise. :-) Be seeing you, Ted -- A: Yes. http://www.guckes.net/faq/attribution.html | Q: Are you sure? | | A: Because it reverses the logical flow of conversation. | | | Q: Why is top posting frowned upon? Ted Thibodeau, Jr. // voice +1-781-273-0900 x32 Evangelism & Support // mailto:[email protected] // http://twitter.com/TallTed OpenLink Software, Inc. // http://www.openlinksw.com/ 10 Burlington Mall Road, Suite 265, Burlington MA 01803 http://www.openlinksw.com/weblogs/uda/ OpenLink Blogs http://www.openlinksw.com/weblogs/virtuoso/ http://www.openlinksw.com/blog/~kidehen/ Universal Data Access and Virtual Database Technology Providers ------------------------------------------------------------------------------ Sell apps to millions through the Intel(R) Atom(Tm) Developer Program Be part of this innovative community and reach millions of netbook users worldwide. Take advantage of special opportunities to increase revenue and speed time-to-market. Join now, and jumpstart your future. http://p.sf.net/sfu/intel-atom-d2d _______________________________________________ Dbpedia-discussion mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/dbpedia-discussion
