given a user input (eg. "dog") I need to find all (or at least some) matching classes given the dbpedia ontology. I am newbie in semantics and every example I found is about concrete values from triplets. I mean, I found queries for retrieving things like: Allie age 15 Phillipe age 21
给定用户输入(例如“dog”)我需要在给定dbpedia本体的情况下找到所有(或至少一些)匹配类。我是语义学的新手,我发现的每个例子都是关于三元组的具体价值观。我的意思是,我找到了一些检索方法,例如:Allie 15岁的Phillipe 21岁
But what I really need is retrieving possible classes given a string. for example if I search for "article", I need a query retrieving things like " ecommerce product, magazine article, constitution article, paper", etc...
但我真正需要的是在给定字符串的情况下检索可能的类。例如,如果我搜索“文章”,我需要一个查询检索“电子商务产品,杂志文章,宪法文章,纸张”等内容...
What should I read to find examples like this? what libraries do you recommend for consuming this from javascript? no matter if there is a need of privileged code like greasemonkey or a browser extension
我应该阅读什么来找到这样的例子?你建议从javascript中使用哪些库?无论是否需要特权代码,如greasemonkey或浏览器扩展
1 个解决方案
#1
0
I can't help on any Javascript libraries but a SPARQL query to extract classes based on some given text could look like this -
我无法帮助任何Javascript库,但基于某些给定文本提取类的SPARQL查询可能如下所示 -
select distinct ?concept ?label where {
?concept a <http://www.w3.org/2002/07/owl#Class> .
?concept rdfs:label ?label .
FILTER(regex(?label, "Dog", "i")) .
FILTER(langMatches(lang(?label),"EN")) .
} LIMIT 100
This query will extract any classes with the exact name Dog. This query will need to adapted for more advanced searches but should give you a starting point.
此查询将提取具有确切名称Dog的所有类。此查询需要适应更高级的搜索,但应该为您提供一个起点。
Note: I've purposefully added FILTER(langMatches(lang(?label),"EN")) .
to search only english labels.
注意:我有意添加了FILTER(langMatches(lang(?label),“EN”))。只搜索英文标签。
#1
0
I can't help on any Javascript libraries but a SPARQL query to extract classes based on some given text could look like this -
我无法帮助任何Javascript库,但基于某些给定文本提取类的SPARQL查询可能如下所示 -
select distinct ?concept ?label where {
?concept a <http://www.w3.org/2002/07/owl#Class> .
?concept rdfs:label ?label .
FILTER(regex(?label, "Dog", "i")) .
FILTER(langMatches(lang(?label),"EN")) .
} LIMIT 100
This query will extract any classes with the exact name Dog. This query will need to adapted for more advanced searches but should give you a starting point.
此查询将提取具有确切名称Dog的所有类。此查询需要适应更高级的搜索,但应该为您提供一个起点。
Note: I've purposefully added FILTER(langMatches(lang(?label),"EN")) .
to search only english labels.
注意:我有意添加了FILTER(langMatches(lang(?label),“EN”))。只搜索英文标签。