我想获取作为参数传递的Job ID,并在owl文件中检查带有id的id,然后使该Job 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查询。我是否以正确的方式实现了过滤器。任何人都可以帮我这个忙。谢谢!
答案 0 :(得分:0)
问题已解决。下面的查询帮助我获得了所需的确切输出
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)