From: <chr...@us...> - 2012-05-07 13:15:30
|
Revision: 3694 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=3694&view=rev Author: christinaunger Date: 2012-05-07 11:56:11 +0000 (Mon, 07 May 2012) Log Message: ----------- [tbsl] repaired some stuff causing parse failures Modified Paths: -------------- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/converter/DRS2BasicSPARQL_Converter.java trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/ltag/parser/GrammarFilter.java trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/ltag/parser/Preprocessor.java trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/sem/dudes/reader/DUDE_Parser.jj trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/templator/BasicSlotBuilder.java trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/templator/BasicTemplator.java trunk/components-ext/src/main/resources/tbsl/lexicon/basic_english.lex trunk/components-ext/src/test/java/org/dllearner/algorithm/tbsl/GoldTagger.java Modified: trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/converter/DRS2BasicSPARQL_Converter.java =================================================================== --- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/converter/DRS2BasicSPARQL_Converter.java 2012-05-06 21:35:52 UTC (rev 3693) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/converter/DRS2BasicSPARQL_Converter.java 2012-05-07 11:56:11 UTC (rev 3694) @@ -1,9 +1,6 @@ package org.dllearner.algorithm.tbsl.converter; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Set; +import java.util.*; import org.dllearner.algorithm.tbsl.sem.drs.Complex_DRS_Condition; import org.dllearner.algorithm.tbsl.sem.drs.DRS; @@ -241,6 +238,35 @@ p.setTarget(simple.getArguments().get(1).getValue()); temp.addConditions(p); } + else if (simple.getArguments().size() == 3) { + Path p = new Path(); + p.setStart(simple.getArguments().get(0).getValue()); + p.setVia(predicate); + String newword = null; + Slot del = null; + for (Slot s : slots) { + if (s.getAnchor().equals(simple.getArguments().get(1).getValue())) { + newword = s.getWords().get(0); + del = s; + break; + } + } + if (newword != null) { + for (Slot s : slots) { + if (s.getAnchor().equals(predicate)) { + boolean date = false; + if (s.getWords().get(0).endsWith(" date")) date = true; + newword = s.getWords().get(0).replace(" date","") + " " + newword; + if (date) newword += " date"; + s.setWords(Arrays.asList(newword)); + break; + } + } + if (del != null) slots.remove(del); + } + p.setTarget(simple.getArguments().get(2).getValue()); + temp.addConditions(p); + } } else if (predicate.equals("count")) { if (simple.getArguments().size() == 1) { Modified: trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/ltag/parser/GrammarFilter.java =================================================================== --- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/ltag/parser/GrammarFilter.java 2012-05-06 21:35:52 UTC (rev 3693) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/ltag/parser/GrammarFilter.java 2012-05-07 11:56:11 UTC (rev 3694) @@ -151,11 +151,11 @@ */ String[] tokenParts = token.split(" "); if (tokenParts.length > 2) { - + for (String anchor : grammar.getWildCardAnchors()) { if (token.matches(anchor)) { - + foundCandidates = true; coveredTokens.add(token); Modified: trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/ltag/parser/Preprocessor.java =================================================================== --- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/ltag/parser/Preprocessor.java 2012-05-06 21:35:52 UTC (rev 3693) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/ltag/parser/Preprocessor.java 2012-05-07 11:56:11 UTC (rev 3694) @@ -195,8 +195,13 @@ } m = whenPattern.matcher(condensedstring); while (m.find()) { + if (m.group(5).equals("VPREP")) { + if (VERBOSE) logger.trace("Replacing " + m.group(1) + " by " + m.group(2)+m.group(3)+"/WHENPREP"); + condensedstring = condensedstring.replaceFirst(m.group(1),m.group(2) + m.group(3)+"/WHENPREP"); + } else { if (VERBOSE) logger.trace("Replacing " + m.group(1) + " by " + m.group(2)+m.group(3)+"/WHEN"); condensedstring = condensedstring.replaceFirst(m.group(1),m.group(2) + m.group(3)+"/WHEN"); + } } m = wherePattern.matcher(condensedstring); while (m.find()) { @@ -210,13 +215,13 @@ } m = adjnounPattern.matcher(condensedstring); while (m.find()) { - if (VERBOSE) logger.trace("Replacing " + m.group(1) + " by " + m.group(2)+"_"+m.group(3)+"/JJNN"); - condensedstring = condensedstring.replaceFirst(m.group(1),m.group(2)+"_"+m.group(3)+"/JJNN"); + if (VERBOSE) logger.trace("Replacing " + m.group(1) + " by " + m.group(2)+"_"+m.group(3)+"/NN"); + condensedstring = condensedstring.replaceFirst(m.group(1),m.group(2)+"_"+m.group(3)+"/NN"); } m = adjnprepPattern.matcher(condensedstring); while (m.find()) { - if (VERBOSE) logger.trace("Replacing " + m.group(1) + " by " + m.group(2)+"_"+m.group(3)+"/JJNPREP"); - condensedstring = condensedstring.replaceFirst(m.group(1),m.group(2)+"_"+m.group(3)+"/JJNPREP"); + if (VERBOSE) logger.trace("Replacing " + m.group(1) + " by " + m.group(2)+"_"+m.group(3)+"/NPREP"); + condensedstring = condensedstring.replaceFirst(m.group(1),m.group(2)+"_"+m.group(3)+"/NPREP"); } return condensedstring; Modified: trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/sem/dudes/reader/DUDE_Parser.jj =================================================================== --- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/sem/dudes/reader/DUDE_Parser.jj 2012-05-06 21:35:52 UTC (rev 3693) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/sem/dudes/reader/DUDE_Parser.jj 2012-05-07 11:56:11 UTC (rev 3694) @@ -52,44 +52,44 @@ { DUDE() <EOF> } - -/** DUDE */ -Dude DUDE() : -{ - Token referent; - Token label; - Type type; - List<DRS> drs_list = null; - List<DominanceConstraint> constraints = null; + +/** DUDE */ +Dude DUDE() : +{ + Token referent; + Token label; + Type type; + List<DRS> drs_list = null; + List<DominanceConstraint> constraints = null; List<Argument> arg_list = null; - List<Slot> slots = null; -} -{ + List<Slot> slots = null; +} +{ "<" referent = dr() "," label=<LABEL> "," type=Type() "," "[" (drs_list=DRS_List())? "]" "," "[" (arg_list = Arg_List())? "]" - "," "[" (constraints = DC_List())? "]" "," "[" (slots = Slot_List())? "]" ">" - { - Dude dude = new Dude(); - dude.setReferent(referent.toString()); - dude.setType(type); - if (drs_list != null) dude.setComponents(drs_list); - dude.setLabel(new Label(label.toString())); - if (arg_list != null) dude.setArguments(arg_list); + "," "[" (constraints = DC_List())? "]" "," "[" (slots = Slot_List())? "]" ">" + { + Dude dude = new Dude(); + dude.setReferent(referent.toString()); + dude.setType(type); + if (drs_list != null) dude.setComponents(drs_list); + dude.setLabel(new Label(label.toString())); + if (arg_list != null) dude.setArguments(arg_list); if (constraints != null) dude.setDominanceConstraints(constraints); - if (slots != null) dude.setSlots(slots); - return dude; - } -} - -DominanceConstraint DominanceConstraint() : -{ - Label label1; + if (slots != null) dude.setSlots(slots); + return dude; + } +} + +DominanceConstraint DominanceConstraint() : +{ + Label label1; Label label2; Token domType; - DominanceConstraint dc = null; -} + DominanceConstraint dc = null; +} { label1 = Label() "<" label2 = Label() - { + { dc = new DominanceConstraint(label1,label2); return dc; } @@ -105,21 +105,21 @@ | label1 = Label() "=" label2 = Label() - { + { dc = new DominanceConstraint(label1,label2); dc.setType(DomType.equal); return dc; - } -} - - -Label Label() : -{ - Token label; -} + } +} + + +Label Label() : { - - label = <LABEL> + Token label; +} +{ + + label = <LABEL> { return new Label(label.toString()); } @@ -127,219 +127,219 @@ | "res(" label = <LABEL> ")" - { + { return new Label(label.toString(),Position.res); } | "scope(" label = <LABEL> ")" - { + { return new Label(label.toString(),Position.scope); } -} - - -List<DominanceConstraint> DC_List() : -{ -List<DominanceConstraint> dc_list = null; -DominanceConstraint dc = null; -} -{ - dc = DominanceConstraint() ("," dc_list = DC_List())? - { - if (dc_list == null) - { - dc_list = new ArrayList<DominanceConstraint>(); - } - - dc_list.add(0,dc); - return dc_list; - } - - } - -List<DRS> DRS_List() : -{ - DRS drs; - List<DRS> drs_list = null; -} -{ - drs = DRS() ("," drs_list = DRS_List())? - { - if (drs_list == null) - { - drs_list = new ArrayList<DRS>(); - } - - drs_list.add(0,drs); - return drs_list; - } -} - -List<Argument> Arg_List() : -{ - Argument argument; - List<Argument> arg_list = null; -} -{ - argument = Argument() ("," arg_list = Arg_List())? - { - if (arg_list == null) - { - arg_list = new ArrayList<Argument>(); - } - - arg_list.add(0,argument); - return arg_list; - } - -} - -Argument Argument() : -{ - Token label; - Token word; - Token referent; - Type type; -} -{ - "(" label=<LABEL> "," referent = dr() "," word=<WORD> "," type = Type() ")" - { - Argument argument = new Argument(); - argument.setLabel(new Label(label.toString())); - argument.setReferent(referent.toString()); - argument.setAnchor(word.toString()); - argument.setType(type); - return argument; - } -} - -Type Type() : -{ - Type argument; - Type result; - Token word; -} -{ - "<" argument = Type() "," result = Type() ">" - { - CompositeType type = new CompositeType(); - type.setArgumentType(argument); - type.setResultType(result); - return type; - } - - | - - word = <WORD> - { - ElementaryType type=null; - if (word.toString().equals("e")) - type = new ElementaryType(ElemType.e); - if (word.toString().equals("t")) - type = new ElementaryType(ElemType.t); - return type; - } -} - +List<DominanceConstraint> DC_List() : +{ +List<DominanceConstraint> dc_list = null; +DominanceConstraint dc = null; +} +{ + dc = DominanceConstraint() ("," dc_list = DC_List())? + { + if (dc_list == null) + { + dc_list = new ArrayList<DominanceConstraint>(); + } + + dc_list.add(0,dc); + return dc_list; + } + + +} + + +List<DRS> DRS_List() : +{ + DRS drs; + List<DRS> drs_list = null; +} +{ + drs = DRS() ("," drs_list = DRS_List())? + { + if (drs_list == null) + { + drs_list = new ArrayList<DRS>(); + } + + drs_list.add(0,drs); + return drs_list; + } +} + +List<Argument> Arg_List() : +{ + Argument argument; + List<Argument> arg_list = null; +} +{ + argument = Argument() ("," arg_list = Arg_List())? + { + if (arg_list == null) + { + arg_list = new ArrayList<Argument>(); + } + + arg_list.add(0,argument); + return arg_list; + } + +} + +Argument Argument() : +{ + Token label; + Token word; + Token referent; + Type type; +} +{ + "(" label=<LABEL> "," referent = dr() "," word=<WORD> "," type = Type() ")" + { + Argument argument = new Argument(); + argument.setLabel(new Label(label.toString())); + argument.setReferent(referent.toString()); + argument.setAnchor(word.toString()); + argument.setType(type); + return argument; + } +} + +Type Type() : +{ + Type argument; + Type result; + Token word; +} +{ + "<" argument = Type() "," result = Type() ">" + { + CompositeType type = new CompositeType(); + type.setArgumentType(argument); + type.setResultType(result); + return type; + } + + | + + word = <WORD> + { + ElementaryType type=null; + if (word.toString().equals("e")) + type = new ElementaryType(ElemType.e); + if (word.toString().equals("t")) + type = new ElementaryType(ElemType.t); + return type; + } +} + + /** DRS */ DRS DRS() : -{ - Set<DiscourseReferent> dr_set = null; - Set<DRS_Condition> conditions = null; - DRS drs; - Token label; - +{ + Set<DiscourseReferent> dr_set = null; + Set<DRS_Condition> conditions = null; + DRS drs; + Token label; + } -{ - label=<LABEL> ":[" (dr_set=DR_Set())? "|" (conditions=Condition_List())? "]" - { - if (dr_set == null) - { - dr_set = new HashSet<DiscourseReferent>(); - } - drs = new DRS(); - drs.setLabel(label.toString()); - drs.setDiscourseReferents(dr_set); - if (conditions != null) - drs.setDRSConditions(conditions); - return drs; +{ + label=<LABEL> ":[" (dr_set=DR_Set())? "|" (conditions=Condition_List())? "]" + { + if (dr_set == null) + { + dr_set = new HashSet<DiscourseReferent>(); + } + drs = new DRS(); + drs.setLabel(label.toString()); + drs.setDiscourseReferents(dr_set); + if (conditions != null) + drs.setDRSConditions(conditions); + return drs; } -} - +} + /** DR_Set*/ Set<DiscourseReferent> DR_Set() : -{ - Token dr; - Set<DiscourseReferent> dr_set=null; +{ + Token dr; + Set<DiscourseReferent> dr_set=null; } -{ - dr = dr() ("," dr_set=DR_Set())? - { - if (dr_set == null) - { - dr_set= new HashSet<DiscourseReferent>(); - } - if (dr.toString().startsWith("?")) - { +{ + dr = dr() ("," dr_set=DR_Set())? + { + if (dr_set == null) + { + dr_set= new HashSet<DiscourseReferent>(); + } + if (dr.toString().startsWith("?")) + { dr_set.add(new DiscourseReferent(dr.toString().substring(1),true,false)); } else if (dr.toString().startsWith("!")) { dr_set.add(new DiscourseReferent(dr.toString().substring(1),false,true)); } - else - { - dr_set.add(new DiscourseReferent(dr.toString(),false,false)); - } - return dr_set; + else + { + dr_set.add(new DiscourseReferent(dr.toString(),false,false)); + } + return dr_set; } -} - -Set<DRS_Condition> Condition_List() : -{ - DRS_Condition condition= null; - Set<DRS_Condition> conditions = null; -} -{ - condition=Condition() ("," conditions=Condition_List())? - { - if (conditions == null) - { - conditions = new HashSet<DRS_Condition>(); - } - conditions.add(condition); - return conditions; - } -} - -DRS_Condition Condition() : -{ - List<DiscourseReferent> dr_list; - Token dr1; +} + +Set<DRS_Condition> Condition_List() : +{ + DRS_Condition condition= null; + Set<DRS_Condition> conditions = null; +} +{ + condition=Condition() ("," conditions=Condition_List())? + { + if (conditions == null) + { + conditions = new HashSet<DRS_Condition>(); + } + conditions.add(condition); + return conditions; + } +} + +DRS_Condition Condition() : +{ + List<DiscourseReferent> dr_list; + Token dr1; Token dr2; - Token dr; - Token predicate; - Token quantifier; - DRS drs1; - DRS drs2; -} + Token dr; + Token predicate; + Token quantifier; + DRS drs1; + DRS drs2; +} { - predicate=<WORD> "(" dr_list=DR_List() ")" - { - Simple_DRS_Condition condition; - - condition = new Simple_DRS_Condition(); - condition.setPredicate(predicate.toString()); - condition.setArguments(dr_list); - return condition; - } - + predicate=<WORD> "(" dr_list=DR_List() ")" + { + Simple_DRS_Condition condition; + + condition = new Simple_DRS_Condition(); + condition.setPredicate(predicate.toString()); + condition.setArguments(dr_list); + return condition; + } + | dr1 = dr() "=" dr2 = dr() @@ -352,54 +352,54 @@ condition.addArgument(new DiscourseReferent(dr2.toString())); return condition; } - - | - - "NOT" drs1=DRS() - { - Negated_DRS drs = new Negated_DRS(); - drs.setDRS(drs1); - return drs; - } - - | - + + | + + "NOT" drs1=DRS() + { + Negated_DRS drs = new Negated_DRS(); + drs.setDRS(drs1); + return drs; + } + + | + drs1=DRS() (quantifier=<EVERY> | quantifier=<SOME> | quantifier=<AFEW> | quantifier=<MOST> | quantifier=<THEMOST> | quantifier=<THELEAST> | - quantifier=<HOWMANY> | quantifier=<MANY> | quantifier=<NO>) dr=dr() drs2=DRS() - { - Complex_DRS_Condition drs; - drs = new Complex_DRS_Condition(); - drs.setRestrictor(drs1); - drs.setScope(drs2); + quantifier=<HOWMANY> | quantifier=<MANY> | quantifier=<NO>) dr=dr() drs2=DRS() + { + Complex_DRS_Condition drs; + drs = new Complex_DRS_Condition(); + drs.setRestrictor(drs1); + drs.setScope(drs2); drs.setReferent(new DiscourseReferent(dr.toString())); - + if (quantifier.toString().equals("EVERY")) {drs.setQuantifier(DRS_Quantifier.EVERY);} - if (quantifier.toString().equals("SOME")) {drs.setQuantifier(DRS_Quantifier.SOME);} + if (quantifier.toString().equals("SOME")) {drs.setQuantifier(DRS_Quantifier.SOME);} if (quantifier.toString().equals("MOST")) {drs.setQuantifier(DRS_Quantifier.MOST);} if (quantifier.toString().equals("THEMOST")) {drs.setQuantifier(DRS_Quantifier.THEMOST);} - if (quantifier.toString().equals("THELEAST")) {drs.setQuantifier(DRS_Quantifier.THELEAST);} - if (quantifier.toString().equals("AFEW")) {drs.setQuantifier(DRS_Quantifier.FEW);} + if (quantifier.toString().equals("THELEAST")) {drs.setQuantifier(DRS_Quantifier.THELEAST);} + if (quantifier.toString().equals("AFEW")) {drs.setQuantifier(DRS_Quantifier.FEW);} if (quantifier.toString().equals("MANY")) {drs.setQuantifier(DRS_Quantifier.MANY);} if (quantifier.toString().equals("HOWMANY")) {drs.setQuantifier(DRS_Quantifier.HOWMANY);} - if (quantifier.toString().equals("NO")) {drs.setQuantifier(DRS_Quantifier.NO);} - - return drs; - - } -} - + if (quantifier.toString().equals("NO")) {drs.setQuantifier(DRS_Quantifier.NO);} + + return drs; + + } +} + /** DR_List*/ List<DiscourseReferent> DR_List() : -{ - Token dr; - List<DiscourseReferent> dr_list=null; +{ + Token dr; + List<DiscourseReferent> dr_list=null; } -{ - dr = dr() ("," dr_list=DR_List())? - { - if (dr_list == null) - { - dr_list= new ArrayList<DiscourseReferent>(); +{ + dr = dr() ("," dr_list=DR_List())? + { + if (dr_list == null) + { + dr_list= new ArrayList<DiscourseReferent>(); } if (dr.toString().startsWith("?")) { @@ -410,9 +410,9 @@ } else { dr_list.add(0,new DiscourseReferent(dr.toString(),false,false)); - } + } - return dr_list; + return dr_list; } } @@ -445,15 +445,15 @@ { ref = <WORD> "/" type = <WORD> "/" (words = Word_List())? { - if (words == null) - { + if (words == null) + { words = new ArrayList<String>(); } if (type.toString().equals("CLASS")) { slottype = SlotType.CLASS; } - else if (type.toString().equals("RESOURCE")) { slottype = SlotType.RESOURCE; } + else if (type.toString().equals("RESOURCE")) { slottype = SlotType.RESOURCE; } else if (type.toString().equals("PROPERTY")) { slottype = SlotType.PROPERTY; } else if (type.toString().equals("SYMPROPERTY")) { slottype = SlotType.SYMPROPERTY; } - else { slottype = SlotType.UNSPEC; } + else { slottype = SlotType.UNSPEC; } return new Slot(ref.toString(),slottype,words); } @@ -476,8 +476,8 @@ return words; } } - + TOKEN: {<EVERY: "EVERY">} TOKEN: {<MOST: "MOST">} @@ -498,7 +498,7 @@ TOKEN: {<LABEL: "l"(["0"-"9"])+>} -TOKEN: {<WORD: (["a"-"z","A"-"Z","_",".","#",":"])+>} +TOKEN: {<WORD: (["a"-"z","A"-"Z","_",".","#",":","0"-"9"])+>} TOKEN: {<DR: (["?","!"])?(["a"-"z","A"-"Z","0"-"9","."])+>} Modified: trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/templator/BasicSlotBuilder.java =================================================================== --- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/templator/BasicSlotBuilder.java 2012-05-06 21:35:52 UTC (rev 3693) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/templator/BasicSlotBuilder.java 2012-05-07 11:56:11 UTC (rev 3694) @@ -11,7 +11,7 @@ private String[] noun = {"NN","NNS","NNP","NNPS","NPREP","JJNN","JJNPREP"}; private String[] adjective = {"JJ","JJR","JJS","JJH"}; - private String[] verb = {"VB","VBD","VBG","VBN","VBP","VBZ","PASSIVE","PASSPART","VPASS","VPASSIN","GERUNDIN","VPREP","WHEN","WHERE"}; + private String[] verb = {"VB","VBD","VBG","VBN","VBP","VBZ","PASSIVE","PASSPART","VPASS","VPASSIN","GERUNDIN","VPREP","WHEN","WHENPREP","WHERE"}; private String[] preps = {"IN","TO"}; public BasicSlotBuilder() { @@ -206,11 +206,16 @@ result.add(vEntry); } else if (pos.equals("VB")) { - String[] whEntry = {token, + String[] whEntry1 = {token, "(S DP[obj] (VP DP[subj] V:'" + token + "'))", "<x,l1,t,[ l1:[|], l4:[ p | SLOT_" + token + "(x,y) ] ],[(l2,x,subj,<<e,t>,t>),(l3,y,obj,<<e,t>,t>)],[ l2<l1,l3<l1,l4<scope(l2),l4<scope(l3) ],[" + slot + "]>" + " ;; <x,l1,t,[ l1:[|], l4:[ | empty(x,y) ] ],[(l2,x,subj,<<e,t>,t>),(l3,y,obj,<<e,t>,t>)],[ l2<l1,l3<l1,l4<scope(l2),l4<scope(l3) ],[]>"}; - result.add(whEntry); + String[] whEntry2 = {token, + "(S DP[subj] (VP V:'" + token + "' DP[obj] ))", + "<x,l1,t,[ l1:[|], l4:[ p | SLOT_" + token + "(x,y) ] ],[(l2,x,subj,<<e,t>,t>),(l3,y,obj,<<e,t>,t>)],[ l2<l1,l3<l1,l4<scope(l2),l4<scope(l3) ],[" + slot + "]>" + + " ;; <x,l1,t,[ l1:[|], l4:[ | empty(x,y) ] ],[(l2,x,subj,<<e,t>,t>),(l3,y,obj,<<e,t>,t>)],[ l2<l1,l3<l1,l4<scope(l2),l4<scope(l3) ],[]>"}; + result.add(whEntry1); + result.add(whEntry2); } else if (pos.equals("VBG") || pos.equals("VBN")) { String[] gerEntry = {token, @@ -225,11 +230,27 @@ } else if (pos.equals("WHEN")) { slot = "SLOT_" + token + "/PROPERTY/" + token + "_date"; - String[] whenEntry = {token, + String[] whenEntry1 = {token, "(S DP[subj] (VP V:'" + token + "'))", "<x,l1,t,[ l1:[ ?y,p | SLOT_" + token + "(x,y) ] ],[(l2,x,subj,<<e,t>,t>)],[ l2=l1 ],[ " + slot + " ]>"}; - result.add(whenEntry); + String[] whenEntry2 = {token, + "(S DP[subj] (VP V:'" + token + "' DP[obj]))", + "<x,l1,t,[ l1:[ ?y,p | SLOT_" + token + "(x,z,y) ] ],[(l2,x,subj,<<e,t>,t>),(l3,z,obj,<<e,t>,t>)],[ l2=l1,l3=l1 ],[ " + slot + " ]>"}; + result.add(whenEntry1); + result.add(whenEntry2); } + else if (pos.equals("WHENPREP")) { + System.out.println(" >>>> " + token); // DEBUG + slot = "SLOT_" + token + "/PROPERTY/" + token + "_date"; + String[] whenprepEntry1 = {token, + "(S DP[subj] (VP V:'" + token + "' DP[pobj]))", + "<x,l1,t,[ l1:[ ?y,p | SLOT_" + token + "(x,z,y) ] ],[(l2,x,subj,<<e,t>,t>),(l3,z,pobj,<<e,t>,t>)],[ l2=l1,l3=l1 ],[ " + slot + " ]>"}; + String[] whenprepEntry2 = {token, + "(S DP[subj] (VP V:'" + token + "' NP[pobj]))", + "<x,l1,t,[ l1:[ ?y,p,z | SLOT_" + token + "(x,z,y) ] ],[(l2,x,subj,<<e,t>,t>),(l3,z,pobj,<e,t>)],[ l2=l1,l3=l1 ],[ " + slot + " ]>"}; + result.add(whenprepEntry1); + result.add(whenprepEntry2); + } else if (pos.equals("WHERE")) { slot = "SLOT_" + token + "/PROPERTY/" + token + "_place"; String[] whereEntry = {token, @@ -245,10 +266,18 @@ slot = "SLOT_" + token + "/PROPERTY/" + token; /* ADJECTIVE */ if (pos.equals("JJ")) { - String[] adjEntry = {token, + String[] adjEntry1 = {token, "(NP ADJ:'" + token.toLowerCase() + "' NP*)", - "<x,l1,<e,t>,[ l1:[ j | SLOT_" + token + "(x,j) ] ],[],[],["+slot+"]>"}; - result.add(adjEntry); + "<x,l1,<e,t>,[ l1:[ j | SLOT_" + token + "(x,j) ] ],[],[],["+slot+"]>"}; +// String[] adjEntry2 = {"is .+ " + token, +// "(S DP[subject] (VP V:'is' ADJ:'" + token.toLowerCase() + "'))", +// "<x,l1,<e,t>,[ l1:[ | SLOT_" + token + "(x) ] ],[(l2,x,subject,<<e,t>,t>)],[l2=l1],["+slot+"]>"}; +// String[] adjEntry3 = {"is .+ " + token, +// "(S (VP V:'is' DP[subject] ADJ:'" + token.toLowerCase() + "'))", +// "<x,l1,<e,t>,[ l1:[ | SLOT_" + token + "(x) ] ],[(l2,x,subject,<<e,t>,t>)],[l2=l1],["+slot+"]>"}; + result.add(adjEntry1); +// result.add(adjEntry2); +// result.add(adjEntry3); } if (pos.equals("JJH")) { String[] howEntry = {"how "+token, Modified: trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/templator/BasicTemplator.java =================================================================== --- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/templator/BasicTemplator.java 2012-05-06 21:35:52 UTC (rev 3693) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/templator/BasicTemplator.java 2012-05-07 11:56:11 UTC (rev 3694) @@ -45,7 +45,7 @@ } g = LTAG_Constructor.construct(grammarFiles); - + tagger = new StanfordPartOfSpeechTagger(); // tagger = new ApachePartOfSpeechTagger(); Modified: trunk/components-ext/src/main/resources/tbsl/lexicon/basic_english.lex =================================================================== --- trunk/components-ext/src/main/resources/tbsl/lexicon/basic_english.lex 2012-05-06 21:35:52 UTC (rev 3693) +++ trunk/components-ext/src/main/resources/tbsl/lexicon/basic_english.lex 2012-05-07 11:56:11 UTC (rev 3694) @@ -18,8 +18,12 @@ is there || (S V:'is' C:'there' DP[dp]) || <x, l1, t, [ l1:[ | ] ], [ (l2,x,dp,<<e,t>,t>) ], [ l2=l1 ],[]> are there || (S V:'are' C:'there' DP[dp]) || <x, l1, t, [ l1:[ | ] ], [ (l2,x,dp,<<e,t>,t>) ], [ l2=l1 ],[]> + has there been || (S V:'has' C:'there' V:'been' DP[dp]) || <x, l1, t, [ l1:[ | ] ], [ (l2,x,dp,<<e,t>,t>) ], [ l2=l1 ],[]> + have there been || (S V:'have' C:'there' V:'been' DP[dp]) || <x, l1, t, [ l1:[ | ] ], [ (l2,x,dp,<<e,t>,t>) ], [ l2=l1 ],[]> is there || (S DP[dp] (VP V:'is' C:'there')) || <x, l1, t, [ l1:[ | ] ], [ (l2,x,dp,<<e,t>,t>) ], [ l2=l1 ],[]> are there || (S DP[dp] (VP V:'are' C:'there')) || <x, l1, t, [ l1:[ | ] ], [ (l2,x,dp,<<e,t>,t>) ], [ l2=l1 ],[]> + have there been || (S DP[dp] (VP V:'have' C:'there' V:'been')) || <x, l1, t, [ l1:[ | ] ], [ (l2,x,dp,<<e,t>,t>) ], [ l2=l1 ],[]> + has there been || (S DP[dp] (VP V:'has' C:'there' V:'been')) || <x, l1, t, [ l1:[ | ] ], [ (l2,x,dp,<<e,t>,t>) ], [ l2=l1 ],[]> // TO BE: YES/NO QUESTIONS @@ -75,8 +79,9 @@ least || (ADJ DET:'least' ADJ*) || <x,l1,<e,t>,[ l1:[ | minimum(a,x,x) ] ], [],[],[]> - how many || (DET DET:'how' DET:'many') || <x,l1,e, [ l1:[ ?x | ] ], [],[],[]> - how many || (DET DET:'how' DET:'many') || <x,l1,e, [ l1:[ | count(x) ] ], [],[],[]> + how many || (DET DET:'how' DET:'many') || <x,l1,e, [ l1:[ ?x | ] ], [],[],[]> + how many || (DET DET:'how' DET:'many') || <x,l1,e, [ l1:[ | count(x) ] ], [],[],[]> + how often || (DP DET:'how' DET:'often') || <x,l1,<<e,t>,t>, [ l1:[ | count(x) ] ], [],[],[]> a || (DET DET:'a') || <x,l1,e, [ l1:[ x |] ], [],[],[]> an || (DET DET:'an') || <x,l1,e, [ l1:[ x |] ], [],[],[]> which || (DET DET:'which') || <x,l1,e, [ l1:[ ?x |] ], [],[],[]> @@ -102,14 +107,18 @@ 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) ],[]> - had || (S DP[subject] (VP V:'had' 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) ],[]> + have || (S DP[object] (VP DP[subject] V:'have')) || <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) ],[]> + had || (S DP[subject] (VP V:'had' 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],[]> - +// of || (NP NP* (PP P:'of' DP[dp])) || <x,l1,<e,t>,[ l1:[| empty(x,y) ] ],[(l2,y,dp,<<e,t>,t>)],[l2=l1],[]> + people || (NP N:'people') || <x,l1,<e,t>,[ l1:[|] ],[],[],[]> + still || (ADJ ADJ:'still' ADJ*) || <x,l1,<e,t>,[l1:[|]],[],[],[]> + // WH WORDS // -------- @@ -172,7 +181,7 @@ eight || (NP NUM:'eight' NP*) || <x,l1,<e,t>,[l1:[x|count(x,8)]],[],[],[]> nine || (NP NUM:'nine' NP*) || <x,l1,<e,t>,[l1:[x|count(x,9)]],[],[],[]> ten || (NP NUM:'ten' NP*) || <x,l1,<e,t>,[l1:[x|count(x,10)]],[],[],[]> - + one || (NUM NUM:'one') || <x,l1,e,[l1:[x|equal(x,1)]],[],[],[]> two || (NUM NUM:'two') || <x,l1,e,[l1:[x|equal(x,2)]],[],[],[]> three || (NUM NUM:'three') || <x,l1,e,[l1:[x|equal(x,3)]],[],[],[]> Modified: trunk/components-ext/src/test/java/org/dllearner/algorithm/tbsl/GoldTagger.java =================================================================== --- trunk/components-ext/src/test/java/org/dllearner/algorithm/tbsl/GoldTagger.java 2012-05-06 21:35:52 UTC (rev 3693) +++ trunk/components-ext/src/test/java/org/dllearner/algorithm/tbsl/GoldTagger.java 2012-05-07 11:56:11 UTC (rev 3694) @@ -25,8 +25,8 @@ public class GoldTagger { - static String GOLD = "src/main/resources/tbsl/evaluation/qald2-dbpedia-train.xml"; - static String OUT = "target/qald2-dbpedia-train-tagged.xml"; + static String GOLD = "/home/christina/Downloads/dbpedia-test-new.xml"; + static String OUT = "/home/christina/Downloads/dbpedia-test-new-tagged.xml"; public static void main(String[] args) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |