From: <chr...@us...> - 2011-10-26 09:43:38
|
Revision: 3323 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=3323&view=rev Author: christinaunger Date: 2011-10-26 09:43:32 +0000 (Wed, 26 Oct 2011) Log Message: ----------- [tbsl] empty words (e.g. 'has/have','with') are ignored and instead the property is provided by the argument noun. plus small bug fix. Modified Paths: -------------- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/converter/DRS2SPARQL_Converter.java trunk/components-ext/src/main/resources/tbsl/evaluation/dbpedia-train-tagged(ideal).xml trunk/components-ext/src/main/resources/tbsl/lexicon/english.lex Modified: trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/converter/DRS2SPARQL_Converter.java =================================================================== --- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/converter/DRS2SPARQL_Converter.java 2011-10-26 09:03:57 UTC (rev 3322) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/converter/DRS2SPARQL_Converter.java 2011-10-26 09:43:32 UTC (rev 3323) @@ -24,6 +24,7 @@ import org.dllearner.algorithm.tbsl.sparql.SPARQL_Term; import org.dllearner.algorithm.tbsl.sparql.SPARQL_Triple; import org.dllearner.algorithm.tbsl.sparql.Slot; +import org.dllearner.algorithm.tbsl.sparql.SlotType; import org.dllearner.algorithm.tbsl.sparql.Template; @@ -91,7 +92,10 @@ private Query convert(DRS drs, Query query, boolean negate) { +// System.out.println("--- DRS (before): " + drs); // DEBUG redundantEqualRenaming(drs); + restructureEmpty(drs); +// System.out.println("--- DRS (after) : " + drs); // DEBUG for (DiscourseReferent referent : drs.getDRs()) { if (referent.isMarked()) { @@ -139,7 +143,7 @@ return query; } - private Query convertCondition(DRS_Condition condition, Query query) { + private Query convertCondition(DRS_Condition condition, Query query) { if (condition.isComplexCondition()) { if (!isSilent()) { System.out.print("|complex:" + condition.toString()); @@ -272,7 +276,7 @@ SPARQL_PairType.LTEQ))); return query; } else if (predicate.equals("maximum")) { - query.addSelTerm(new SPARQL_Term(simple.getArguments().get(0).getValue(),false)); +// query.addSelTerm(new SPARQL_Term(simple.getArguments().get(0).getValue(),false)); query.addOrderBy(new SPARQL_Term(simple.getArguments().get(0).getValue(), SPARQL_OrderBy.DESC)); query.setLimit(1); return query; @@ -373,7 +377,42 @@ drs.removeCondition(c); } } + + private void restructureEmpty(DRS drs) { + + Set<Simple_DRS_Condition> emptyConditions = new HashSet<Simple_DRS_Condition>(); + for (Simple_DRS_Condition c : drs.getAllSimpleConditions()) { + if(c.getPredicate().equals("empty")) { + emptyConditions.add(c); + } + } + + for (Simple_DRS_Condition c : emptyConditions) { + String nounToExpand = c.getArguments().get(1).getValue(); + for (Simple_DRS_Condition sc : drs.getAllSimpleConditions()) { + if (sc.getArguments().size() == 1 && sc.getArguments().get(0).getValue().equals(nounToExpand)) { + List<DiscourseReferent> newargs = new ArrayList<DiscourseReferent>(); + newargs.add(c.getArguments().get(0)); + newargs.add(sc.getArguments().get(0)); + sc.setArguments(newargs); + for (Slot s : slots) { + if (s.getAnchor().equals(sc.getPredicate())) { + s.setSlotType(SlotType.PROPERTY); + break; + } + } + break; + } + } + } + + for (Simple_DRS_Condition c : emptyConditions) { + drs.removeCondition(c); + } + + } + private boolean isUri(String arg) { return false; // TODO } Modified: trunk/components-ext/src/main/resources/tbsl/evaluation/dbpedia-train-tagged(ideal).xml =================================================================== --- trunk/components-ext/src/main/resources/tbsl/evaluation/dbpedia-train-tagged(ideal).xml 2011-10-26 09:03:57 UTC (rev 3322) +++ trunk/components-ext/src/main/resources/tbsl/evaluation/dbpedia-train-tagged(ideal).xml 2011-10-26 09:43:32 UTC (rev 3323) @@ -14410,7 +14410,7 @@ </answers> </question> <question id="13"> -<string>Which/WDT cities/NNS have/VBP more/JJR than/IN 2/CD million/CD inhabitants/NNS</string> +<string>Which/WDT cities/NNS have/VBP more/JJR than/IN 2000000/CD inhabitants/NNS</string> <query> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> Modified: trunk/components-ext/src/main/resources/tbsl/lexicon/english.lex =================================================================== --- trunk/components-ext/src/main/resources/tbsl/lexicon/english.lex 2011-10-26 09:03:57 UTC (rev 3322) +++ trunk/components-ext/src/main/resources/tbsl/lexicon/english.lex 2011-10-26 09:43:32 UTC (rev 3323) @@ -86,8 +86,8 @@ the least || (DET DET:'the' DET:'least') || <y, l1, e, [ l1:[ | l2:[ y | ] THELEAST y l3:[|] ] ], [], [],[]> // COUNT - more than || (DP DET:'more' DET:'than' NUM[num] NP[np]) || <x,l1,<<e,t>,t>,[ l1:[ y,c | count(y,c), greater(c,z) ] ],[(l2,y,np,<e,t>),(l3,z,num,e)],[l2=l1,l3=l1],[]> ;; <x,l1,<<e,t>,t>,[ l1:[ y | greater(y,z) ] ],[(l2,y,np,<e,t>),(l3,z,num,e)],[l2=l1,l3=l1],[]> - less than || (DP DET:'less' DET:'than' NUM[num] NP[np]) || <x,l1,<<e,t>,t>,[ l1:[ y,c | count(y,c), less(c,z) ] ],[(l2,y,np,<e,t>),(l3,z,num,e)],[l2=l1,l3=l1],[]> ;; <x,l1,<<e,t>,t>,[ l1:[ y | less(y,z) ] ],[(l2,y,np,<e,t>),(l3,z,num,e)],[l2=l1,l3=l1],[]> + more than || (DP DET:'more' DET:'than' NUM[num] NP[np]) || <y,l1,<<e,t>,t>,[ l1:[ y,c | count(y,c), greater(c,z) ] ],[(l2,y,np,<e,t>),(l3,z,num,e)],[l2=l1,l3=l1],[]> ;; <y,l1,<<e,t>,t>,[ l1:[ y | greater(y,z) ] ],[(l2,y,np,<e,t>),(l3,z,num,e)],[l2=l1,l3=l1],[]> + less than || (DP DET:'less' DET:'than' NUM[num] NP[np]) || <y,l1,<<e,t>,t>,[ l1:[ y,c | count(y,c), less(c,z) ] ],[(l2,y,np,<e,t>),(l3,z,num,e)],[l2=l1,l3=l1],[]> ;; <y,l1,<<e,t>,t>,[ l1:[ y | less(y,z) ] ],[(l2,y,np,<e,t>),(l3,z,num,e)],[l2=l1,l3=l1],[]> // HOW how || (DP DET:'how' ADJ[adj]) || <x,l1,<<e,t>,t>,[ l1:[?x|] ],[ (x,l2,adj,<e,t>) ],[l2=l1],[]> @@ -99,6 +99,11 @@ also || (VP ADV:'also' VP*) || <x,l1,t,[ l1:[|] ],[],[],[]> also || (DP ADV:'also' DP*) || <x,l1,<<e,t>,t>,[ l1:[|] ],[],[],[]> + has || (S DP[subject] (VP V:'has' DP[object])) || <x, l1, t, [ l1:[ | ], l2:[ | empty(x,y) ] ], [ (l3,x,subject,<<e,t>,t>), (l4,y,object,<<e,t>,t>) ], [ l3<l1, l4<l1, l2<scope(l3), l2<scope(l4) ],[]> + have || (S DP[subject] (VP V:'have' DP[object])) || <x, l1, t, [ l1:[ | ], l2:[ | empty(x,y) ] ], [ (l3,x,subject,<<e,t>,t>), (l4,y,object,<<e,t>,t>) ], [ l3<l1, l4<l1, l2<scope(l3), l2<scope(l4) ],[]> + + with || (NP NP* (PP P:'with' DP[dp])) || <x,l1,<e,t>,[ l1:[| empty(x,y) ] ],[(l2,y,dp,<<e,t>,t>)],[l2=l1],[]> + // WH WORDS // -------- This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |