在 SPARQL 查询中使用多个过滤器
Using multiple filters in SPARQL query
我想获取作为参数传递的工作 ID,并使用 owl 文件中的 ID 检查该 ID,然后将该工作 ID 的工作技能与候选人的技能相匹配(候选人也包含技能)。我正在获取 url 参数并将其存储在一个变量中。
String jobID = request.getParameter("JobID");
String query =
"PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>" +
"PREFIX owl: <http://www.w3.org/2002/07/owl#> " +
"PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> " +
"PREFIX ns0: <http://www.Jobsurveillance.com/CV#> " +
"SELECT (str(?object) as ?label) " +
"(str(?object2) as ?label2) " +
"(str (?phoneNumobj) as ?label3) " +
"(str (?degreeobj) as ?label4) " +
"(str (?jobcatObj) as ?label5) " +
"(str (?candidateSkill) as ?label8) " +
"(str (?jobAdID) as ?label6) " +
"(str (?jobSkill) as ?label7) WHERE { " +
" ?person ns0:Full_Name ?object ." +
" ?person ns0:Email_Id ?object2 ." +
" ?person ns0:Phone_Number ?phoneNumobj ." +
" ?person ns0:Degree ?degreeobj ." +
" ?person ns0:Job_Category ?jobcatObj ." +
" ?person ns0:Skills ?candidateSkill ." +
" ?job ns0:JobID ?jobAdID ." +
" ?job ns0:JobSkills ?jobSkill ." +
" filter (regex(?jobAdID, \"" + jobID + "\") ." +
" filter (?jobSkill = ?candidateSkill)) ." +
"}";
当我 运行 时,出现如下错误:
com.hp.hpl.jena.query.QueryParseException: Encountered " "." ". "" at line 1,
column 756.
Was expecting one of:
"not" ...
"in" ...
<INTEGER_POSITIVE> ...
<DECIMAL_POSITIVE> ...
<DOUBLE_POSITIVE> ...
<INTEGER_NEGATIVE> ...
<DECIMAL_NEGATIVE> ...
<DOUBLE_NEGATIVE> ...
")" ...
"=" ...
"!=" ...
">" ...
"<" ...
"<=" ...
">=" ...
"||" ...
"&&" ...
"+" ...
"-" ...
"*" ...
"/" ...
我的数据集如下
<owl:NamedIndividual rdf:about="http://www.Jobsurveillance.com/CV#Candidate6">
<rdf:type>
<owl:Restriction>
<owl:onProperty rdf:resource="http://www.Jobsurveillance.com/CV#includes"/>
<owl:someValuesFrom rdf:resource="http://www.Jobsurveillance.com/CV#CV"/>
</owl:Restriction>
</rdf:type>
<ns0:Address rdf:datatype="http://www.w3.org/2001/XMLSchema#string">Colombo 15</ns0:Address>
<ns0:Company rdf:datatype="http://www.w3.org/2001/XMLSchema#string">TechOrin</ns0:Company>
<ns0:Degree rdf:datatype="http://www.w3.org/2001/XMLSchema#string">B.Sc (Hons), Information Technology</ns0:Degree>
<ns0:Email_Id rdf:datatype="http://www.w3.org/2001/XMLSchema#string">yashmitha@gmail.com</ns0:Email_Id>
<ns0:Skills rdf:datatype="http://www.w3.org/2001/XMLSchema#string">Java</ns0:Skills>
<ns0:Job_Category rdf:datatype="http://www.w3.org/2001/XMLSchema#string">Marketing</ns0:Job_Category>
<ns0:Full_Name rdf:datatype="http://www.w3.org/2001/XMLSchema#string">Yashmitha</ns0:Full_Name>
<ns0:Phone_Number rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">0723679017</ns0:Phone_Number>
</owl:NamedIndividual>
这是我的 SPARQL 查询。我是否以正确的方式实施过滤器。谁能帮我解决这个问题。谢谢!
问题已解决。下面的查询帮助我获得了我需要的准确输出
String query =
"PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>" +
"PREFIX owl: <http://www.w3.org/2002/07/owl#> " +
"PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> " +
"PREFIX ns0: <http://www.Jobsurveillance.com/CV#> " +
"SELECT (str(?object) as ?label) " +
"(str(?object2) as ?label2) " +
"(str (?phoneNumobj) as ?label3) " +
"(str (?degreeobj) as ?label4) " +
"(str (?jobcatObj) as ?label5) " +
"(str (?candidateSkill) as ?label8) " +
"(str (?jobSkill) as ?label7) WHERE { " +
" ?person ns0:Full_Name ?object ." +
" ?person ns0:Email_Id ?object2 ." +
" ?person ns0:Phone_Number ?phoneNumobj ." +
" ?person ns0:Degree ?degreeobj ." +
" ?person ns0:Job_Category ?jobcatObj ." +
" ?person ns0:Skills ?candidateSkill ." +
" ?job ns0:JobID \"" + jobID + "\"." +
" ?job ns0:JobSkills ?jobSkill ." +
" filter (?jobSkill = ?candidateSkill)" +
"}";
在上面的代码中,下面一行是
filter (?jobSkill = ?candidateSkill))
更正为
filter (?jobSkill = ?candidateSkill)
我想获取作为参数传递的工作 ID,并使用 owl 文件中的 ID 检查该 ID,然后将该工作 ID 的工作技能与候选人的技能相匹配(候选人也包含技能)。我正在获取 url 参数并将其存储在一个变量中。
String jobID = request.getParameter("JobID");
String query =
"PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>" +
"PREFIX owl: <http://www.w3.org/2002/07/owl#> " +
"PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> " +
"PREFIX ns0: <http://www.Jobsurveillance.com/CV#> " +
"SELECT (str(?object) as ?label) " +
"(str(?object2) as ?label2) " +
"(str (?phoneNumobj) as ?label3) " +
"(str (?degreeobj) as ?label4) " +
"(str (?jobcatObj) as ?label5) " +
"(str (?candidateSkill) as ?label8) " +
"(str (?jobAdID) as ?label6) " +
"(str (?jobSkill) as ?label7) WHERE { " +
" ?person ns0:Full_Name ?object ." +
" ?person ns0:Email_Id ?object2 ." +
" ?person ns0:Phone_Number ?phoneNumobj ." +
" ?person ns0:Degree ?degreeobj ." +
" ?person ns0:Job_Category ?jobcatObj ." +
" ?person ns0:Skills ?candidateSkill ." +
" ?job ns0:JobID ?jobAdID ." +
" ?job ns0:JobSkills ?jobSkill ." +
" filter (regex(?jobAdID, \"" + jobID + "\") ." +
" filter (?jobSkill = ?candidateSkill)) ." +
"}";
当我 运行 时,出现如下错误:
com.hp.hpl.jena.query.QueryParseException: Encountered " "." ". "" at line 1,
column 756.
Was expecting one of:
"not" ...
"in" ...
<INTEGER_POSITIVE> ...
<DECIMAL_POSITIVE> ...
<DOUBLE_POSITIVE> ...
<INTEGER_NEGATIVE> ...
<DECIMAL_NEGATIVE> ...
<DOUBLE_NEGATIVE> ...
")" ...
"=" ...
"!=" ...
">" ...
"<" ...
"<=" ...
">=" ...
"||" ...
"&&" ...
"+" ...
"-" ...
"*" ...
"/" ...
我的数据集如下
<owl:NamedIndividual rdf:about="http://www.Jobsurveillance.com/CV#Candidate6">
<rdf:type>
<owl:Restriction>
<owl:onProperty rdf:resource="http://www.Jobsurveillance.com/CV#includes"/>
<owl:someValuesFrom rdf:resource="http://www.Jobsurveillance.com/CV#CV"/>
</owl:Restriction>
</rdf:type>
<ns0:Address rdf:datatype="http://www.w3.org/2001/XMLSchema#string">Colombo 15</ns0:Address>
<ns0:Company rdf:datatype="http://www.w3.org/2001/XMLSchema#string">TechOrin</ns0:Company>
<ns0:Degree rdf:datatype="http://www.w3.org/2001/XMLSchema#string">B.Sc (Hons), Information Technology</ns0:Degree>
<ns0:Email_Id rdf:datatype="http://www.w3.org/2001/XMLSchema#string">yashmitha@gmail.com</ns0:Email_Id>
<ns0:Skills rdf:datatype="http://www.w3.org/2001/XMLSchema#string">Java</ns0:Skills>
<ns0:Job_Category rdf:datatype="http://www.w3.org/2001/XMLSchema#string">Marketing</ns0:Job_Category>
<ns0:Full_Name rdf:datatype="http://www.w3.org/2001/XMLSchema#string">Yashmitha</ns0:Full_Name>
<ns0:Phone_Number rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">0723679017</ns0:Phone_Number>
</owl:NamedIndividual>
这是我的 SPARQL 查询。我是否以正确的方式实施过滤器。谁能帮我解决这个问题。谢谢!
问题已解决。下面的查询帮助我获得了我需要的准确输出
String query =
"PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>" +
"PREFIX owl: <http://www.w3.org/2002/07/owl#> " +
"PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> " +
"PREFIX ns0: <http://www.Jobsurveillance.com/CV#> " +
"SELECT (str(?object) as ?label) " +
"(str(?object2) as ?label2) " +
"(str (?phoneNumobj) as ?label3) " +
"(str (?degreeobj) as ?label4) " +
"(str (?jobcatObj) as ?label5) " +
"(str (?candidateSkill) as ?label8) " +
"(str (?jobSkill) as ?label7) WHERE { " +
" ?person ns0:Full_Name ?object ." +
" ?person ns0:Email_Id ?object2 ." +
" ?person ns0:Phone_Number ?phoneNumobj ." +
" ?person ns0:Degree ?degreeobj ." +
" ?person ns0:Job_Category ?jobcatObj ." +
" ?person ns0:Skills ?candidateSkill ." +
" ?job ns0:JobID \"" + jobID + "\"." +
" ?job ns0:JobSkills ?jobSkill ." +
" filter (?jobSkill = ?candidateSkill)" +
"}";
在上面的代码中,下面一行是
filter (?jobSkill = ?candidateSkill))
更正为
filter (?jobSkill = ?candidateSkill)