From: <lor...@us...> - 2012-06-18 12:51:56
|
Revision: 3760 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=3760&view=rev Author: lorenz_b Date: 2012-06-18 12:51:44 +0000 (Mon, 18 Jun 2012) Log Message: ----------- Added further lexicon entries for Oxford data. Extended eval output. Added some manual mappings. Modified Paths: -------------- trunk/components-ext/src/main/resources/tbsl/lexicon/english_oxford.lex trunk/components-ext/src/main/resources/tbsl/oxford_dataproperty_mappings.txt trunk/components-ext/src/main/resources/tbsl/oxford_objectproperty_mappings.txt trunk/components-ext/src/test/java/org/dllearner/algorithm/tbsl/OxfordEvaluation.java trunk/components-ext/src/test/java/org/dllearner/algorithm/tbsl/TBSLTest.java Modified: trunk/components-ext/src/main/resources/tbsl/lexicon/english_oxford.lex =================================================================== --- trunk/components-ext/src/main/resources/tbsl/lexicon/english_oxford.lex 2012-06-18 10:50:46 UTC (rev 3759) +++ trunk/components-ext/src/main/resources/tbsl/lexicon/english_oxford.lex 2012-06-18 12:51:44 UTC (rev 3760) @@ -15,21 +15,22 @@ in walking distance from || (PP P:'in' (NP N:'walking' N:'distance' P:'from' DP[dp])) || <x,l1,<e,t>, [ l1:[ | SLOT_near(x,y) ] ], [ (l2,y,dp,<<e,t>,t>) ], [ l2=l1 ],[ SLOT_near/OBJECTPROPERTY/at_walking_distance ]> at walking distance from || (NP NP* (PP P:'at' (NP N:'walking' N:'distance' P:'from' DP[dp]))) || <x,l1,<e,t>, [ l1:[ | SLOT_near(x,y) ] ], [ (l2,y,dp,<<e,t>,t>) ], [ l2=l1 ],[ SLOT_near/OBJECTPROPERTY/at_walking_distance ]> at walking distance from || (PP P:'at' (NP N:'walking' N:'distance' P:'from' DP[dp])) || <x,l1,<e,t>, [ l1:[ | SLOT_near(x,y) ] ], [ (l2,y,dp,<<e,t>,t>) ], [ l2=l1 ],[ SLOT_near/OBJECTPROPERTY/at_walking_distance ]> - + in the area || (NP NP* (PP P:'in' (DP DET:'the' (NP N:'area' DP[dp])))) || <x,l1,<e,t>, [ l1:[ | SLOT_near(x,y) ] ], [ (l2,y,dp,<<e,t>,t>) ], [ l2=l1 ],[ SLOT_near/OBJECTPROPERTY/near]> in || (NP NP* (PP P:'in' DP[dp])) || <x,l1,<e,t>, [ l1:[ | SLOT_location(x,y) ] ], [ (l2,y,dp,<<e,t>,t>) ], [ l2=l1 ],[ SLOT_location/PROPERTY/location^city^postal_code^address^street ]> + on || (NP NP* (PP P:'on' DP[dp])) || <x,l1,<e,t>, [ l1:[ | SLOT_location(x,y) ] ], [ (l2,y,dp,<<e,t>,t>) ], [ l2=l1 ],[ SLOT_location/PROPERTY/location^city^postal_code^address^street ]> since || (NP NP* (PP P:'since' DP[dp])) || <x,l1,<e,t>, [ l1:[ | SLOT_since(x,y) ] ], [ (l2,y,dp,<<e,t>,t>) ], [ l2=l1 ],[ SLOT_since/PROPERTY/since ]> - for .+ pounds || (NP NP* (PP P:'for' (NP NUM[num] N:'pounds'))) || <x,l1,<e,t>, [ l1:[ | SLOT_price(x,y) ] ], [ (l2,y,num,e) ], [ l2=l1 ],[ SLOT_price/DATATYPEPROPERTY/price ]> - for more than .+ pounds || (NP NP* (PP P:'for' DET:'more' DET:'than' (NP NUM[num] N:'pounds'))) || <x,l1,<e,t>, [ l1:[ | SLOT_price(x,y), greater(y,z) ] ], [ (l2,z,num,e) ], [ l2=l1 ],[ SLOT_price/DATATYPEPROPERTY/price ]> - for less than .+ pounds || (NP NP* (PP P:'for' DET:'less' DET:'than' (NP NUM[num] N:'pounds'))) || <x,l1,<e,t>, [ l1:[ | SLOT_price(x,y), less(y,z) ] ], [ (l2,z,num,e) ], [ l2=l1 ],[ SLOT_price/DATATYPEPROPERTY/price ]> - for less than || (NP NP* (PP P:'for' DET:'less' DET:'than' NUM[num])) || <x,l1,<e,t>, [ l1:[ | SLOT_price(x,y), less(y,z) ] ], [ (l2,z,num,e) ], [ l2=l1 ],[ SLOT_price/DATATYPEPROPERTY/price ]> - for more than || (NP NP* (PP P:'for' DET:'more' DET:'than' NUM[num])) || <x,l1,<e,t>, [ l1:[ | SLOT_price(x,y), greater(y,z) ] ], [ (l2,z,num,e) ], [ l2=l1 ],[ SLOT_price/DATATYPEPROPERTY/price ]> - cheaper than .+ pounds || (NP NP* (ADJ ADJ:'cheaper' DET:'than' (NP NUM[num] N:'pounds'))) || <x,l1,<e,t>, [ l1:[ | SLOT_price(x,y), less(y,z) ] ], [ (l2,z,num,e) ], [ l2=l1 ],[ SLOT_price/DATATYPEPROPERTY/price ]> - cheaper than .+ pounds || (ADJ ADJ:'cheaper' DET:'than' (NP NUM[num] N:'pounds')) || <x,l1,<e,t>, [ l1:[ | SLOT_price(x,y), less(y,z) ] ], [ (l2,z,num,e) ], [ l2=l1 ],[ SLOT_price/DATATYPEPROPERTY/price ]> - below .+ pounds || (NP NP* (PP P:'below' (NP NUM[num] N:'pounds'))) || <x,l1,<e,t>, [ l1:[ | SLOT_price(x,y), less(y,z) ] ], [ (l2,z,num,e) ], [ l2=l1 ],[ SLOT_price/DATATYPEPROPERTY/price ]> - below .+ pounds || (PP P:'below' (NP NUM[num] N:'pounds')) || <x,l1,<e,t>, [ l1:[ | SLOT_price(x,y), less(y,z) ] ], [ (l2,z,num,e) ], [ l2=l1 ],[ SLOT_price/DATATYPEPROPERTY/price ]> - from .+ to .+ pounds || (NP NP* (PP P:'from' NUM[num1] P:'to' NUM[num2] N:'pounds')) || <x,l1,<e,t>, [ l1:[ | SLOT_price(x,y), greaterorequal(y,n1), lessorequal(y,n2) ] ], [ (l2,n1,num1,e),(l3,n2,num2,e) ], [ l2=l1,l3=l1 ],[ SLOT_price/DATATYPEPROPERTY/price ]> - between .+ and .+ pounds || (NP NP* (PP P:'between' NUM[num1] P:'and' NUM[num2] N:'pounds')) || <x,l1,<e,t>, [ l1:[ | SLOT_price(x,y), greaterorequal(y,n1), lessorequal(y,n2) ] ], [ (l2,n1,num1,e),(l3,n2,num2,e) ], [ l2=l1,l3=l1 ],[ SLOT_price/DATATYPEPROPERTY/price ]> + for .+ pounds || (NP NP* (PP P:'for' (NP NUM[num] N:'pounds'))) || <x,l1,<e,t>, [ l1:[ | SLOT_includes(v,x), SLOT_price(v,y) ] ], [ (l2,y,num,e) ], [ l2=l1 ],[ SLOT_price/DATATYPEPROPERTY/price, SLOT_includes/OBJECTPROPERTY/includes ]> + for more than .+ pounds || (NP NP* (PP P:'for' DET:'more' DET:'than' (NP NUM[num] N:'pounds'))) || <x,l1,<e,t>, [ l1:[ | SLOT_includes(v,x), SLOT_price(v,y), greater(y,z) ] ], [ (l2,z,num,e) ], [ l2=l1 ],[ SLOT_price/DATATYPEPROPERTY/price, SLOT_includes/OBJECTPROPERTY/includes ]> + for less than .+ pounds || (NP NP* (PP P:'for' DET:'less' DET:'than' (NP NUM[num] N:'pounds'))) || <x,l1,<e,t>, [ l1:[ | SLOT_includes(v,x), SLOT_price(v,y), less(y,z) ] ], [ (l2,z,num,e) ], [ l2=l1 ],[ SLOT_price/DATATYPEPROPERTY/price, SLOT_includes/OBJECTPROPERTY/includes ]> + for less than || (NP NP* (PP P:'for' DET:'less' DET:'than' NUM[num])) || <x,l1,<e,t>, [ l1:[v | SLOT_includes(v,x), SLOT_price(v,y), less(y,z) ] ], [ (l2,z,num,e) ], [ l2=l1 ],[ SLOT_price/DATATYPEPROPERTY/price, SLOT_includes/OBJECTPROPERTY/includes ]> + for more than || (NP NP* (PP P:'for' DET:'more' DET:'than' NUM[num])) || <x,l1,<e,t>, [ l1:[v | SLOT_includes(v,x), SLOT_price(v,y), greater(y,z) ] ], [ (l2,z,num,e) ], [ l2=l1 ],[ SLOT_price/DATATYPEPROPERTY/price, SLOT_includes/OBJECTPROPERTY/includes ]> + cheaper than .+ pounds || (NP NP* (ADJ ADJ:'cheaper' DET:'than' (NP NUM[num] N:'pounds'))) || <x,l1,<e,t>, [ l1:[ | SLOT_includes(v,x), SLOT_price(v,y), less(y,z) ] ], [ (l2,z,num,e) ], [ l2=l1 ],[ SLOT_price/DATATYPEPROPERTY/price, SLOT_includes/OBJECTPROPERTY/includes ]> + cheaper than .+ pounds || (ADJ ADJ:'cheaper' DET:'than' (NP NUM[num] N:'pounds')) || <x,l1,<e,t>, [ l1:[ | SLOT_includes(v,x), SLOT_price(v,y), less(y,z) ] ], [ (l2,z,num,e) ], [ l2=l1 ],[ SLOT_price/DATATYPEPROPERTY/price, SLOT_includes/OBJECTPROPERTY/includes ]> + below .+ pounds || (NP NP* (PP P:'below' (NP NUM[num] N:'pounds'))) || <x,l1,<e,t>, [ l1:[ | SLOT_includes(v,x), SLOT_price(v,y), less(y,z) ] ], [ (l2,z,num,e) ], [ l2=l1 ],[ SLOT_price/DATATYPEPROPERTY/price, SLOT_includes/OBJECTPROPERTY/includes ]> + below .+ pounds || (PP P:'below' (NP NUM[num] N:'pounds')) || <x,l1,<e,t>, [ l1:[ | SLOT_includes(v,x), SLOT_price(v,y), less(y,z) ] ], [ (l2,z,num,e) ], [ l2=l1 ],[ SLOT_price/DATATYPEPROPERTY/price, SLOT_includes/OBJECTPROPERTY/includes ]> + from .+ to .+ pounds || (NP NP* (PP P:'from' NUM[num1] P:'to' NUM[num2] N:'pounds')) || <x,l1,<e,t>, [ l1:[ | SLOT_includes(v,x), SLOT_price(v,y), greaterorequal(y,n1), lessorequal(y,n2) ] ], [ (l2,n1,num1,e),(l3,n2,num2,e) ], [ l2=l1,l3=l1 ],[ SLOT_price/DATATYPEPROPERTY/price, SLOT_includes/OBJECTPROPERTY/includes ]> + between .+ and .+ pounds || (NP NP* (PP P:'between' NUM[num1] P:'and' NUM[num2] N:'pounds')) || <x,l1,<e,t>, [ l1:[ | SLOT_includes(v,x), SLOT_price(v,y), greaterorequal(y,n1), lessorequal(y,n2) ] ], [ (l2,n1,num1,e),(l3,n2,num2,e) ], [ l2=l1,l3=l1 ],[ SLOT_price/DATATYPEPROPERTY/price, SLOT_includes/OBJECTPROPERTY/includes ]> with || (NP NP* (PP P:'with' DP[dp])) || <x,l1,<e,t>, [ l1:[ | empty(x,y) ] ], [ (l2,y,dp,<<e,t>,t>) ], [ l2=l1 ],[]> ;; <x,l1,<e,t>, [ l1:[ | SLOT_description(x,z), regextoken(z,y) ] ], [ (l2,y,dp,<<e,t>,t>) ], [ l2=l1 ],[ SLOT_description/DATATYPEPROPERTY/description, SLOT_arg/LITERAL/z ]> with || (PP P:'with' DP[dp]) || <x,l1,<e,t>, [ l1:[ | empty(x,y) ] ], [ (l2,y,dp,<<e,t>,t>) ], [ l2=l1 ],[]> ;; <x,l1,<e,t>, [ l1:[ | SLOT_description(x,z), regextoken(z,y) ] ], [ (l2,y,dp,<<e,t>,t>) ], [ l2=l1 ],[ SLOT_description/DATATYPEPROPERTY/description, SLOT_arg/LITERAL/z ]> Modified: trunk/components-ext/src/main/resources/tbsl/oxford_dataproperty_mappings.txt =================================================================== --- trunk/components-ext/src/main/resources/tbsl/oxford_dataproperty_mappings.txt 2012-06-18 10:50:46 UTC (rev 3759) +++ trunk/components-ext/src/main/resources/tbsl/oxford_dataproperty_mappings.txt 2012-06-18 12:51:44 UTC (rev 3760) @@ -1,3 +1,5 @@ http://www.w3.org/2006/vcard/ns#street-address|address, location, postal code http://www.w3.org/2006/vcard/ns#locality|address, location -http://purl.org/goodrelations/v1#description|description \ No newline at end of file +http://purl.org/goodrelations/v1#description|description +http://purl.org/goodrelations/v1#hasPrice|has price, price +http://diadem.cs.ox.ac.uk/ontologies/real-estate#receptions|receptions, reception room, reception rooms \ No newline at end of file Modified: trunk/components-ext/src/main/resources/tbsl/oxford_objectproperty_mappings.txt =================================================================== --- trunk/components-ext/src/main/resources/tbsl/oxford_objectproperty_mappings.txt 2012-06-18 10:50:46 UTC (rev 3759) +++ trunk/components-ext/src/main/resources/tbsl/oxford_objectproperty_mappings.txt 2012-06-18 12:51:44 UTC (rev 3760) @@ -1 +1 @@ -http://dbpedia.org/property/near|close, near \ No newline at end of file +http://dbpedia.org/property/near|close, near, at walking distance \ No newline at end of file Modified: trunk/components-ext/src/test/java/org/dllearner/algorithm/tbsl/OxfordEvaluation.java =================================================================== --- trunk/components-ext/src/test/java/org/dllearner/algorithm/tbsl/OxfordEvaluation.java 2012-06-18 10:50:46 UTC (rev 3759) +++ trunk/components-ext/src/test/java/org/dllearner/algorithm/tbsl/OxfordEvaluation.java 2012-06-18 12:51:44 UTC (rev 3760) @@ -22,11 +22,12 @@ import com.hp.hpl.jena.query.QueryParseException; import com.hp.hpl.jena.sparql.engine.http.QueryExceptionHTTP; +import com.jamonapi.Monitor; +import com.jamonapi.MonitorFactory; public class OxfordEvaluation { - private static final String QUERIES_FILE1 = OxfordEvaluation.class.getClassLoader().getResource("tbsl/oxford_eval_queries.txt").getPath(); - private static final String QUERIES_FILE2 = OxfordEvaluation.class.getClassLoader().getResource("tbsl/oxford_eval_additional_queries.txt").getPath(); + private static final String QUERIES_FILE = OxfordEvaluation.class.getClassLoader().getResource("tbsl/oxford_eval_queries.txt").getPath(); private static final String LOG_DIRECTORY = "log/oxford/"; private static final String LOG_FILE = "evaluation.txt"; @@ -52,8 +53,14 @@ int learnedQuestions = 0; Map<String, String> question2QueryMap = new HashMap<String, String>(); - BufferedReader in = new BufferedReader(new FileReader(new File(QUERIES_FILE1))); + Monitor mon = MonitorFactory.getTimeMonitor("tbsl"); + + BufferedReader in = new BufferedReader(new FileReader(new File(QUERIES_FILE))); BufferedWriter out = new BufferedWriter(new FileWriter(new File(LOG_DIRECTORY + LOG_FILE), false)); + BufferedWriter answerOut = new BufferedWriter(new FileWriter(new File(LOG_DIRECTORY + "questionsWithAnswer.txt"), false)); + BufferedWriter noAnswerOut = new BufferedWriter(new FileWriter(new File(LOG_DIRECTORY + "questionsWithNoAnswer.txt"), false)); + BufferedWriter templatesOut = new BufferedWriter(new FileWriter(new File(LOG_DIRECTORY + "questionsWithTemplate.txt"), false)); + BufferedWriter noTemplatesOut = new BufferedWriter(new FileWriter(new File(LOG_DIRECTORY + "questionsWithNoTemplate.txt"), false)); int questionCnt = 0; int errorCnt = 0; @@ -73,26 +80,49 @@ out.write("****************************************\n"); out.write("QUESTION: " + question + "\n"); learner.setQuestion(question); + mon.start(); learner.learnSPARQLQueries(); + mon.stop(); String learnedQuery = learner.getBestSPARQLQuery(); if(learnedQuery != null){ question2QueryMap.put(question, learnedQuery); learnedQuestions++; out.write("ANSWER FOUND: YES\n"); out.write(learnedQuery + "\n"); + + answerOut.write("****************************************\n"); + answerOut.write("QUESTION: " + question + "\n"); + answerOut.write("ANSWER FOUND: YES\n"); + answerOut.write(learnedQuery + "\n"); + answerOut.write("TIME NEEDED: " + mon.getLastValue() + "ms\n"); + answerOut.flush(); + } else { noQueryWithNonEmptyResultSetCnt++; out.write("ANSWER FOUND: NO\n"); out.write("REASON: NO SPARQL QUERY WITH NON-EMPTY RESULTSET FOUND\n"); out.write("SPARQL QUERY WITH HIGHEST SCORE TESTED:\n" + learner.getGeneratedQueries().first()); + noAnswerOut.write("****************************************\n"); + noAnswerOut.write("QUESTION: " + question + "\n"); + noAnswerOut.write("ANSWER FOUND: NO\n"); + noAnswerOut.write("REASON: NO SPARQL QUERY WITH NON-EMPTY RESULTSET FOUND\n"); + noAnswerOut.write("SPARQL QUERY WITH HIGHEST SCORE TESTED:\n" + learner.getGeneratedQueries().first() + "\n"); + noAnswerOut.write("TIME NEEDED: " + mon.getLastValue() + "ms\n"); + noAnswerOut.flush(); + } + templatesOut.write(question + "\n"); + templatesOut.flush(); } catch (Exception e) { + mon.stop(); e.printStackTrace(); out.write("ANSWER FOUND: NO\n"); if(e instanceof NoTemplateFoundException){ noTemplateFoundCnt++; out.write("REASON: NO TEMPLATE FOUND"); + noTemplatesOut.write(question + "\n"); + noTemplatesOut.flush(); } else { errorCnt++; out.write("REASON: ERROR OCCURED (" + e.getClass() + ")\n"); @@ -100,7 +130,9 @@ out.write("\nLast tested SPARQL query: " + learner.getCurrentlyExecutedQuery()); } } + } catch (Error e){ + mon.stop(); e.printStackTrace(); out.write("ANSWER FOUND: NO\n"); errorCnt++; @@ -111,6 +143,10 @@ } out.write("\n\n###################SUMMARY################\n"); out.write("Questions tested:\t" + questionCnt + "\n"); + out.write("Overall time:\t" + mon.getTotal() + "ms\n"); + out.write("Avg. time per question:\t" + mon.getAvg() + "ms\n"); + out.write("Longest time:\t" + mon.getMax() + "ms\n"); + out.write("Shortest time:\t" + mon.getMin() + "ms\n"); out.write("Questions with answer:\t" + learnedQuestions + "\n"); out.write("Questions with no answer (and no error):\t" + noQueryWithNonEmptyResultSetCnt + "\n"); out.write("Questions with no templates:\t" + noTemplateFoundCnt + "\n"); @@ -118,6 +154,8 @@ in.close(); out.close(); + templatesOut.close(); + noTemplatesOut.close(); } Modified: trunk/components-ext/src/test/java/org/dllearner/algorithm/tbsl/TBSLTest.java =================================================================== --- trunk/components-ext/src/test/java/org/dllearner/algorithm/tbsl/TBSLTest.java 2012-06-18 10:50:46 UTC (rev 3759) +++ trunk/components-ext/src/test/java/org/dllearner/algorithm/tbsl/TBSLTest.java 2012-06-18 12:51:44 UTC (rev 3760) @@ -118,7 +118,7 @@ String question = "Give me all houses near a school."; question = "Give me all houses with more than 3 bathrooms and more than 2 bedrooms."; question = "Give me all Victorian houses in Oxfordshire"; - question = "Give me all Edwardian house in Oxfordshire for less than 1000000."; + question = "modern houses with gas central heating"; // question = "Give me all family houses with more than 2 bathrooms and more than 4 bedrooms"; learner.setQuestion(question); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |