[英]DBPedia: SPARQL query on field starting with literal
I am trying to get the respective DBPedia entry for a list of companies. 我正在尝试获取公司列表的相应DBPedia条目。 I can't figure out how to do approximate matches.
我不知道如何进行近似匹配。 Example: "Audi" is called "Audi AG" in DBPedia and "Novartis" is called "Novartis International AG" (foaf:name).
示例:在DBPedia中,“ Audi”被称为“ Audi AG”,而“ Novartis”被称为“ Novartis International AG”(foaf:name)。 How do I search for entries with rdf:type = dbo:Company and name closest to whatever I provide?
如何搜索rdf:type = dbo:Company且名称最接近我提供的名称的条目?
I'm using SPARQL as the query language. 我正在使用SPARQL作为查询语言。 (But I'm open to change if there is an advantage.)
(但如果有优势,我愿意改变。)
select ?company
where {
?company foaf:name "Novartis"@en.
?company a dbo:Company.
}
LIMIT 100
I get no hit but http://dbpedia.org/page/Novartis should be found. 我没有获得成功,但应该找到http://dbpedia.org/page/Novartis 。 Matching the beginning of the name might be good enough to get this.
匹配名称的开头可能就足够了。
For DBpedia, the best option might be to use the bif:contains
full-text search pseudo property: 对于DBpedia,最好的选择可能是使用
bif:contains
全文搜索伪属性:
SELECT ?company {
?company a dbo:Company.
?company foaf:name ?name.
?name bif:contains "Novartis"@en.
}
This feature is specific to the Virtuoso database that powers the DBpedia SPARQL endpoint. 此功能特定于为DBpedia SPARQL端点提供支持的Virtuoso数据库。
If you want to stick to standard SPARQL , to match at the beginning of the name only: 如果要坚持使用标准SPARQL ,以仅在名称的开头进行匹配 :
SELECT ?company {
?company a dbo:Company.
?company foaf:name ?name.
FILTER strStarts(?name, "Novartis")
}
Unlike the full-text feature, this version cannot make use of a text index, so it is slower. 与全文功能不同,此版本无法使用文本索引,因此速度较慢。
If you want a more flexible match : 如果您想要更灵活的匹配 :
SELECT ?company {
?company a dbo:Company.
?company foaf:name ?name.
FILTER contains(lCase(?name), lCase("Novartis"))
}
This will find a case-insensitive match anywhere in the name. 这将在名称中的任何位置找到不区分大小写的匹配项。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.