From: <chr...@us...> - 2011-05-03 15:27:13
|
Revision: 2781 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=2781&view=rev Author: christinaunger Date: 2011-05-03 15:27:07 +0000 (Tue, 03 May 2011) Log Message: ----------- Update SPARQL Template Generation (small fixes) Modified Paths: -------------- 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/templator/SlotBuilder.java trunk/components-ext/src/main/resources/tbsl/lexicon/english.lex 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 2011-05-03 14:57:22 UTC (rev 2780) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/ltag/parser/GrammarFilter.java 2011-05-03 15:27:07 UTC (rev 2781) @@ -25,7 +25,6 @@ class GrammarFilter { final static String[] NAMED_Strings = {"named", "called"}; - final static String NAME_PREDICATE = "SLOT.pred:title_name"; static ParseGrammar filter(String taggedinput,LTAGLexicon grammar,List<Integer> temps) { @@ -100,10 +99,10 @@ try { - TreeNode tree = c.construct("(DP NUM:'" + token + "' NP[noun])"); + TreeNode tree = c.construct("NUM:'" + token + "'"); int gid = grammar.addTree(grammar.size(), new Pair<String,TreeNode>(token,tree), - Collections.singletonList("<x,l1,<<e,t>,t>,[l1:[ x | count(x,c), equal(c," + token + ")]],[(l2,x,noun,<e,t>)],[l2=l1],[]>")); + Collections.singletonList("<x,l1,e,[l1:[ x | equal(x," + token + ")]],[],[],[]>")); add(parseG, tree, gid-1, localID); localID++; @@ -230,8 +229,9 @@ rawNames += "DP:'" + split[i] + "' "; } semName = semName.substring(1); - out.add(new Pair<String,String>("(NP NP* ADJ:'"+ w +"' " + rawNames + ")", "<x,l1,<e,t>,[ l1:[ | " + NAME_PREDICATE + "(x,'" + semName + "') ] ], [],[],[]>")); - out.add(new Pair<String,String>("(DP DP* ADJ:'"+ w +"' " + rawNames + ")", "<x,l1,<<e,t>,t>,[ l1:[ | " + NAME_PREDICATE + "(x,'" + semName + "') ] ], [],[],[]>")); + out.add(new Pair<String,String>("(NP NP* ADJ:'"+ w +"' " + rawNames + ")", "<x,l1,<e,t>,[ l1:[ | SLOT_title(x,'" + semName + "') ] ], [],[],[ SLOT_title/PROPERTY/title^name ]>")); + out.add(new Pair<String,String>("(DP DP* ADJ:'"+ w +"' " + rawNames + ")", "<x,l1,<<e,t>,t>,[ l1:[ | SLOT_title(x,'" + semName + "') ] ], [],[],[ SLOT_title/PROPERTY/title^name ]>")); + out.add(new Pair<String,String>("(ADJ ADJ:'"+ w +"' " + rawNames + ")", "<x,l1,<e,t>,[ l1:[ | SLOT_title(x,'" + semName + "') ] ], [],[],[ SLOT_title/PROPERTY/title^name ]>")); return out; 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 2011-05-03 14:57:22 UTC (rev 2780) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/ltag/parser/Preprocessor.java 2011-05-03 15:27:07 UTC (rev 2781) @@ -56,6 +56,7 @@ Pattern passpartPattern = Pattern.compile("\\s((\\w+)/VBN.by/IN)"); Pattern vpassPattern = Pattern.compile("\\s(\\w+/VBD.(\\w+)/VBN)"); Pattern vpassinPattern = Pattern.compile("\\s((\\w+)/VPASS.\\w+/IN)"); + Pattern gerundinPattern = Pattern.compile("\\s((\\w+)/((VBG)|(VBN)).\\w+/IN)"); Pattern vprepPattern = Pattern.compile("\\s((\\w+)/V[A-Z]+\\s\\w+/IN)"); m = compAdjPattern.matcher(condensedstring); @@ -94,6 +95,10 @@ while (m.find()) { condensedstring = condensedstring.replaceFirst(m.group(1),m.group(2)+"/VPASSIN"); } + m = gerundinPattern.matcher(condensedstring); + while (m.find()) { + condensedstring = condensedstring.replaceFirst(m.group(1),m.group(2)+"/GERUNDIN"); + } m = vprepPattern.matcher(condensedstring); while (m.find()) { condensedstring = condensedstring.replaceFirst(m.group(1),m.group(2)+"/VPREP"); Modified: trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/templator/SlotBuilder.java =================================================================== --- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/templator/SlotBuilder.java 2011-05-03 14:57:22 UTC (rev 2780) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/templator/SlotBuilder.java 2011-05-03 15:27:07 UTC (rev 2781) @@ -11,7 +11,7 @@ private WordNet wordnet; private String[] noun = {"NN","NNS","NNP","NNPS","NPREP"}; private String[] adjective = {"JJ","JJR","JJS","JJH"}; - private String[] verb = {"VB","VBD","VBG","VBN","VBP","VBZ","PASSIVE","PASSPART","VPASS","VPASSIN","VPREP"}; + private String[] verb = {"VB","VBD","VBG","VBN","VBP","VBZ","PASSIVE","PASSPART","VPASS","VPASSIN","GERUNDIN","VPREP"}; private String[] preps = {"IN"}; public SlotBuilder() { @@ -52,8 +52,9 @@ words.add(token); words.addAll(wordnet.getBestSynonyms(token)); + String tokenfluent = token.replaceAll(" ",""); String slotX = "x/" + type + "/"; - String slotP = "SLOT_" + token + "/" + type + "/"; + String slotP = "SLOT_" + tokenfluent + "/" + type + "/"; for (Iterator<String> i = words.iterator(); i.hasNext();) { String next = i.next().replaceAll(" ","_"); slotX += next; slotP += next; @@ -72,12 +73,12 @@ /* DP */ String[] dpEntry = {token, "(DP (NP " + treetoken + "))", - "<x,l1,<<e,t>,t>,[ l1:[ x | SLOT_" + token + "(x) ] ],[],[],[" + slotP + "]>"}; + "<x,l1,<<e,t>,t>,[ l1:[ x | SLOT_" + tokenfluent + "(x) ] ],[],[],[" + slotP + "]>"}; result.add(dpEntry); /* NP */ String[] npEntry = {token, "(NP " + treetoken + ")", - "<x,l1,<e,t>,[ l1:[ | SLOT_" + token + "(x) ] ],[],[],[" + slotP + "]>"}; + "<x,l1,<e,t>,[ l1:[ | SLOT_" + tokenfluent + "(x) ] ],[],[],[" + slotP + "]>"}; result.add(npEntry); } else if (pos.equals("NNP") || pos.equals("NNPS")) { @@ -94,17 +95,17 @@ else if (pos.equals("NPREP")) { /* DP */ String[] dpEntry1a = {token, - "(DP (NP " + treetoken + " P:'of' DP[pobj]))", - "<x,l1,<<e,t>,t>,[ l1:[ x | SLOT_" + token + "(y,x) ] ],[(l2,y,pobj,<<e,t>,t>)],[l2=l1],[" + slotP + "]>"}; + "(DP (NP " + treetoken + " DP[pobj]))", + "<x,l1,<<e,t>,t>,[ l1:[ x | SLOT_" + tokenfluent + "(y,x) ] ],[(l2,y,pobj,<<e,t>,t>)],[l2=l1],[" + slotP + "]>"}; String[] dpEntry1b = {token, - "(DP (NP " + treetoken + " P:'of' DP[pobj]))", - "<x,l1,<<e,t>,t>,[ l1:[ x | SLOT_" + token + "(x), SLOT_of(x,y) ] ],[(l2,y,pobj,<<e,t>,t>)],[l2=l1],[" + slotP + "," + "SLOT_of/PROPERTY/" + "]>"}; + "(DP (NP " + treetoken + " DP[pobj]))", + "<x,l1,<<e,t>,t>,[ l1:[ x | SLOT_" + tokenfluent + "(x), SLOT_of(x,y) ] ],[(l2,y,pobj,<<e,t>,t>)],[l2=l1],[" + slotP + "," + "SLOT_of/PROPERTY/" + "]>"}; String[] dpEntry2a = {token, - "(DP DET[det] (NP " + treetoken + " P:'of' DP[pobj]))", - "<x,l1,<<e,t>,t>,[ l1:[ x | SLOT_" + token + "(y,x) ] ],[(l2,y,pobj,<<e,t>,t>),(l3,x,det,e)],[l2=l1,l3=l1],[" + slotP + "]>"}; + "(DP DET[det] (NP " + treetoken + " DP[pobj]))", + "<x,l1,<<e,t>,t>,[ l1:[ x | SLOT_" + tokenfluent + "(y,x) ] ],[(l2,y,pobj,<<e,t>,t>),(l3,x,det,e)],[l2=l1,l3=l1],[" + slotP + "]>"}; String[] dpEntry2b = {token, - "(DP DET[det] (NP " + treetoken + " P:'of' DP[pobj]))", - "<x,l1,<<e,t>,t>,[ l1:[ x | SLOT_" + token + "(x), SLOT_of(x,y) ] ],[(l2,y,pobj,<<e,t>,t>),(l3,x,det,e)],[l2=l1,l3=l1],[" + slotP + "," + "SLOT_of/PROPERTY/" + "]>"}; + "(DP DET[det] (NP " + treetoken + " DP[pobj]))", + "<x,l1,<<e,t>,t>,[ l1:[ x | SLOT_" + tokenfluent + "(x), SLOT_of(x,y) ] ],[(l2,y,pobj,<<e,t>,t>),(l3,x,det,e)],[l2=l1,l3=l1],[" + slotP + "," + "SLOT_of/PROPERTY/" + "]>"}; result.add(dpEntry1a); result.add(dpEntry1b); result.add(dpEntry2a); @@ -147,6 +148,16 @@ "<x,l1,t,[ l1:[|], l4:[ | 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 + "]>"}; result.add(passEntry); } + else if (pos.equals("GERUNDIN")) { + String[] gerundinEntry1 = {token, + "(NP NP* V:'" + token + "' DP[obj]))", + "<x,l1,t,[ l1:[ | SLOT_" + token + "(x,y) ] ],[(l2,y,obj,<<e,t>,t>)],[ l2=l1 ],[" + slot + "]>"}; + String[] gerundinEntry2 = {token, + "(ADJ V:'" + token + "' DP[obj]))", + "<x,l1,<e,t>,[ l1:[ | SLOT_" + token + "(x,y) ] ],[(l2,y,obj,<<e,t>,t>)],[ l2=l1 ],[" + slot + "]>"}; + result.add(gerundinEntry1); + result.add(gerundinEntry2); + } else if (pos.equals("VPREP")) { String[] passEntry = {token, "(S DP[subj] (VP V:'" + token + "' DP[obj]))", Modified: trunk/components-ext/src/main/resources/tbsl/lexicon/english.lex =================================================================== --- trunk/components-ext/src/main/resources/tbsl/lexicon/english.lex 2011-05-03 14:57:22 UTC (rev 2780) +++ trunk/components-ext/src/main/resources/tbsl/lexicon/english.lex 2011-05-03 15:27:07 UTC (rev 2781) @@ -76,8 +76,10 @@ the most || (DET DET:'the' DET:'most') || <y, l1, e, [ l1:[ | l2:[ y | ] THEMOST y l3:[|] ] ], [], [],[]> 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:[ c | count(y,c), greater(c,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:[ c | count(y,c), less(c,z) ] ],[(l2,y,np,<e,t>),(l3,z,num,e)],[l2=l1,l3=l1],[]> + // EMPTY STUFF This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2011-05-13 09:38:56
|
Revision: 2804 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=2804&view=rev Author: christinaunger Date: 2011-05-13 09:38:49 +0000 (Fri, 13 May 2011) Log Message: ----------- [tbsl] removed some small bugs, added TreeTagger test, and removed parser redundancies Modified Paths: -------------- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/converter/DRS2SPARQL_Converter.java trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/ltag/data/FootNode.java trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/ltag/data/SubstNode.java trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/ltag/data/TerminalNode.java trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/ltag/data/Tree.java trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/ltag/data/TreeNode.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/Parser.java trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/sparql/SPARQL_Term.java trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/templator/SlotBuilder.java Added Paths: ----------- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/templator/TreeTagger.java trunk/components-ext/src/main/resources/tbsl/lib/ trunk/components-ext/src/main/resources/tbsl/lib/org.annolab.tt4j-1.0.14.jar 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-05-13 09:21:24 UTC (rev 2803) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/converter/DRS2SPARQL_Converter.java 2011-05-13 09:38:49 UTC (rev 2804) @@ -156,6 +156,7 @@ // add the quantifier at last DiscourseReferent ref = complex.getReferent(); String sref = ref.getValue(); + String fresh; if (!isSilent()) { System.out.print("|quantor:" + quant); } @@ -181,13 +182,15 @@ case SOME: // break; case THE_LEAST: - query.addSelTerm(new SPARQL_Term(sref, SPARQL_Aggregate.COUNT)); - query.addOrderBy(new SPARQL_Term(sref, SPARQL_OrderBy.ASC)); + fresh = "c"+createFresh(); + query.addSelTerm(new SPARQL_Term(sref, SPARQL_Aggregate.COUNT,true, new SPARQL_Term(fresh))); + query.addOrderBy(new SPARQL_Term(fresh, SPARQL_OrderBy.ASC)); query.setLimit(1); break; case THE_MOST: - query.addSelTerm(new SPARQL_Term(sref, SPARQL_Aggregate.COUNT)); - query.addOrderBy(new SPARQL_Term(sref, SPARQL_OrderBy.DESC)); + fresh = "c"+createFresh(); + query.addSelTerm(new SPARQL_Term(sref, SPARQL_Aggregate.COUNT,true, new SPARQL_Term(fresh))); + query.addOrderBy(new SPARQL_Term(fresh, SPARQL_OrderBy.DESC)); query.setLimit(1); break; } Modified: trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/ltag/data/FootNode.java =================================================================== --- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/ltag/data/FootNode.java 2011-05-13 09:21:24 UTC (rev 2803) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/ltag/data/FootNode.java 2011-05-13 09:38:49 UTC (rev 2804) @@ -174,6 +174,9 @@ public String getAnchor() { return ""; } + public TreeNode setAnchor(String a) { + return this; + } public Feature getFeature() { return null; @@ -192,4 +195,8 @@ } } + @Override + public void setAnchor(String old_anchor, String new_anchor) { + } + } Modified: trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/ltag/data/SubstNode.java =================================================================== --- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/ltag/data/SubstNode.java 2011-05-13 09:21:24 UTC (rev 2803) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/ltag/data/SubstNode.java 2011-05-13 09:38:49 UTC (rev 2804) @@ -163,6 +163,9 @@ public String getAnchor() { return ""; } + public TreeNode setAnchor(String a) { + return this; + } public String getIndex() { return index; @@ -198,4 +201,8 @@ } } + @Override + public void setAnchor(String old_anchor, String new_anchor) { + } + } Modified: trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/ltag/data/TerminalNode.java =================================================================== --- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/ltag/data/TerminalNode.java 2011-05-13 09:21:24 UTC (rev 2803) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/ltag/data/TerminalNode.java 2011-05-13 09:38:49 UTC (rev 2804) @@ -164,6 +164,12 @@ } return getTerminal()+" "; } + public TreeNode setAnchor(String a) { + if (!getTerminal().equals("")) { + setTerminal(a); + } + return this; + } public void setTerminal(String terminal) { this.terminal = terminal; @@ -190,5 +196,12 @@ return this.getParent().isGovernedBy(cat); } } + + @Override + public void setAnchor(String old_anchor, String new_anchor) { + if (terminal.equals(old_anchor)) { + terminal = new_anchor; + } + } } Modified: trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/ltag/data/Tree.java =================================================================== --- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/ltag/data/Tree.java 2011-05-13 09:21:24 UTC (rev 2803) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/ltag/data/Tree.java 2011-05-13 09:38:49 UTC (rev 2804) @@ -240,6 +240,11 @@ return output; } + public void setAnchor(String old_anchor,String new_anchor) { + for (TreeNode child : children) { + child.setAnchor(old_anchor,new_anchor); + } + } public String toString() { Modified: trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/ltag/data/TreeNode.java =================================================================== --- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/ltag/data/TreeNode.java 2011-05-13 09:21:24 UTC (rev 2803) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/ltag/data/TreeNode.java 2011-05-13 09:38:49 UTC (rev 2804) @@ -40,6 +40,7 @@ public void setAdjConstraint (boolean x); public String getAnchor(); + public void setAnchor(String old_anchor,String new_anchor); public TreeNode clone(); 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 2011-05-13 09:21:24 UTC (rev 2803) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/ltag/parser/GrammarFilter.java 2011-05-13 09:38:49 UTC (rev 2804) @@ -25,6 +25,9 @@ class GrammarFilter { final static String[] NAMED_Strings = {"named", "called"}; + // DISAM + static List<Integer> usedInts = new ArrayList<Integer>(); + static ArrayList<String> doubles = new ArrayList<String>(); static ParseGrammar filter(String taggedinput,LTAGLexicon grammar,List<Integer> temps) { @@ -66,10 +69,29 @@ if (candidates != null) { foundCandidates = true; coveredTokens.add(token); + + // DISAM + String[] tokenParts = token.split(" "); + String[] newTokenParts = new String[tokenParts.length]; + int fresh = createFresh(); + for (int i = 0; i < tokenParts.length; i++) { + newTokenParts[i] = tokenParts[i] + fresh; + } // + for (Pair<Integer,TreeNode> p : candidates) { - add(parseG, p.getSecond(), p.getFirst(), localID); + + // DISAM + TreeNode new_p_second = p.getSecond(); + if (doubles.contains(token)) { + for (int i = 0; i < tokenParts.length; i++) { + new_p_second.setAnchor(tokenParts[i],newTokenParts[i]); + } + } // + + add(parseG, new_p_second, p.getFirst(), localID); localID++; } + doubles.add(token); // DISAM } else if (named != null) { @@ -127,10 +149,27 @@ foundCandidates = true; coveredTokens.add(token); + // DISAM + String[] newTokenParts = new String[tokenParts.length]; + int fresh = createFresh(); + for (int i = 0; i < tokenParts.length; i++) { + newTokenParts[i] = tokenParts[i] + fresh; + } // + for (Pair<Integer, TreeNode> p : grammar.getAnchorToTrees().get(anchor)) { - add(parseG, p.getSecond(), p.getFirst(),localID); + + // DISAM + TreeNode new_p_second = p.getSecond(); + if (doubles.contains(token)) { + for (int i = 0; i < tokenParts.length; i++) { + new_p_second.setAnchor(tokenParts[i],newTokenParts[i]); + } + } // + + add(parseG, new_p_second, p.getFirst(),localID); localID++; } + doubles.add(token); // DISAM } } } @@ -181,9 +220,14 @@ String[] newparts = newtaggedstring.trim().split(" "); for (String s : newparts) { if (s.contains("/")) { - buildSlotFor.add(new Pair<String,String>(s.trim().substring(0,s.indexOf("/")),s.trim().substring(s.indexOf("/")+1))); + String word = s.trim().substring(0,s.indexOf("/")); + if (doubles.contains(word)) { + word += createFresh(); + } + buildSlotFor.add(new Pair<String,String>(word,s.trim().substring(s.indexOf("/")+1))); + doubles.add(word); } else { - System.out.println("Oh no, " + s + " has no POS tag!"); // DEBUG + System.out.println("Oh no, " + s + " has no POS tag!"); } } System.out.println("build slot for: " + buildSlotFor + "\n"); @@ -284,9 +328,17 @@ result.add(s.substring(0,s.indexOf("/"))); } - System.out.println("Word list: " + result); - return result; } + + private static int createFresh() { + + int fresh = 0; + for (int i = 0; usedInts.contains(i); i++) { + fresh = i+1 ; + } + usedInts.add(fresh); + return fresh; + } } Modified: trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/ltag/parser/Parser.java =================================================================== --- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/ltag/parser/Parser.java 2011-05-13 09:21:24 UTC (rev 2803) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/ltag/parser/Parser.java 2011-05-13 09:38:49 UTC (rev 2804) @@ -42,14 +42,6 @@ */ public List<DerivationTree> parse(String taggeduserinput, LTAGLexicon grammar) { - String inputNoTags = ""; - for (String s : taggeduserinput.split(" ")) { - inputNoTags += s.substring(0,s.indexOf("/")) + " "; - } - - this.input = ("# ".concat(inputNoTags.trim())).split(" "); - int n = this.input.length; - derivationTrees.clear(); derivedTrees.clear(); dudes.clear(); @@ -63,6 +55,15 @@ */ parseGrammar = GrammarFilter.filter(taggeduserinput,grammar,temporaryEntries); + String inputNoTags = ""; + for (String s : taggeduserinput.split(" ")) { + inputNoTags += s.substring(0,s.indexOf("/")) + " "; + } + + this.input = ("# ".concat(inputNoTags.trim())).split(" "); + int n = this.input.length; + + if (SHOW_GRAMMAR) { System.out.println(parseGrammar); } @@ -79,6 +80,7 @@ internalParse(parseGrammar.getDPInitTrees(), n); } + System.out.println("Constructed " + derivationTrees.size() + " derivation trees."); return derivationTrees; } Modified: trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/sparql/SPARQL_Term.java =================================================================== --- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/sparql/SPARQL_Term.java 2011-05-13 09:21:24 UTC (rev 2803) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/sparql/SPARQL_Term.java 2011-05-13 09:38:49 UTC (rev 2804) @@ -2,21 +2,17 @@ public class SPARQL_Term extends SPARQL_Value { - SPARQL_OrderBy orderBy; - SPARQL_Aggregate aggregate; + SPARQL_OrderBy orderBy = SPARQL_OrderBy.NONE; + SPARQL_Aggregate aggregate = SPARQL_Aggregate.NONE; SPARQL_Term as = null; public SPARQL_Term(String name) { super(name); this.name = name.replace("?","").replace("!",""); - orderBy = SPARQL_OrderBy.NONE; - aggregate = SPARQL_Aggregate.NONE; } public SPARQL_Term(String name,boolean b) { super(name); this.name = name.replace("?","").replace("!",""); - orderBy = SPARQL_OrderBy.NONE; - aggregate = SPARQL_Aggregate.NONE; setIsVariable(b); } @@ -35,6 +31,12 @@ super(name); this.orderBy = orderBy; } + public SPARQL_Term(String name, SPARQL_OrderBy orderBy,boolean b,SPARQL_Term t) { + super(name); + this.orderBy = orderBy; + setIsVariable(b); + as = t; + } @Override public boolean equals(Object obj) { @@ -76,12 +78,14 @@ } } if (orderBy != SPARQL_OrderBy.NONE) { + String n; + if (as != null) { n = as.name; } else { n = name; } if (orderBy == SPARQL_OrderBy.ASC) - return "ASC(?"+name.toLowerCase()+")"; + return "ASC(?"+n.toLowerCase()+")"; else - return "DESC(?"+name.toLowerCase()+")"; + return "DESC(?"+n.toLowerCase()+")"; } - if (isVariable()) { + if (isVariable() && !isString()) { return "?"+name.toLowerCase(); } else { Modified: trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/templator/SlotBuilder.java =================================================================== --- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/templator/SlotBuilder.java 2011-05-13 09:21:24 UTC (rev 2803) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/templator/SlotBuilder.java 2011-05-13 09:38:49 UTC (rev 2804) @@ -48,6 +48,7 @@ else if (pos.equals("NPREP")) { type = "PROPERTY"; } + List<String> words = new ArrayList<String>(); words.add(token); if (!pos.equals("NNP") && !pos.equals("NNPS")) { Added: trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/templator/TreeTagger.java =================================================================== --- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/templator/TreeTagger.java (rev 0) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/templator/TreeTagger.java 2011-05-13 09:38:49 UTC (rev 2804) @@ -0,0 +1,37 @@ +package org.dllearner.algorithm.tbsl.templator; + +import java.io.IOException; +import java.util.List; +import java.util.Arrays; + +import org.annolab.tt4j.TokenHandler; +import org.annolab.tt4j.TreeTaggerException; +import org.annolab.tt4j.TreeTaggerWrapper; + +public class TreeTagger { + + TreeTaggerWrapper<String> tt; + + public TreeTagger() throws IOException { + System.setProperty("treetagger.home","/home/christina/Software/TreeTagger"); + tt = new TreeTaggerWrapper<String>(); + tt.setModel("/home/christina/Software/TreeTagger/lib/english.par:iso8859-1"); + } + + public void tagthis(String s) throws IOException, TreeTaggerException { + + List<String> input = Arrays.asList(s.split(" ")); + try { + tt.setHandler(new TokenHandler<String>() { + public void token(String token, String pos, String lemma) { + System.out.println(token+"/"+pos+"/"+lemma); + } + }); + tt.process(input); + System.out.println(tt.getStatus()); + } + finally { + tt.destroy(); + } + } +} Property changes on: trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/templator/TreeTagger.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: trunk/components-ext/src/main/resources/tbsl/lib/org.annolab.tt4j-1.0.14.jar =================================================================== (Binary files differ) Property changes on: trunk/components-ext/src/main/resources/tbsl/lib/org.annolab.tt4j-1.0.14.jar ___________________________________________________________________ Added: svn:mime-type + application/octet-stream This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lor...@us...> - 2011-07-25 09:03:16
|
Revision: 2960 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=2960&view=rev Author: lorenz_b Date: 2011-07-25 09:03:10 +0000 (Mon, 25 Jul 2011) Log Message: ----------- Changed resource loading to InputStreams if possible. Modified Paths: -------------- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/nlp/ApachePartOfSpeechTagger.java trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/nlp/ApacheTokenizer.java trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/nlp/LingPipeNER.java trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/nlp/LingPipePartOfSpeechTagger.java trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/nlp/StanfordPartOfSpeechTagger.java trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/templator/SlotBuilder.java trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/templator/Templator.java trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/templator/WordNet.java trunk/components-ext/src/main/resources/tbsl/tbsl.properties Modified: trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/nlp/ApachePartOfSpeechTagger.java =================================================================== --- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/nlp/ApachePartOfSpeechTagger.java 2011-07-25 08:52:39 UTC (rev 2959) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/nlp/ApachePartOfSpeechTagger.java 2011-07-25 09:03:10 UTC (rev 2960) @@ -1,6 +1,5 @@ package org.dllearner.algorithm.tbsl.nlp; -import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.util.ArrayList; @@ -13,16 +12,15 @@ public class ApachePartOfSpeechTagger implements PartOfSpeechTagger{ private POSTaggerME tagger; - private static final String MODEL_PATH = "src/main/resources/tbsl/models/en-pos-maxent.bin"; + private static final String MODEL_PATH = "tbsl/models/en-pos-maxent.bin"; private Tokenizer tokenizer; public ApachePartOfSpeechTagger() { - InputStream modelIn = null; + InputStream modelIn = this.getClass().getClassLoader().getResourceAsStream(MODEL_PATH); POSModel model = null; try { - modelIn = new FileInputStream(MODEL_PATH); model = new POSModel(modelIn); } catch (IOException e) { Modified: trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/nlp/ApacheTokenizer.java =================================================================== --- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/nlp/ApacheTokenizer.java 2011-07-25 08:52:39 UTC (rev 2959) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/nlp/ApacheTokenizer.java 2011-07-25 09:03:10 UTC (rev 2960) @@ -1,6 +1,5 @@ package org.dllearner.algorithm.tbsl.nlp; -import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; @@ -10,13 +9,12 @@ public class ApacheTokenizer implements Tokenizer{ private opennlp.tools.tokenize.Tokenizer tokenizer; - private static final String MODEL_FILE = "src/main/resources/tbsl/models/en-token.bin"; + private static final String MODEL_PATH = "tbsl/models/en-token.bin"; public ApacheTokenizer() { - InputStream modelIn = null; + InputStream modelIn = this.getClass().getClassLoader().getResourceAsStream(MODEL_PATH); TokenizerModel model = null; try { - modelIn = new FileInputStream(MODEL_FILE); model = new TokenizerModel(modelIn); } catch (IOException e) { Modified: trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/nlp/LingPipeNER.java =================================================================== --- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/nlp/LingPipeNER.java 2011-07-25 08:52:39 UTC (rev 2959) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/nlp/LingPipeNER.java 2011-07-25 09:03:10 UTC (rev 2960) @@ -1,7 +1,10 @@ package org.dllearner.algorithm.tbsl.nlp; import java.io.File; +import java.io.FileOutputStream; import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; import java.util.ArrayList; import java.util.List; @@ -35,8 +38,17 @@ try { long startTime = System.currentTimeMillis(); logger.info("Initializing LingPipe NER..."); - String path = this.getClass().getClassLoader().getResource(DICTIONARY_PATH).getPath(); - Dictionary<String> dictionary = (Dictionary<String>) AbstractExternalizable.readObject(new File(path)); + InputStream is = this.getClass().getClassLoader().getResourceAsStream(DICTIONARY_PATH); + File f = File.createTempFile("dbpedia_lingpipe", ".dictionary"); + f.deleteOnExit(); + OutputStream out=new FileOutputStream(f); + byte buf[]=new byte[1024]; + int len; + while((len=is.read(buf))>0) + out.write(buf,0,len); + out.close(); + is.close(); + Dictionary<String> dictionary = (Dictionary<String>) AbstractExternalizable.readObject(f); ner = new ExactDictionaryChunker(dictionary, IndoEuropeanTokenizerFactory.INSTANCE, allMatches, caseSensitive); logger.info("Done in " + (System.currentTimeMillis()-startTime) + "ms."); } catch (IOException e) { Modified: trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/nlp/LingPipePartOfSpeechTagger.java =================================================================== --- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/nlp/LingPipePartOfSpeechTagger.java 2011-07-25 08:52:39 UTC (rev 2959) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/nlp/LingPipePartOfSpeechTagger.java 2011-07-25 09:03:10 UTC (rev 2960) @@ -1,8 +1,8 @@ package org.dllearner.algorithm.tbsl.nlp; -import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; +import java.io.InputStream; import java.io.ObjectInputStream; import java.util.ArrayList; import java.util.Arrays; @@ -18,7 +18,7 @@ public class LingPipePartOfSpeechTagger implements PartOfSpeechTagger{ - private static final String MODEL_PATH = "src/main/resources/tbsl/models/lingpipe/pos-en-general-brown.HiddenMarkovModel"; + private static final String MODEL_PATH = "tbsl/models/lingpipe/pos-en-general-brown.HiddenMarkovModel"; private static final int TOP_K = 5; @@ -26,7 +26,7 @@ public LingPipePartOfSpeechTagger() { try { - FileInputStream fileIn = new FileInputStream(MODEL_PATH); + InputStream fileIn = this.getClass().getClassLoader().getResourceAsStream(MODEL_PATH); ObjectInputStream objIn = new ObjectInputStream(fileIn); HiddenMarkovModel hmm = (HiddenMarkovModel) objIn.readObject(); Streams.closeQuietly(objIn); Modified: trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/nlp/StanfordPartOfSpeechTagger.java =================================================================== --- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/nlp/StanfordPartOfSpeechTagger.java 2011-07-25 08:52:39 UTC (rev 2959) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/nlp/StanfordPartOfSpeechTagger.java 2011-07-25 09:03:10 UTC (rev 2960) @@ -18,7 +18,8 @@ public StanfordPartOfSpeechTagger(){ try { - String modelPath = this.getClass().getClassLoader().getResource(MODEL).getPath(); +// String modelPath = this.getClass().getClassLoader().getResource(MODEL).getPath(); + String modelPath = Thread.currentThread().getContextClassLoader().getResource(MODEL).getPath(); tagger = new MaxentTagger(modelPath); } catch (IOException e) { e.printStackTrace(); Modified: trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/templator/SlotBuilder.java =================================================================== --- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/templator/SlotBuilder.java 2011-07-25 08:52:39 UTC (rev 2959) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/templator/SlotBuilder.java 2011-07-25 09:03:10 UTC (rev 2960) @@ -19,7 +19,6 @@ public SlotBuilder() { wordnet = new WordNet(); - wordnet.init(); } /** Modified: trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/templator/Templator.java =================================================================== --- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/templator/Templator.java 2011-07-25 08:52:39 UTC (rev 2959) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/templator/Templator.java 2011-07-25 09:03:10 UTC (rev 2960) @@ -1,7 +1,6 @@ package org.dllearner.algorithm.tbsl.templator; import java.util.ArrayList; -import java.util.Arrays; import java.util.HashSet; import java.util.List; import java.util.Set; @@ -12,8 +11,8 @@ import org.dllearner.algorithm.tbsl.ltag.parser.LTAG_Lexicon_Constructor; import org.dllearner.algorithm.tbsl.ltag.parser.Parser; import org.dllearner.algorithm.tbsl.ltag.parser.Preprocessor; +import org.dllearner.algorithm.tbsl.nlp.ApachePartOfSpeechTagger; import org.dllearner.algorithm.tbsl.nlp.PartOfSpeechTagger; -import org.dllearner.algorithm.tbsl.nlp.StanfordPartOfSpeechTagger; import org.dllearner.algorithm.tbsl.sem.drs.DRS; import org.dllearner.algorithm.tbsl.sem.drs.UDRS; import org.dllearner.algorithm.tbsl.sem.dudes.data.Dude; @@ -23,7 +22,7 @@ public class Templator { - String[] GRAMMAR_FILES = {"src/main/resources/tbsl/lexicon/english.lex"}; + String[] GRAMMAR_FILES = {"tbsl/lexicon/english.lex"}; PartOfSpeechTagger tagger; LTAGLexicon g; @@ -34,10 +33,15 @@ boolean UNTAGGED_INPUT = true; public Templator() { + List<String> grammarFiles = new ArrayList<String>(); + for(int i = 0; i < GRAMMAR_FILES.length; i++){ + grammarFiles.add(this.getClass().getClassLoader().getResource(GRAMMAR_FILES[i]).getPath()); + } - g = LTAG_Constructor.construct(Arrays.asList(GRAMMAR_FILES)); + g = LTAG_Constructor.construct(grammarFiles); - tagger = new StanfordPartOfSpeechTagger(); +// tagger = new StanfordPartOfSpeechTagger(); + tagger = new ApachePartOfSpeechTagger(); p = new Parser(); p.SHOW_GRAMMAR = true; Modified: trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/templator/WordNet.java =================================================================== --- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/templator/WordNet.java 2011-07-25 08:52:39 UTC (rev 2959) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/templator/WordNet.java 2011-07-25 09:03:10 UTC (rev 2960) @@ -8,27 +8,12 @@ public class WordNet { - public String path = "tbsl/dict/"; - public WordNetDatabase database; + private WordNetDatabase database; - public WordNet(String s) { - path = s; - - } public WordNet() { - path = this.getClass().getClassLoader().getResource(path).getPath(); - } - - public void setWordNetPath(String s) { - path = s; - } - - public void init() { - System.setProperty("wordnet.database.dir",path); database = WordNetDatabase.getFileInstance(); } - public List<String> getBestSynonyms(String s) { List<String> synonyms = new ArrayList<String>(); Modified: trunk/components-ext/src/main/resources/tbsl/tbsl.properties =================================================================== --- trunk/components-ext/src/main/resources/tbsl/tbsl.properties 2011-07-25 08:52:39 UTC (rev 2959) +++ trunk/components-ext/src/main/resources/tbsl/tbsl.properties 2011-07-25 09:03:10 UTC (rev 2960) @@ -14,3 +14,5 @@ learning.maxTestedQueriesPerTemplate = 20 !similarity | lucene | none learning.ranking = similarity + +wordnet.dictionary = tbsl/dict/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lor...@us...> - 2011-09-28 16:02:31
|
Revision: 3289 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=3289&view=rev Author: lorenz_b Date: 2011-09-28 16:02:20 +0000 (Wed, 28 Sep 2011) Log Message: ----------- Added new index for properties based on NLP pattern extracted with the BOA framework from Daniel and Axel. Modified Paths: -------------- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/learning/SPARQLTemplateBasedLearner.java trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/nlp/WordNet.java trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/search/Search.java trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/search/SolrSearch.java trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/templator/Templator.java trunk/components-ext/src/main/resources/tbsl/tbsl.properties Added Paths: ----------- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/search/HierarchicalSolrSearch.java Modified: trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/learning/SPARQLTemplateBasedLearner.java =================================================================== --- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/learning/SPARQLTemplateBasedLearner.java 2011-09-27 13:16:47 UTC (rev 3288) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/learning/SPARQLTemplateBasedLearner.java 2011-09-28 16:02:20 UTC (rev 3289) @@ -82,6 +82,7 @@ private SolrSearch resource_index; private SolrSearch class_index; private SolrSearch property_index; + private SolrSearch boa_pattern_property_index; private ModelGenerator modelGenenerator; private Templator templateGenerator; @@ -127,14 +128,23 @@ private void init(Options options){ String resourcesIndexUrl = options.fetch("solr.resources.url"); - resource_index = new SolrSearch(resourcesIndexUrl); + String resourcesIndexSearchField = options.fetch("solr.resources.searchfield"); + resource_index = new SolrSearch(resourcesIndexUrl, resourcesIndexSearchField); String classesIndexUrl = options.fetch("solr.classes.url"); - class_index = new SolrSearch(classesIndexUrl); + String classesIndexSearchField = options.fetch("solr.classes.searchfield"); + class_index = new SolrSearch(classesIndexUrl, classesIndexSearchField); String propertiesIndexUrl = options.fetch("solr.properties.url"); - property_index = new SolrSearch(propertiesIndexUrl); + String propertiesIndexSearchField = options.fetch("solr.properties.searchfield"); + property_index = new SolrSearch(propertiesIndexUrl, propertiesIndexSearchField); + String boaPatternIndexUrl = options.fetch("solr.boa.properties.url"); + String boaPatternIndexSearchField = options.fetch("solr.boa.properties.searchfield"); + boa_pattern_property_index = new SolrSearch(boaPatternIndexUrl, boaPatternIndexSearchField); + + int maxIndexResults = Integer.parseInt(options.fetch("solr.query.limit"), 10); + maxQueryExecutionTimeInSeconds = Integer.parseInt(options.get("sparql.query.maxExecutionTimeInSeconds", "20")); cache.setMaxExecutionTimeInSeconds(maxQueryExecutionTimeInSeconds); @@ -493,21 +503,47 @@ if(slot.getSlotType() == SlotType.RESOURCE){ words = slot.getWords(); } else { - words = pruneList(slot.getWords());//getLemmatizedWords(slot.getWords()); +// words = pruneList(slot.getWords());//getLemmatizedWords(slot.getWords()); + words = pruneList(slot.getWords()); } - for(String word : words){ - tmp = new TreeSet<String>(new StringSimilarityComparator(word)); - uris = uriCache.get(word); - if(uris == null){ -// uris = index.getResources("label:\"" + word + "\"~0.7"); - uris = index.getResources("label:" + word + "~0.5"); - uriCache.put(word, uris); + if(slot.getSlotType() == SlotType.PROPERTY || slot.getSlotType() == SlotType.SYMPROPERTY){ + for(String word : words){ + tmp = new TreeSet<String>(new StringSimilarityComparator(word)); + uris = uriCache.get(word); + index = boa_pattern_property_index; + if(uris == null){ + uris = index.getResources(word); + uriCache.put(word, uris); + } + index = property_index; + if(uris.size() < 10){ + uris.addAll(index.getResources(word)); + } + if(uris.size() < 10){ + uris.addAll(index.getResources("" + word + "~0.8")); + } + tmp.addAll(uris); + sortedURIs.addAll(tmp); + tmp.clear(); } - tmp.addAll(uris); - sortedURIs.addAll(tmp); - tmp.clear(); + } else { + for(String word : words){ + tmp = new TreeSet<String>(new StringSimilarityComparator(word)); + uris = uriCache.get(word); + if(uris == null){ + uris = index.getResources(word); + uriCache.put(word, uris); + } + if(uris.size() < 10){ + uris.addAll(index.getResources("" + word + "~0.7")); + } + tmp.addAll(uris); + sortedURIs.addAll(tmp); + tmp.clear(); + } } + slot2URI.put(slot, sortedURIs); mon.stop(); logger.info("Done in " + mon.getLastValue() + "ms."); @@ -521,7 +557,7 @@ boolean smallest = true; for(String w2 : words){ if(!w1.equals(w2)){ - if(w2.contains(w1)){ + if(w1.contains(w2)){ smallest = false; break; } @@ -546,7 +582,6 @@ pruned.add(word); } else { String lemWord = lemmatizer.stem(word); - new LingPipeLemmatizer().stem(word); if(!pruned.contains(lemWord)){ pruned.add(lemWord); } @@ -742,7 +777,7 @@ // String question = "Give me all books written by authors influenced by Ernest Hemingway."; // String question = "Give me all cities in Canada."; - String question = "Give me all soccer clubs in Premier League?"; + String question = "Give me all books written by authors influenced by Ernest Hemingway."; SPARQLTemplateBasedLearner learner = new SPARQLTemplateBasedLearner(); SparqlEndpoint endpoint = new SparqlEndpoint(new URL("http://greententacle.techfak.uni-bielefeld.de:5171/sparql"), Collections.<String>singletonList(""), Collections.<String>emptyList()); Modified: trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/nlp/WordNet.java =================================================================== --- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/nlp/WordNet.java 2011-09-27 13:16:47 UTC (rev 3288) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/nlp/WordNet.java 2011-09-28 16:02:20 UTC (rev 3289) @@ -34,6 +34,7 @@ try { IndexWord iw = dict.getIndexWord(pos, s);//dict.getMorphologicalProcessor().lookupBaseForm(pos, s) +// IndexWord iw = dict.getMorphologicalProcessor().lookupBaseForm(pos, s); if(iw != null){ Synset[] synsets = iw.getSenses(); Word[] words = synsets[0].getWords(); Added: trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/search/HierarchicalSolrSearch.java =================================================================== --- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/search/HierarchicalSolrSearch.java (rev 0) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/search/HierarchicalSolrSearch.java 2011-09-28 16:02:20 UTC (rev 3289) @@ -0,0 +1,36 @@ +package org.dllearner.algorithm.tbsl.search; + +import java.util.ArrayList; +import java.util.List; + +public class HierarchicalSolrSearch extends SolrSearch { + + private SolrSearch primarySearch; + private SolrSearch secondarySearch; + + public HierarchicalSolrSearch(SolrSearch primarySearch, SolrSearch secondarySearch) { + this.primarySearch = primarySearch; + this.secondarySearch = secondarySearch; + } + + @Override + public List<String> getResources(String queryString) { + return getResources(queryString, 10, 0); + } + + @Override + public List<String> getResources(String queryString, int limit) { + return getResources(queryString, limit, 0); + } + + @Override + public List<String> getResources(String queryString, int limit, int offset) { + List<String> resources = new ArrayList<String>(); + resources = primarySearch.getResources(queryString, limit, offset); + if(resources.size() < limit){ + resources.addAll(secondarySearch.getResources(queryString, limit-resources.size(), offset)); + } + return resources; + } + +} Property changes on: trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/search/HierarchicalSolrSearch.java ___________________________________________________________________ Added: svn:mime-type + text/plain Modified: trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/search/Search.java =================================================================== --- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/search/Search.java 2011-09-27 13:16:47 UTC (rev 3288) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/search/Search.java 2011-09-28 16:02:20 UTC (rev 3289) @@ -4,7 +4,8 @@ public interface Search { List<String> getResources(String queryString); - List<String> getResources(String queryString, int offset); + List<String> getResources(String queryString, int limit); + List<String> getResources(String queryString, int limit, int offset); int getTotalHits(String queryString); void setHitsPerPage(int hitsPerPage); Modified: trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/search/SolrSearch.java =================================================================== --- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/search/SolrSearch.java 2011-09-27 13:16:47 UTC (rev 3288) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/search/SolrSearch.java 2011-09-28 16:02:20 UTC (rev 3289) @@ -22,6 +22,12 @@ private int hitsPerPage = 10; private int lastTotalHits = 0; + private String searchField; + + public SolrSearch() { + // TODO Auto-generated constructor stub + } + public SolrSearch(String solrServerURL){ try { server = new CommonsHttpSolrServer(solrServerURL); @@ -30,22 +36,36 @@ e.printStackTrace(); } } + + public SolrSearch(String solrServerURL, String searchField){ + this(solrServerURL); + this.searchField = searchField; + } @Override public List<String> getResources(String queryString) { - return getResources(queryString, 0); + return getResources(queryString, hitsPerPage); } + + @Override + public List<String> getResources(String queryString, int limit) { + return getResources(queryString, limit, 0); + } @Override - public List<String> getResources(String queryString, int offset) { + public List<String> getResources(String queryString, int limit, int offset) { List<String> resources = new ArrayList<String>(); QueryResponse response; try { - ModifiableSolrParams params = new ModifiableSolrParams(); - params.set("q", queryString); - params.set("rows", hitsPerPage); - params.set("start", offset); - response = server.query(params); + SolrQuery q = new SolrQuery((searchField != null) ? searchField + ":" + queryString : queryString); + q.setStart(offset); + q.setRows(limit); + response = server.query(q); +// ModifiableSolrParams params = new ModifiableSolrParams(); +// params.set("q", queryString); +// params.set("rows", hitsPerPage); +// params.set("start", offset); +// response = server.query(params); SolrDocumentList docList = response.getResults(); lastTotalHits = (int) docList.getNumFound(); Modified: trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/templator/Templator.java =================================================================== --- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/templator/Templator.java 2011-09-27 13:16:47 UTC (rev 3288) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/templator/Templator.java 2011-09-28 16:02:20 UTC (rev 3289) @@ -16,6 +16,7 @@ import org.dllearner.algorithm.tbsl.ltag.parser.Parser; import org.dllearner.algorithm.tbsl.ltag.parser.Preprocessor; import org.dllearner.algorithm.tbsl.nlp.ApachePartOfSpeechTagger; +import org.dllearner.algorithm.tbsl.nlp.Lemmatizer; import org.dllearner.algorithm.tbsl.nlp.LingPipeLemmatizer; import org.dllearner.algorithm.tbsl.nlp.PartOfSpeechTagger; import org.dllearner.algorithm.tbsl.nlp.WordNet; @@ -173,8 +174,8 @@ newwords.add(word); newwords.addAll(strings); - newwords.addAll(wordnet.getBestSynonyms(wordnetpos,word)); - for (String att : strings) { + newwords.addAll(wordnet.getBestSynonyms(wordnetpos,getLemmatizedWord(word))); + for (String att : getLemmatizedWords(strings)) { newwords.addAll(wordnet.getBestSynonyms(wordnetpos,att)); } if (newwords.isEmpty()) { @@ -205,6 +206,24 @@ return templates; } + private List<String> getLemmatizedWords(List<String> words){ + List<String> stemmed = new ArrayList<String>(); + for(String word : words){ + //currently only stem single words + if(word.contains(" ")){ + stemmed.add(word); + } else { + stemmed.add(getLemmatizedWord(word)); + } + + } + return stemmed; + } + + private String getLemmatizedWord(String word){ + return lem.stem(word); + } + private boolean containsModuloRenaming(Set<DRS> drses, DRS drs) { for (DRS d : drses) { Modified: trunk/components-ext/src/main/resources/tbsl/tbsl.properties =================================================================== --- trunk/components-ext/src/main/resources/tbsl/tbsl.properties 2011-09-27 13:16:47 UTC (rev 3288) +++ trunk/components-ext/src/main/resources/tbsl/tbsl.properties 2011-09-28 16:02:20 UTC (rev 3289) @@ -1,7 +1,12 @@ solr.server.url = http://139.18.2.173:8080/apache-solr-3.3.0 solr.classes.url = ${solr.server.url}/dbpedia_classes +solr.classes.searchfield = label solr.resources.url = ${solr.server.url}/dbpedia_resources +solr.resources.searchfield = label solr.properties.url = ${solr.server.url}/dbpedia_properties +solr.properties.searchfield = label +solr.boa.properties.url = ${solr.server.url}/boa_pattern +solr.boa.properties.searchfield = nlr solr.query.limit = 20 sparql.endpoint.url = http://live.dbpedia.org/sparql @@ -11,7 +16,7 @@ !remote | local learning.validationType = remote learning.stopAfterFirstNonEmptyQueryResult = true -learning.maxTestedQueriesPerTemplate = 20 +learning.maxTestedQueriesPerTemplate = 50 !similarity | lucene | none learning.ranking = similarity This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lor...@us...> - 2011-09-30 12:13:51
|
Revision: 3296 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=3296&view=rev Author: lorenz_b Date: 2011-09-30 12:13:40 +0000 (Fri, 30 Sep 2011) Log Message: ----------- Made console output configurable via log4j. Fixed bug in Query copy contructor. Modified Paths: -------------- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/learning/SPARQLTemplateBasedLearner.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/Parser.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/sparql/Query.java trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/templator/Templator.java trunk/components-ext/src/main/resources/log4j.properties Modified: trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/learning/SPARQLTemplateBasedLearner.java =================================================================== --- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/learning/SPARQLTemplateBasedLearner.java 2011-09-30 07:42:41 UTC (rev 3295) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/learning/SPARQLTemplateBasedLearner.java 2011-09-30 12:13:40 UTC (rev 3296) @@ -725,7 +725,7 @@ // Logger.getLogger(HttpClient.class).setLevel(Level.OFF); // Logger.getLogger(HttpMethodBase.class).setLevel(Level.OFF); // String question = "Give me all books written by authors influenced by Ernest Hemingway."; - String question = "Give me the highest mountain in Germany"; + String question = "Give me all European Capitals!"; // String question = "Give me all books written by authors influenced by Ernest Hemingway."; SPARQLTemplateBasedLearner learner = new SPARQLTemplateBasedLearner(); 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 2011-09-30 07:42:41 UTC (rev 3295) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/ltag/parser/GrammarFilter.java 2011-09-30 12:13:40 UTC (rev 3296) @@ -5,6 +5,7 @@ import java.util.Iterator; import java.util.List; +import org.apache.log4j.Logger; import org.dllearner.algorithm.tbsl.ltag.data.Category; import org.dllearner.algorithm.tbsl.ltag.data.LTAG_Tree_Constructor; import org.dllearner.algorithm.tbsl.ltag.data.TreeNode; @@ -24,6 +25,8 @@ * anchor "a b .+ c". */ class GrammarFilter { + + private static final Logger logger = Logger.getLogger(GrammarFilter.class); final static String[] NAMED_Strings = {"named", "called"}; // DISAM @@ -188,7 +191,7 @@ start++; } - System.out.println("\ncovered tokens: " + coveredTokens); + logger.trace("\ncovered tokens: " + coveredTokens); /* construct slots for all unknown tokens */ @@ -208,7 +211,7 @@ } } } - System.out.println("unknown words: " + unknownWords); + logger.trace("unknown words: " + unknownWords); List<Pair<String,String>> buildSlotFor = new ArrayList<Pair<String,String>>(); @@ -235,7 +238,7 @@ System.out.println("Oh no, " + s + " has no POS tag!"); } } - System.out.println("build slot for: " + buildSlotFor + "\n"); + logger.trace("build slot for: " + buildSlotFor + "\n"); List<String[]> entries; if (mode.equals("LEIPZIG")) { Modified: trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/ltag/parser/Parser.java =================================================================== --- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/ltag/parser/Parser.java 2011-09-30 07:42:41 UTC (rev 3295) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/ltag/parser/Parser.java 2011-09-30 12:13:40 UTC (rev 3296) @@ -3,12 +3,15 @@ import java.util.ArrayList; import java.util.List; +import org.apache.log4j.Logger; import org.dllearner.algorithm.tbsl.ltag.data.TreeNode; import org.dllearner.algorithm.tbsl.sem.dudes.data.Dude; import org.dllearner.algorithm.tbsl.sem.dudes.reader.ParseException; import org.dllearner.algorithm.tbsl.sem.util.Pair; public class Parser { + + private static final Logger logger = Logger.getLogger(Parser.class); public boolean CONSTRUCT_SEMANTICS = false; public boolean USE_DPS_AS_INITTREES = false; @@ -66,11 +69,11 @@ if (SHOW_GRAMMAR) { - System.out.println(parseGrammar); + logger.trace(parseGrammar); } if (SHOW_LEXICAL_COVERAGE) { - System.out.println("# OF TREES FOUND: " + parseGrammar.size()); - System.out.println("# OF INPUT TOKENS: " + n); + logger.trace("# OF TREES FOUND: " + parseGrammar.size()); + logger.trace("# OF INPUT TOKENS: " + n); } List<Pair<TreeNode, Short>> initTrees = parseGrammar.getInitTrees(); @@ -81,7 +84,7 @@ internalParse(parseGrammar.getDPInitTrees(), n); } - System.out.println("Constructed " + derivationTrees.size() + " derivation trees.\n"); + logger.trace("Constructed " + derivationTrees.size() + " derivation trees.\n"); return derivationTrees; } 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 2011-09-30 07:42:41 UTC (rev 3295) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/ltag/parser/Preprocessor.java 2011-09-30 12:13:40 UTC (rev 3296) @@ -6,10 +6,14 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; +import org.apache.log4j.Logger; import org.dllearner.algorithm.tbsl.nlp.LingPipeNER; import org.dllearner.algorithm.tbsl.nlp.NER; +import org.dllearner.algorithm.tbsl.templator.Templator; public class Preprocessor { + + private static final Logger logger = Logger.getLogger(Preprocessor.class); static final String[] genericReplacements = { "\"", "", "'", "", "[!?.,;]", "" }; static final String[] englishReplacements = { "don't", "do not", "doesn't", "does not" }; @@ -80,57 +84,57 @@ m = compAdjPattern.matcher(condensedstring); while (m.find()) { - System.out.println("Replacing " + m.group(1) + " by " + m.group(2)+"/JJR"); + logger.trace("Replacing " + m.group(1) + " by " + m.group(2)+"/JJR"); condensedstring = condensedstring.replaceFirst(m.group(1),m.group(2)+"/JJR"); } m = superAdjPattern.matcher(condensedstring); while (m.find()) { - System.out.println("Replacing " + m.group(1) + " by " + m.group(2)+"/JJS"); + logger.trace("Replacing " + m.group(1) + " by " + m.group(2)+"/JJS"); condensedstring = condensedstring.replaceFirst(m.group(1),m.group(2)+"/JJS"); } m = howAdjPattern.matcher(condensedstring); while (m.find()) { - System.out.println("Replacing " + m.group(1) + " by " + m.group(2)+"/JJH"); + logger.trace("Replacing " + m.group(1) + " by " + m.group(2)+"/JJH"); condensedstring = condensedstring.replaceFirst(m.group(1),m.group(2)+"/JJH"); } m = nprepPattern.matcher(condensedstring); while (m.find()) { - System.out.println("Replacing " + m.group(1) + " by " + m.group(2)+"/NPREP"); + logger.trace("Replacing " + m.group(1) + " by " + m.group(2)+"/NPREP"); condensedstring = condensedstring.replaceFirst(m.group(1),m.group(2)+"/NPREP"); } m = didPattern.matcher(condensedstring); while (m.find()) { - System.out.println("Replacing " + m.group(1) + " by \"\""); + logger.trace("Replacing " + m.group(1) + " by \"\""); condensedstring = condensedstring.replaceFirst(m.group(1),""); } m = prepfrontPattern.matcher(condensedstring); while (m.find()) { - System.out.println("Replacing " + m.group(1) + " by \"\""); + logger.trace("Replacing " + m.group(1) + " by \"\""); condensedstring = condensedstring.replaceFirst(m.group(1),""); } m = passivePattern1a.matcher(condensedstring); while (m.find()) { - System.out.println("Replacing " + m.group(1) + " by " + m.group(6)+"/PASSIVE"); + logger.trace("Replacing " + m.group(1) + " by " + m.group(6)+"/PASSIVE"); condensedstring = condensedstring.replaceFirst(m.group(1),m.group(6)+"/PASSIVE"); } m = passivePattern1b.matcher(condensedstring); while (m.find()) { - System.out.println("Replacing " + m.group(1) + " by " + m.group(6)+m.group(7)+"/PASSIVE"); + logger.trace("Replacing " + m.group(1) + " by " + m.group(6)+m.group(7)+"/PASSIVE"); condensedstring = condensedstring.replaceFirst(m.group(1),m.group(6) + m.group(7)+"/PASSIVE"); } m = passivePattern2a.matcher(condensedstring); while (m.find()) { - System.out.println("Replacing " + m.group(1) + " by " + m.group(7)+"/PASSIVE"); + logger.trace("Replacing " + m.group(1) + " by " + m.group(7)+"/PASSIVE"); condensedstring = condensedstring.replaceFirst(m.group(1),m.group(7)+"/PASSIVE"); } m = pseudopassPattern.matcher(condensedstring); while (m.find()) { - System.out.println("Replacing " + m.group(1) + " by " + m.group(7)+"/VPREP"); + logger.trace("Replacing " + m.group(1) + " by " + m.group(7)+"/VPREP"); condensedstring = condensedstring.replaceFirst(m.group(1),m.group(7)+"/VPREP"); } m = pseudopwhPattern.matcher(condensedstring); while (m.find()) { - System.out.println("Replacing " + m.group(1) + " by " + m.group(7)+m.group(8)+"/VPREP"); + logger.trace("Replacing " + m.group(1) + " by " + m.group(7)+m.group(8)+"/VPREP"); condensedstring = condensedstring.replaceFirst(m.group(1),m.group(7)+" "+m.group(8)+"/VPREP"); } m = saveIsThere.matcher(condensedstring); @@ -139,52 +143,52 @@ } m = passivePattern2b.matcher(condensedstring); while (m.find()) { - System.out.println("Replacing " + m.group(1) + " by " + m.group(7)+"/PASSIVE"); + logger.trace("Replacing " + m.group(1) + " by " + m.group(7)+"/PASSIVE"); condensedstring = condensedstring.replaceFirst(m.group(1),m.group(7)+"/PASSIVE"); } m = passpartPattern.matcher(condensedstring); while (m.find()) { - System.out.println("Replacing " + m.group(1) + " by " + m.group(2)+"/PASSPART"); + logger.trace("Replacing " + m.group(1) + " by " + m.group(2)+"/PASSPART"); condensedstring = condensedstring.replaceFirst(m.group(1),m.group(2)+"/PASSPART"); } m = vpassPattern.matcher(condensedstring); while (m.find()) { - System.out.println("Replacing " + m.group(1) + " by " + m.group(2)+"/VPASS"); + logger.trace("Replacing " + m.group(1) + " by " + m.group(2)+"/VPASS"); condensedstring = condensedstring.replaceFirst(m.group(1),m.group(2)+"/VPASS"); } m = vpassinPattern.matcher(condensedstring); while (m.find()) { - System.out.println("Replacing " + m.group(1) + " by " + m.group(2)+"/VPASSIN"); + logger.trace("Replacing " + m.group(1) + " by " + m.group(2)+"/VPASSIN"); condensedstring = condensedstring.replaceFirst(m.group(1),m.group(2)+"/VPASSIN"); } m = gerundinPattern.matcher(condensedstring); while (m.find()) { - System.out.println("Replacing " + m.group(1) + " by " + m.group(2)+"/GERUNDIN"); + logger.trace("Replacing " + m.group(1) + " by " + m.group(2)+"/GERUNDIN"); condensedstring = condensedstring.replaceFirst(m.group(1),m.group(2)+"/GERUNDIN"); } m = vprepPattern.matcher(condensedstring); while (m.find()) { - System.out.println("Replacing " + m.group(1) + " by " + m.group(2)+"/VPREP"); + logger.trace("Replacing " + m.group(1) + " by " + m.group(2)+"/VPREP"); condensedstring = condensedstring.replaceFirst(m.group(1),m.group(2)+"/VPREP"); } m = whenPattern.matcher(condensedstring); while (m.find()) { - System.out.println("Replacing " + m.group(1) + " by " + m.group(2)+m.group(3)+"/WHEN"); + 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()) { - System.out.println("Replacing " + m.group(1) + " by " + m.group(2)+m.group(3)+"/WHERE"); + logger.trace("Replacing " + m.group(1) + " by " + m.group(2)+m.group(3)+"/WHERE"); condensedstring = condensedstring.replaceFirst(m.group(1),m.group(2) + m.group(3)+"/WHERE"); } m = adjnounPattern.matcher(condensedstring); while (m.find()) { - System.out.println("Replacing " + m.group(1) + " by " + m.group(2)+"_"+m.group(3)+"/JJNN"); + 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"); } m = adjnprepPattern.matcher(condensedstring); while (m.find()) { - System.out.println("Replacing " + m.group(1) + " by " + m.group(2)+"_"+m.group(3)+"/JJNPREP"); + 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"); } @@ -232,7 +236,7 @@ List<String> namedentities = ner.getNamedEntitites(untagged); List<String> usefulnamedentities = new ArrayList<String>(); - System.out.println("Proposed NEs: " + namedentities); + logger.trace("Proposed NEs: " + namedentities); // keep only longest matches (e.g. keep 'World of Warcraft' and forget about 'Warcraft') // containing at least one upper case letter (in order to filter out errors like 'software') @@ -250,7 +254,7 @@ } } - System.out.println("Accepted NEs: " + usefulnamedentities); + logger.trace("Accepted NEs: " + usefulnamedentities); // replace POS tags accordingly for (String ne : usefulnamedentities) { Modified: trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/sparql/Query.java =================================================================== --- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/sparql/Query.java 2011-09-30 07:42:41 UTC (rev 3295) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/sparql/Query.java 2011-09-30 12:13:40 UTC (rev 3296) @@ -88,8 +88,9 @@ newTerm.setIsVariable(order.isVariable()); newTerm.setAggregate(order.getAggregate()); newTerm.setOrderBy(order.getOrderBy()); - selTerms.add(newTerm); + orderBy.add(newTerm); } + this.orderBy = orderBy; //TODO add copy for filters Set<SPARQL_Filter> filters = new HashSet<SPARQL_Filter>(); for(SPARQL_Filter filter : query.getFilters()){ @@ -99,7 +100,6 @@ } this.filter = filters; - this.orderBy = orderBy; this.limit = query.getLimit(); this.offset = query.getOffset(); } Modified: trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/templator/Templator.java =================================================================== --- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/templator/Templator.java 2011-09-30 07:42:41 UTC (rev 3295) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/templator/Templator.java 2011-09-30 12:13:40 UTC (rev 3296) @@ -9,6 +9,7 @@ import net.didion.jwnl.data.POS; +import org.apache.log4j.Logger; import org.dllearner.algorithm.tbsl.converter.DRS2SPARQL_Converter; import org.dllearner.algorithm.tbsl.converter.DUDE2UDRS_Converter; import org.dllearner.algorithm.tbsl.ltag.parser.LTAGLexicon; @@ -29,6 +30,8 @@ public class Templator { + private static final Logger logger = Logger.getLogger(Templator.class); + String[] GRAMMAR_FILES = {"tbsl/lexicon/english.lex"}; private String[] noun = {"NN","NNS","NNP","NNPS","NPREP","JJNN","JJNPREP"}; @@ -85,7 +88,7 @@ if (UNTAGGED_INPUT) { s = pp.normalize(s); tagged = tagger.tag(s); - System.out.println("Tagged input: " + tagged); + logger.trace("Tagged input: " + tagged); } else { tagged = s; @@ -93,20 +96,20 @@ String newtagged = pp.condenseNominals(pp.findNEs(tagged,s)); newtagged = pp.condense(newtagged); - System.out.println("Preprocessed: " + newtagged); + logger.trace("Preprocessed: " + newtagged); p.parse(newtagged,g); if (p.getDerivationTrees().isEmpty()) { p.clear(g,p.getTemps()); clearAgain = false; - System.out.println("[Templator.java] '" + s + "' could not be parsed."); + logger.error("[Templator.java] '" + s + "' could not be parsed."); } else { try { p.buildDerivedTrees(g); } catch (ParseException e) { - System.err.println("[Templator.java] ParseException at '" + e.getMessage() + "'"); + logger.error("[Templator.java] ParseException at '" + e.getMessage() + "'", e); } } @@ -145,7 +148,7 @@ Template temp = d2s.convert(drs,slots); // find WordNet synonyms - Set<String> newwords; + List<String> newwords; String word; String pos; for (Slot slot : temp.getSlots()) { @@ -170,7 +173,7 @@ strings = wordnet.getAttributes(word); } - newwords = new HashSet<String>(); + newwords = new ArrayList<String>(); newwords.add(word); newwords.addAll(strings); Modified: trunk/components-ext/src/main/resources/log4j.properties =================================================================== --- trunk/components-ext/src/main/resources/log4j.properties 2011-09-30 07:42:41 UTC (rev 3295) +++ trunk/components-ext/src/main/resources/log4j.properties 2011-09-30 12:13:40 UTC (rev 3296) @@ -26,6 +26,7 @@ # loglevels: trace, debug, info, warn, error, fatal # log4j.rootLogger=INFO, stdout +log4j.appender.stdout.layout.ConversionPattern=%m%n #, file @@ -39,6 +40,8 @@ ####TBSL log4j.category.org.dllearner.algorithm.tbsl=INFO +log4j.category.org.dllearner.algorithm.tbsl.ltag.parser=TRACE +log4j.category.org.dllearner.algorithm.tbsl.templator=TRACE ####SOLR log4j.category.org.apache.solr.level = OFF This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
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. |
From: <chr...@us...> - 2011-10-26 13:42:52
|
Revision: 3325 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=3325&view=rev Author: christinaunger Date: 2011-10-26 13:42:40 +0000 (Wed, 26 Oct 2011) Log Message: ----------- [tbsl] added additional templates and ideal POS tags for NEs Modified Paths: -------------- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/converter/DRS2SPARQL_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/sparql/SPARQL_Term.java trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/templator/SlotBuilder.java trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/templator/Templator.java trunk/components-ext/src/main/resources/tbsl/evaluation/dbpedia-test-questions-tagged(ideal).xml 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 11:38:13 UTC (rev 3324) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/converter/DRS2SPARQL_Converter.java 2011-10-26 13:42:40 UTC (rev 3325) @@ -79,6 +79,9 @@ slots = ls; Query q = convert(drs, new Query(), false); + if (q == null) { + return null; + } q.setPrefixes(prefixes); template.setQuery(q); @@ -94,7 +97,9 @@ // System.out.println("--- DRS (before): " + drs); // DEBUG redundantEqualRenaming(drs); - restructureEmpty(drs); + if (!restructureEmpty(drs)) { + return null; + } // System.out.println("--- DRS (after) : " + drs); // DEBUG for (DiscourseReferent referent : drs.getDRs()) { @@ -379,7 +384,7 @@ } - private void restructureEmpty(DRS drs) { + private boolean restructureEmpty(DRS drs) { Set<Simple_DRS_Condition> emptyConditions = new HashSet<Simple_DRS_Condition>(); for (Simple_DRS_Condition c : drs.getAllSimpleConditions()) { @@ -387,30 +392,63 @@ emptyConditions.add(c); } } + if (emptyConditions.isEmpty()) { + return true; + } + boolean globalsuccess = false; for (Simple_DRS_Condition c : emptyConditions) { String nounToExpand = c.getArguments().get(1).getValue(); + String fallbackNoun = c.getArguments().get(0).getValue(); + boolean success = false; + loop: 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; - } + if (s.getSlotType().equals(SlotType.CLASS)) { + s.setSlotType(SlotType.PROPERTY); + List<DiscourseReferent> newargs = new ArrayList<DiscourseReferent>(); + newargs.add(c.getArguments().get(0)); + newargs.add(sc.getArguments().get(0)); + sc.setArguments(newargs); + success = true; + globalsuccess = true; + break loop; + } + } } - break; } } + if (!success) { // do the same for fallbackNoun + loop: + for (Simple_DRS_Condition sc : drs.getAllSimpleConditions()) { + if (sc.getArguments().size() == 1 && sc.getArguments().get(0).getValue().equals(fallbackNoun)) { + for (Slot s : slots) { + if (s.getAnchor().equals(sc.getPredicate())) { + if (s.getSlotType().equals(SlotType.CLASS)) { + s.setSlotType(SlotType.PROPERTY); + List<DiscourseReferent> newargs = new ArrayList<DiscourseReferent>(); + newargs.add(c.getArguments().get(1)); + newargs.add(sc.getArguments().get(0)); + sc.setArguments(newargs); + success = true; + globalsuccess = true; + break loop; + } + } + } + } + } + } } - for (Simple_DRS_Condition c : emptyConditions) { - drs.removeCondition(c); + if (globalsuccess) { + for (Simple_DRS_Condition c : emptyConditions) { + drs.removeCondition(c); + } } - + return globalsuccess; } private boolean isUri(String arg) { 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 2011-10-26 11:38:13 UTC (rev 3324) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/ltag/parser/GrammarFilter.java 2011-10-26 13:42:40 UTC (rev 3325) @@ -106,7 +106,7 @@ for (Pair<String,String> p : named) { try { - TreeNode tree = c.construct(p.getFirst().replaceAll("_"," ")); + TreeNode tree = c.construct(p.getFirst()); // .replaceAll("_"," ") int gid = grammar.addTree(grammar.size(), new Pair<String,TreeNode>(token,tree), Collections.singletonList(p.getSecond())); add(parseG, tree, gid-1, localID); @@ -277,7 +277,11 @@ private static List<Pair<String,String>> checkForNamedString(String token) { - String[] split = token.split(" "); + String[] split; + if (token.contains(" ")) { + split = token.split(" "); + } + else split = token.split("_"); if (split.length > 1 && split.length < 5) { @@ -292,6 +296,7 @@ semName += "_" + split[i]; rawNames += "DP:'" + split[i] + "' "; } + semName = semName.substring(1); out.add(new Pair<String,String>("(NP NP* ADJ:'"+ w +"' " + rawNames + ")", "<x,l1,<e,t>,[ l1:[ | SLOT_title(x,'" + semName + "') ] ], [],[],[ SLOT_title/PROPERTY/title^name ]>")); out.add(new Pair<String,String>("(DP DP* ADJ:'"+ w +"' " + rawNames + ")", "<x,l1,<<e,t>,t>,[ l1:[ | SLOT_title(x,'" + semName + "') ] ], [],[],[ SLOT_title/PROPERTY/title^name ]>")); 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 2011-10-26 11:38:13 UTC (rev 3324) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/ltag/parser/Preprocessor.java 2011-10-26 13:42:40 UTC (rev 3325) @@ -81,6 +81,7 @@ Pattern vprepPattern = Pattern.compile("\\s((\\w+)/V[A-Z]+\\s\\w+/(IN|TO))"); Pattern whenPattern = Pattern.compile("(?i)(when/WRB\\s(.+\\s)(\\w+)/((V[A-Z]+)|(PASS[A-Z]+)))"); Pattern wherePattern = Pattern.compile("(?i)(where/WRB\\s(.+\\s)(\\w+)/((V[A-Z]+)|(PASS[A-Z]+)))"); + Pattern adjsPattern = Pattern.compile("((\\w+)/JJ.(\\w+)/JJ)"); Pattern adjnounPattern = Pattern.compile("((\\w+)(?<!many)/JJ.(\\w+)/NN(S)?)"); Pattern adjnprepPattern = Pattern.compile("((\\w+)(?<!many)/JJ.(\\w+)/NPREP)"); @@ -183,6 +184,11 @@ logger.trace("Replacing " + m.group(1) + " by " + m.group(2)+m.group(3)+"/WHERE"); condensedstring = condensedstring.replaceFirst(m.group(1),m.group(2) + m.group(3)+"/WHERE"); } + m = adjsPattern.matcher(condensedstring); + while (m.find()) { + logger.trace("Replacing " + m.group(1) + " by " + m.group(2)+"_"+m.group(3)+"/JJ"); + condensedstring = condensedstring.replaceFirst(m.group(1),m.group(2)+"_"+m.group(3)+"/JJ"); + } m = adjnounPattern.matcher(condensedstring); while (m.find()) { logger.trace("Replacing " + m.group(1) + " by " + m.group(2)+"_"+m.group(3)+"/JJNN"); Modified: trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/sparql/SPARQL_Term.java =================================================================== --- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/sparql/SPARQL_Term.java 2011-10-26 11:38:13 UTC (rev 3324) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/sparql/SPARQL_Term.java 2011-10-26 13:42:40 UTC (rev 3325) @@ -97,7 +97,10 @@ else return "DESC(?"+alias.toLowerCase()+")"; } - if (isString() || isURI) { + if (isString()) { + return name.replaceAll("_"," "); + } + else if (isURI) { return name; } else return "?"+name.toLowerCase(); Modified: trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/templator/SlotBuilder.java =================================================================== --- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/templator/SlotBuilder.java 2011-10-26 11:38:13 UTC (rev 3324) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/templator/SlotBuilder.java 2011-10-26 13:42:40 UTC (rev 3325) @@ -124,7 +124,7 @@ else if (pos.equals("JJNPREP")) { String jjtoken = token.substring(0,token.indexOf("_")); String nntoken = token.substring(token.indexOf("_")+1); - String slotfluent = "SLOT_" + tokenfluent + "/" + type + "/" + token; + String slotfluent = "SLOT_" + tokenfluent + "/CLASS/" + token; String slotnn = "SLOT_" + nntoken + "/PROPERTY/" + nntoken; String slotnnc = "SLOT_" + nntoken + "/CLASS/" + nntoken; String slotjj = "SLOT_" + jjtoken + "/CLASS/" + jjtoken; @@ -148,15 +148,24 @@ result.add(npEntry); } else if(pos.equals("JJNN") && token.contains("_")) { - String jjtoken = token.substring(0,token.indexOf("_")); - String nntoken = token.substring(token.indexOf("_")+1); + String[] tokens = token.split("_"); + String nntoken = tokens[tokens.length-1]; String slotfluent = "SLOT_" + tokenfluent + "/CLASS/" + token; - String slotnn = "SLOT_" + nntoken + "/CLASS/" + nntoken; - String slotjj = "SLOT_" + jjtoken + "/CLASS/" + jjtoken; + String slotnn = "SLOT_" + nntoken + "/CLASS/" + nntoken; + String semantics = "<x,l1,<e,t>,[ l1:[ | SLOT_" + tokenfluent + "(x) ] ],[],[],[" + slotfluent + "]> " + + ";; <x,l1,<e,t>,[ l1:[ | SLOT_" + nntoken + "(x)"; + String slots = slotnn; + for (int i=0; i<(tokens.length-1); i++) { + semantics += ", SLOT_" + tokens[i] + "(x)"; + slots += ",SLOT_" + tokens[i] + "/CLASS/" + tokens[i]; + } + semantics += "] ],[],[],[" + slots + "]>"; + String[] npEntry = {token, "(NP " + treetoken + " )", - "<x,l1,<e,t>,[ l1:[ | SLOT_" + tokenfluent + "(x) ] ],[],[],[" + slotfluent + "]> ;; " + - "<x,l1,<e,t>,[ l1:[ | SLOT_" + nntoken + "(x), SLOT_" + jjtoken + "(x) ] ],[],[],[" + slotnn + "," + slotjj + "]>"}; + semantics }; +// "<x,l1,<e,t>,[ l1:[ | SLOT_" + tokenfluent + "(x) ] ],[],[],[" + slotfluent + "]> ;; " + +// "<x,l1,<e,t>,[ l1:[ | SLOT_" + nntoken + "(x), SLOT_" + jjtoken + "(x) ] ],[],[],[" + slotnn + "," + slotjj + "]>"}; result.add(npEntry); } @@ -165,13 +174,8 @@ else if (equalsOneOf(pos,verb)) { String slot; String symslot; - if (token.equals("has") || token.equals("have") || token.equals("had")) { - slot = "SLOT_" + token + "/PROPERTY/"; - symslot = "SLOT_" + token + "/SYMPROPERTY/"; - } - else { - slot = "SLOT_" + token + "/PROPERTY/" + token; - symslot = "SLOT_" + token + "/SYMPROPERTY/" + token; + slot = "SLOT_" + token + "/PROPERTY/" + token; + symslot = "SLOT_" + token + "/SYMPROPERTY/" + token; // List<String> preds = wordnet.getAttributes(token); // for (Iterator<String> i = preds.iterator(); i.hasNext();) { // slot += i.next(); @@ -181,7 +185,7 @@ // symslot += "^"; // } // } - } + if (pos.equals("PASSIVE")) { String[] passEntry1 = {token, "(S DP[subj] (VP V:'" + token + "' DP[obj]))", @@ -189,20 +193,36 @@ String[] passEntry2 = {token, "(S DP[wh] (VP DP[dp] V:'" + token + "'))", "<x,l1,t,[ l1:[|], l4:[ | SLOT_" + token + "(x,y) ] ],[(l2,x,wh,<<e,t>,t>),(l3,y,dp,<<e,t>,t>)],[ l2<l1,l3<l1,l4<scope(l2),l4<scope(l3) ],[" + symslot + "]>"}; + String[] passEntry1empty = {token, + "(S DP[subj] (VP V:'" + token + "' DP[obj]))", + "<x,l1,t,[ l1:[|], l4:[ | empty(y,x) ] ],[(l2,x,subj,<<e,t>,t>),(l3,y,obj,<<e,t>,t>)],[ l2<l1,l3<l1,l4<scope(l2),l4<scope(l3) ],[]>"}; + String[] passEntry2empty = {token, + "(S DP[wh] (VP DP[dp] V:'" + token + "'))", + "<x,l1,t,[ l1:[|], l4:[ | empty(x,y) ] ],[(l2,x,wh,<<e,t>,t>),(l3,y,dp,<<e,t>,t>)],[ l2<l1,l3<l1,l4<scope(l2),l4<scope(l3) ],[]>"}; result.add(passEntry1); result.add(passEntry2); + result.add(passEntry1empty); + result.add(passEntry2empty); } else if (pos.equals("PASSPART")) { String[] passpartEntry = {token, "(NP NP* (VP V:'" + token + "' DP[dp]))", - "<x,l1,t,[ l1:[ | SLOT_" + token + "(y,x) ] ],[(l2,y,dp,<<e,t>,t>)],[ l2=l1 ],[" + symslot + "]>"}; + "<x,l1,t,[ l1:[ | SLOT_" + token + "(y,x) ] ],[(l2,y,dp,<<e,t>,t>)],[ l2=l1 ],[]>"}; + String[] passpartEntryEmpty = {token, + "(NP NP* (VP V:'" + token + "' DP[dp]))", + "<x,l1,t,[ l1:[ | empty(y,x) ] ],[(l2,y,dp,<<e,t>,t>)],[ l2=l1 ],[]>"}; result.add(passpartEntry); + result.add(passpartEntryEmpty); } else if (pos.equals("VPASS")) { String[] passEntry = {token, "(S DP[subj] (VP V:'" + token + "'))", "<x,l1,t,[ l1:[|], l4:[ | SLOT_" + token + "(y,x) ] ],[(l2,x,subj,<<e,t>,t>),(l3,y,obj,<<e,t>,t>)],[ l2<l1,l3<l1,l4<scope(l2),l4<scope(l3) ],[" + symslot + "]>"}; + String[] passEntryEmpty = {token, + "(S DP[subj] (VP V:'" + token + "'))", + "<x,l1,t,[ l1:[|], l4:[ | empty(y,x) ] ],[(l2,x,subj,<<e,t>,t>),(l3,y,obj,<<e,t>,t>)],[ l2<l1,l3<l1,l4<scope(l2),l4<scope(l3) ],[]>"}; result.add(passEntry); + result.add(passEntryEmpty); } else if (pos.equals("VPASSIN")) { String[] passEntry1 = {token, @@ -221,8 +241,16 @@ String[] gerundinEntry2 = {token, "(ADJ V:'" + token + "' DP[obj]))", "<x,l1,<e,t>,[ l1:[ | SLOT_" + token + "(x,y) ] ],[(l2,y,obj,<<e,t>,t>)],[ l2=l1 ],[" + symslot + "]>"}; + String[] gerundinEntry1Empty = {token, + "(NP NP* V:'" + token + "' DP[obj]))", + "<x,l1,t,[ l1:[ | empty(x,y) ] ],[(l2,y,obj,<<e,t>,t>)],[ l2=l1 ],[]>"}; + String[] gerundinEntry2Empty = {token, + "(ADJ V:'" + token + "' DP[obj]))", + "<x,l1,<e,t>,[ l1:[ | empty(x,y) ] ],[(l2,y,obj,<<e,t>,t>)],[ l2=l1 ],[]>"}; result.add(gerundinEntry1); result.add(gerundinEntry2); + result.add(gerundinEntry1Empty); + result.add(gerundinEntry2Empty); } else if (pos.equals("VPREP")) { String[] passEntry = {token, @@ -231,26 +259,46 @@ String[] whEntry = {token, "(S DP[obj] (VP DP[subj] V:'" + token + "'))", "<x,l1,t,[ l1:[|], l4:[ | 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) ],[" + symslot + "]>"}; + String[] passEntryEmpty = {token, + "(S DP[subj] (VP V:'" + token + "' DP[obj]))", + "<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) ],[]>"}; + String[] whEntryEmpty = {token, + "(S DP[obj] (VP DP[subj] V:'" + token + "'))", + "<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(passEntry); result.add(whEntry); + result.add(passEntryEmpty); + result.add(whEntryEmpty); } else if (pos.equals("VBD") || pos.equals("VBZ") || pos.equals("VBP")) { String[] vEntry = {token, "(S DP[subj] (VP V:'" + token + "' DP[obj]))", "<x,l1,t,[ l1:[|], l4:[ | 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) ],[" + symslot + "]>"}; + String[] vEntryEmpty = {token, + "(S DP[subj] (VP V:'" + token + "' DP[obj]))", + "<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(vEntry); + result.add(vEntryEmpty); } else if (pos.equals("VB")) { String[] whEntry = {token, "(S DP[obj] (VP DP[subj] V:'" + token + "'))", "<x,l1,t,[ l1:[|], l4:[ | 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) ],[" + symslot + "]>"}; + String[] whEntryEmpty = {token, + "(S DP[obj] (VP DP[subj] V:'" + token + "'))", + "<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); + result.add(whEntryEmpty); } else if (pos.equals("VBG") || pos.equals("VBN")) { String[] gerEntry = {token, "(NP NP* (VP V:'" + token + "' DP[dp]))", "<x,l1,t,[ l1:[ | SLOT_" + token + "(x,y) ] ],[(l2,y,dp,<<e,t>,t>)],[ l2=l1 ],[" + symslot + "]>"}; + String[] gerEntryEmpty = {token, + "(NP NP* (VP V:'" + token + "' DP[dp]))", + "<x,l1,t,[ l1:[ | empty(x,y) ] ],[(l2,y,dp,<<e,t>,t>)],[ l2=l1 ],[]>"}; result.add(gerEntry); + result.add(gerEntryEmpty); } else if (pos.equals("WHEN")) { String dateSlot = "SLOT_" + token + "/PROPERTY/" + token + "Date"; @@ -349,7 +397,11 @@ String[] npAdjunct = {token, "(NP NP* (PP P:'" + token.toLowerCase() + "' DP[pobj]))", "<x,l1,<e,t>,[ l1:[ | SLOT_" + token + "(x,y) ] ],[(l2,y,pobj,<<e,t>,t>)],[l2=l1],["+slot+"]>"}; + String[] npAdjunctEmpty = {token, + "(NP NP* (PP P:'" + token.toLowerCase() + "' DP[pobj]))", + "<x,l1,<e,t>,[ l1:[ | empty(x,y) ] ],[(l2,y,pobj,<<e,t>,t>)],[l2=l1],[]>"}; result.add(npAdjunct); + result.add(npAdjunctEmpty); } } Modified: trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/templator/Templator.java =================================================================== --- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/templator/Templator.java 2011-10-26 11:38:13 UTC (rev 3324) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/templator/Templator.java 2011-10-26 13:42:40 UTC (rev 3325) @@ -137,16 +137,19 @@ if (!containsModuloRenaming(drses,drs)) { // // DEBUG - System.out.println(dude); - System.out.println(drs); - for (Slot sl : slots) { - System.out.println(sl.toString()); - } +// System.out.println(dude); +// System.out.println(drs); +// for (Slot sl : slots) { +// System.out.println(sl.toString()); +// } // // drses.add(drs); try { Template temp = d2s.convert(drs,slots); + if (temp == null) { + continue; + } // find WordNet synonyms List<String> newwords; Modified: trunk/components-ext/src/main/resources/tbsl/evaluation/dbpedia-test-questions-tagged(ideal).xml =================================================================== --- trunk/components-ext/src/main/resources/tbsl/evaluation/dbpedia-test-questions-tagged(ideal).xml 2011-10-26 11:38:13 UTC (rev 3324) +++ trunk/components-ext/src/main/resources/tbsl/evaluation/dbpedia-test-questions-tagged(ideal).xml 2011-10-26 13:42:40 UTC (rev 3325) @@ -3,7 +3,7 @@ <string>Which/WDT presidents/NNS of/IN the/DT United/NNP States/NNPS had/VBD more/JJR than/IN three/CD children/NNS</string> </question> <question id="3"> -<string>Give/VB me/PRP the/DT official/JJ websites/NNS of/IN actors/NNS of/IN the/DT television/NN show/NN Charmed/VBN</string> +<string>Give/VB me/PRP the/DT official/JJ websites/NNS of/IN actors/NNS of/IN the/DT television/NN show/NN Charmed/NNP</string> </question> <question id="37"> <string>Who/WP is/VBZ the/DT daughter/NN of/IN Bill/NNP Clinton/NNP married/VBN to/TO</string> 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 11:38:13 UTC (rev 3324) +++ trunk/components-ext/src/main/resources/tbsl/evaluation/dbpedia-train-tagged(ideal).xml 2011-10-26 13:42:40 UTC (rev 3325) @@ -2031,7 +2031,7 @@ </answers> </question> <question id="37"> -<string>List/VB all/DT episodes/NNS of/IN the/DT first/JJ season/NN of/IN the/DT HBO/NNP television/NN series/NN The/DT Sopranos/NNPS</string> +<string>List/VB all/DT episodes/NNS of/IN the/DT first/JJ season/NN of/IN the/DT HBO/NNP television/NN series/NN The/NNP Sopranos/NNPS</string> <query> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> PREFIX onto: <http://dbpedia.org/ontology/> @@ -19886,7 +19886,7 @@ </answers> </question> <question id="33"> -<string>Which/WDT music/NN albums/NNS contain/VBP the/DT song/NN Last/JJ Christmas/NNP</string> +<string>Which/WDT music/NN albums/NNS contain/VBP the/DT song/NN Last/NNP Christmas/NNP</string> <query> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> @@ -26155,7 +26155,7 @@ </answers> </question> <question id="39"> -<string>Who/WP wrote/VBD the/DT book/NN The/DT pillars/NNS of/IN the/DT Earth/NNP</string> +<string>Who/WP wrote/VBD the/DT book/NN The/NNP pillars/NNP of/NNP the/NNP Earth/NNP</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 11:38:13 UTC (rev 3324) +++ trunk/components-ext/src/main/resources/tbsl/lexicon/english.lex 2011-10-26 13:42:40 UTC (rev 3325) @@ -101,9 +101,12 @@ 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) ],[]> - with || (NP NP* (PP P:'with' DP[dp])) || <x,l1,<e,t>,[ l1:[| empty(x,y) ] ],[(l2,y,dp,<<e,t>,t>)],[l2=l1],[]> +// with || (NP NP* (PP P:'with' 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:[|] ],[],[],[]> + // WH WORDS // -------- This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2011-10-28 14:01:27
|
Revision: 3339 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=3339&view=rev Author: christinaunger Date: 2011-10-28 14:01:16 +0000 (Fri, 28 Oct 2011) Log Message: ----------- [tbsl] small bug fixes and changes Modified Paths: -------------- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/converter/DRS2SPARQL_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/sparql/SPARQL_Pair.java trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/templator/SlotBuilder.java trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/templator/Templator.java trunk/components-ext/src/main/resources/tbsl/evaluation/dbpedia-test-questions-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-28 09:43:10 UTC (rev 3338) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/converter/DRS2SPARQL_Converter.java 2011-10-28 14:01:16 UTC (rev 3339) @@ -76,7 +76,7 @@ } template = new Template(new Query()); - slots = ls; + // slots = ls; Query q = convert(drs, new Query(), false); if (q == null) { @@ -102,7 +102,7 @@ } // System.out.println("--- DRS (after) : " + drs); // DEBUG - for (DiscourseReferent referent : drs.getDRs()) { + for (DiscourseReferent referent : drs.collectDRs()) { if (referent.isMarked()) { SPARQL_Term term = new SPARQL_Term(referent.toString().replace("?","")); term.setIsVariable(true); @@ -115,9 +115,13 @@ f.addNotBound(term); query.addFilter(f); } + +// System.out.println("--- referent: " + referent.toString()); // DEBUG for (Slot s : slots) { - if (s.getAnchor().equals(referent.toString())) { - template.addSlot(s); +// System.out.println("--- slot: " + s.toString()); // DEBUG + if (s.getAnchor().equals(referent.getValue()) || s.getAnchor().equals(referent.toString())) { +// System.out.println(" fits!"); // DEBUG + template.addSlot(s); break; } } 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 2011-10-28 09:43:10 UTC (rev 3338) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/ltag/parser/GrammarFilter.java 2011-10-28 14:01:16 UTC (rev 3339) @@ -254,7 +254,7 @@ try { for (String[] entry : entries) { String anchor = entry[0]; - String treestring = entry[1]; + String treestring = entry[1]; List<String> dudeStrings = new ArrayList<String>(); for (String s : entry[2].trim().split(";;")) { if (!s.equals("")) { 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 2011-10-28 09:43:10 UTC (rev 3338) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/ltag/parser/Preprocessor.java 2011-10-28 14:01:16 UTC (rev 3339) @@ -70,8 +70,8 @@ Pattern passivePattern1a = Pattern.compile("(((has)|(have)|(had))/VB[A-Z]?.been/VBN.(\\w+)/VBN.by/IN)"); Pattern passivePattern1b = Pattern.compile("(\\s((has)|(have)|(had))/VB[A-Z]?(.+\\s)been/VBN\\s(\\w+)/VB(N|D))"); Pattern passivePattern2a = Pattern.compile("(((is)|(are)|(was)|(were))/VB[A-Z]?.(\\w+)/VBN.by/IN)"); - Pattern pseudopassPattern = Pattern.compile("(((is)|(are)|(was)|(were))/VB[A-Z]?.(\\w+)/VBN.\\w+/TO)"); - Pattern pseudopwhPattern = Pattern.compile("(((is)|(are)|(was)|(were))/VB[A-Z]?.(.+)\\s(\\w+)/VB(N|D).\\w+/TO)"); + Pattern pseudopassPattern = Pattern.compile("(((is)|(are)|(was)|(were))/VB[A-Z]?.(\\w+)/VBN.\\w+/((TO)|(IN)))"); + Pattern pseudopwhPattern = Pattern.compile("(((is)|(are)|(was)|(were))/VB[A-Z]?.(.+)\\s(\\w+)/VB(N|D).\\w+/((TO)|(IN)))"); Pattern saveIsThere = Pattern.compile("((is)|(are))/(VB[A-Z]?).there/(RB)"); Pattern passivePattern2b = Pattern.compile("(((is)|(are)|(was)|(were))/VB[A-Z]?.((.+)\\s\\w+)/VB(N|D))"); Pattern passpartPattern = Pattern.compile("\\s((\\w+)/VBN.by/IN)"); Modified: trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/sparql/SPARQL_Pair.java =================================================================== --- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/sparql/SPARQL_Pair.java 2011-10-28 09:43:10 UTC (rev 3338) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/sparql/SPARQL_Pair.java 2011-10-28 14:01:16 UTC (rev 3339) @@ -43,7 +43,7 @@ case NEQ: return a + "!=" + b; case REGEX: - return "regex(" + a + "," + b + ")"; + return "regex(" + a + "," + b + ",'i')"; } return ""; } Modified: trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/templator/SlotBuilder.java =================================================================== --- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/templator/SlotBuilder.java 2011-10-28 09:43:10 UTC (rev 3338) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/templator/SlotBuilder.java 2011-10-28 14:01:16 UTC (rev 3339) @@ -124,7 +124,7 @@ else if (pos.equals("JJNPREP")) { String jjtoken = token.substring(0,token.indexOf("_")); String nntoken = token.substring(token.indexOf("_")+1); - String slotfluent = "SLOT_" + tokenfluent + "/CLASS/" + token; + String slotfluent = "SLOT_" + tokenfluent + "/PROPERTY/" + token; String slotnn = "SLOT_" + nntoken + "/PROPERTY/" + nntoken; String slotnnc = "SLOT_" + nntoken + "/CLASS/" + nntoken; String slotjj = "SLOT_" + jjtoken + "/CLASS/" + jjtoken; Modified: trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/templator/Templator.java =================================================================== --- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/templator/Templator.java 2011-10-28 09:43:10 UTC (rev 3338) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/templator/Templator.java 2011-10-28 14:01:16 UTC (rev 3339) @@ -147,11 +147,11 @@ if (!containsModuloRenaming(drses,drs)) { // // DEBUG -// System.out.println(dude); -// System.out.println(drs); -// for (Slot sl : slots) { -// System.out.println(sl.toString()); -// } + System.out.println(dude); + System.out.println(drs); + for (Slot sl : slots) { + System.out.println(sl.toString()); + } // // drses.add(drs); @@ -190,7 +190,7 @@ } newwords = new ArrayList<String>(); - newwords.add(word); + newwords.addAll(slot.getWords()); newwords.addAll(strings); if (wordnetpos != null && !slot.getSlotType().equals(SlotType.RESOURCE)) { Modified: trunk/components-ext/src/main/resources/tbsl/evaluation/dbpedia-test-questions-tagged(ideal).xml =================================================================== --- trunk/components-ext/src/main/resources/tbsl/evaluation/dbpedia-test-questions-tagged(ideal).xml 2011-10-28 09:43:10 UTC (rev 3338) +++ trunk/components-ext/src/main/resources/tbsl/evaluation/dbpedia-test-questions-tagged(ideal).xml 2011-10-28 14:01:16 UTC (rev 3339) @@ -84,13 +84,13 @@ <string>Which/WDT European/JJ countries/NNS are/VBP a/DT constitutional/JJ monarchy/NN</string> </question> <question id="40"> -<string>Who/WP is/VBZ the/DT author/NN of/IN WikiLeaks/NNS</string> +<string>Who/WP is/VBZ the/DT author/NN of/IN WikiLeaks/NNP</string> </question> <question id="17"> <string>Which/WDT state/NN of/IN the/DT United/NNP States/NNPS of/IN America/NNP has/VBZ the/DT highest/JJS density/NN</string> </question> <question id="19"> -<string>What/WP is/VBZ the/DT currency/NN of/IN the/DT Czech/JJ Republic/NNP</string> +<string>What/WP is/VBZ the/DT currency/NN of/IN the/DT Czech/NNP Republic/NNP</string> </question> <question id="22"> <string>Which/WDT countries/NNS in/IN the/DT European/NNP Union/NNP adopted/VBD the/DT Euro/NNP</string> @@ -111,7 +111,7 @@ <string>When/WRB did/VBD Germany/NNP join/VB the/DT EU/NNP</string> </question> <question id="36"> -<string>Which/WDT monarchs/NNS of/IN the/DT United/NNP Kingdom/NNP were/VBD married/VBN to/TO a/DT German/JJ</string> +<string>Which/WDT monarchs/NNS of/IN the/DT United/NNP Kingdom/NNP were/VBD married/VBN to/TO a/DT German/NN</string> </question> <question id="8"> <string>When/WRB was/VBD the/DT Battle/NNP of/IN Gettysburg/NNP</string> Modified: trunk/components-ext/src/main/resources/tbsl/lexicon/english.lex =================================================================== --- trunk/components-ext/src/main/resources/tbsl/lexicon/english.lex 2011-10-28 09:43:10 UTC (rev 3338) +++ trunk/components-ext/src/main/resources/tbsl/lexicon/english.lex 2011-10-28 14:01:16 UTC (rev 3339) @@ -85,6 +85,9 @@ the most || (DET DET:'the' DET:'most') || <y, l1, e, [ l1:[ | l2:[ y | ] THEMOST y l3:[|] ] ], [], [],[]> the least || (DET DET:'the' DET:'least') || <y, l1, e, [ l1:[ | l2:[ y | ] THELEAST y l3:[|] ] ], [], [],[]> + // CHEAT! + highest || (NP ADJ:'highest' NP*) || <x, l1, e, [ l1:[ | maximum(a,x,x) ] ], [], [],[]> ;; <x, l1, e, [ l1:[ | SLOT_high(x), maximum(a,x,x) ] ],[],[],[ SLOT_high/PROPERTY/height^elevation ]> + // COUNT 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],[]> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2011-10-31 09:33:20
|
Revision: 3343 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=3343&view=rev Author: christinaunger Date: 2011-10-31 09:33:13 +0000 (Mon, 31 Oct 2011) Log Message: ----------- [tbsl] fixed parse failures in dbpedia:test Modified Paths: -------------- 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/Scanner.java trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/templator/SlotBuilder.java trunk/components-ext/src/main/resources/tbsl/evaluation/dbpedia-test-questions-tagged(ideal).xml trunk/components-ext/src/main/resources/tbsl/lexicon/english.lex 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 2011-10-31 09:29:27 UTC (rev 3342) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/ltag/parser/Preprocessor.java 2011-10-31 09:33:13 UTC (rev 3343) @@ -63,7 +63,9 @@ Pattern compAdjPattern = Pattern.compile("(\\w+/RBR.(\\w+)/JJ)"); // Pattern superAdjPattern = Pattern.compile("(\\w+/RBS.(\\w+)/JJ)"); // TODO "(the most) official languages" vs "the (most official) languages" + Pattern howManyPattern = Pattern.compile("(how/WRB.many/JJ)"); Pattern howAdjPattern = Pattern.compile("(\\w+/WRB.(\\w+)(?<!many)/JJ)"); + Pattern thesameasPattern = Pattern.compile("(the/DT.same/JJ.(\\w+)/NN.as/IN)"); Pattern nprepPattern = Pattern.compile("\\s((\\w+)/NNS?.of/IN)"); Pattern didPattern = Pattern.compile("(?i)(\\s((did)|(do)|(does))/VB.?)\\s"); Pattern prepfrontPattern = Pattern.compile("(\\A\\w+/((TO)|(IN)).)\\w+/WDT"); // TODO (Nicht ganz sauber. Bei P-Stranding immer zwei Querys, hier nur eine.) @@ -95,11 +97,21 @@ // logger.trace("Replacing " + m.group(1) + " by " + m.group(2)+"/JJS"); // condensedstring = condensedstring.replaceFirst(m.group(1),m.group(2)+"/JJS"); // } + m = howManyPattern.matcher(condensedstring); + while (m.find()) { + logger.trace("Replacing " + m.group(1) + " by how/WLEX many/WLEX"); + condensedstring = condensedstring.replaceFirst(m.group(1),"how/WLEX many/WLEX"); + } m = howAdjPattern.matcher(condensedstring); while (m.find()) { logger.trace("Replacing " + m.group(1) + " by " + m.group(2)+"/JJH"); condensedstring = condensedstring.replaceFirst(m.group(1),m.group(2)+"/JJH"); } + m = thesameasPattern.matcher(condensedstring); + while (m.find()) { + logger.trace("Replacing " + m.group(1) + " by " + m.group(2)+"/NNSAME"); + condensedstring = condensedstring.replaceFirst(m.group(1),m.group(2)+"/NNSAME"); + } m = nprepPattern.matcher(condensedstring); while (m.find()) { logger.trace("Replacing " + m.group(1) + " by " + m.group(2)+"/NPREP"); Modified: trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/ltag/parser/Scanner.java =================================================================== --- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/ltag/parser/Scanner.java 2011-10-31 09:29:27 UTC (rev 3342) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/ltag/parser/Scanner.java 2011-10-31 09:33:13 UTC (rev 3343) @@ -29,7 +29,7 @@ word_i = ""; } - if (t.getTerminal().equalsIgnoreCase(word_i)) { + if (t.getTerminal().equalsIgnoreCase(word_i) || t.getTerminal().matches(word_i + "\\d")) { // second disjunct: DISAM case state.side = 'r'; state.pos = 'a'; Modified: trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/templator/SlotBuilder.java =================================================================== --- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/templator/SlotBuilder.java 2011-10-31 09:29:27 UTC (rev 3342) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/templator/SlotBuilder.java 2011-10-31 09:33:13 UTC (rev 3343) @@ -10,7 +10,7 @@ public class SlotBuilder { - private String[] noun = {"NN","NNS","NNP","NNPS","NPREP","JJNN","JJNPREP"}; + private String[] noun = {"NN","NNS","NNP","NNPS","NPREP","JJNN","JJNPREP","NNSAME"}; 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[] preps = {"IN","TO"}; @@ -43,7 +43,7 @@ else if (pos.equals("NNP") || pos.equals("NNPS")) { type = "RESOURCE"; } - else if (pos.equals("NPREP")) { + else if (pos.equals("NPREP") || pos.equals("NNSAME")) { type = "PROPERTY"; } @@ -168,6 +168,13 @@ // "<x,l1,<e,t>,[ l1:[ | SLOT_" + nntoken + "(x), SLOT_" + jjtoken + "(x) ] ],[],[],[" + slotnn + "," + slotjj + "]>"}; result.add(npEntry); } + else if (pos.equals("NNSAME")) { + String slot = "SLOT_" + token + "/" + type + "/" + token; + String[] nnentry = {token, + "(DP N:'" + token.toLowerCase() + "' DP[dp])", + "<x,l1,<<e,t>,t>, [ l1:[ z | SLOT_"+token+"(x,z), SLOT_"+token+"(y,z) ] ], [ (l2,y,dp,<<e,t>,t>) ], [ l2=l1 ],["+slot+"]>" }; + result.add(nnentry); + } } /* VERBS */ @@ -189,40 +196,28 @@ if (pos.equals("PASSIVE")) { String[] passEntry1 = {token, "(S DP[subj] (VP V:'" + token + "' DP[obj]))", - "<x,l1,t,[ l1:[|], l4:[ | SLOT_" + token + "(y,x) ] ],[(l2,x,subj,<<e,t>,t>),(l3,y,obj,<<e,t>,t>)],[ l2<l1,l3<l1,l4<scope(l2),l4<scope(l3) ],[" + symslot + "]>"}; + "<x,l1,t,[ l1:[|], l4:[ | SLOT_" + token + "(y,x) ] ],[(l2,x,subj,<<e,t>,t>),(l3,y,obj,<<e,t>,t>)],[ l2<l1,l3<l1,l4<scope(l2),l4<scope(l3) ],[" + symslot + "]>" + + " ;; <x,l1,t,[ l1:[|], l4:[ | empty(y,x) ] ],[(l2,x,subj,<<e,t>,t>),(l3,y,obj,<<e,t>,t>)],[ l2<l1,l3<l1,l4<scope(l2),l4<scope(l3) ],[]>"}; String[] passEntry2 = {token, "(S DP[wh] (VP DP[dp] V:'" + token + "'))", - "<x,l1,t,[ l1:[|], l4:[ | SLOT_" + token + "(x,y) ] ],[(l2,x,wh,<<e,t>,t>),(l3,y,dp,<<e,t>,t>)],[ l2<l1,l3<l1,l4<scope(l2),l4<scope(l3) ],[" + symslot + "]>"}; - String[] passEntry1empty = {token, - "(S DP[subj] (VP V:'" + token + "' DP[obj]))", - "<x,l1,t,[ l1:[|], l4:[ | empty(y,x) ] ],[(l2,x,subj,<<e,t>,t>),(l3,y,obj,<<e,t>,t>)],[ l2<l1,l3<l1,l4<scope(l2),l4<scope(l3) ],[]>"}; - String[] passEntry2empty = {token, - "(S DP[wh] (VP DP[dp] V:'" + token + "'))", - "<x,l1,t,[ l1:[|], l4:[ | empty(x,y) ] ],[(l2,x,wh,<<e,t>,t>),(l3,y,dp,<<e,t>,t>)],[ l2<l1,l3<l1,l4<scope(l2),l4<scope(l3) ],[]>"}; + "<x,l1,t,[ l1:[|], l4:[ | SLOT_" + token + "(x,y) ] ],[(l2,x,wh,<<e,t>,t>),(l3,y,dp,<<e,t>,t>)],[ l2<l1,l3<l1,l4<scope(l2),l4<scope(l3) ],[" + symslot + "]>" + + " ;; <x,l1,t,[ l1:[|], l4:[ | empty(x,y) ] ],[(l2,x,wh,<<e,t>,t>),(l3,y,dp,<<e,t>,t>)],[ l2<l1,l3<l1,l4<scope(l2),l4<scope(l3) ],[]>"}; result.add(passEntry1); result.add(passEntry2); - result.add(passEntry1empty); - result.add(passEntry2empty); } else if (pos.equals("PASSPART")) { String[] passpartEntry = {token, "(NP NP* (VP V:'" + token + "' DP[dp]))", - "<x,l1,t,[ l1:[ | SLOT_" + token + "(y,x) ] ],[(l2,y,dp,<<e,t>,t>)],[ l2=l1 ],[]>"}; - String[] passpartEntryEmpty = {token, - "(NP NP* (VP V:'" + token + "' DP[dp]))", - "<x,l1,t,[ l1:[ | empty(y,x) ] ],[(l2,y,dp,<<e,t>,t>)],[ l2=l1 ],[]>"}; + "<x,l1,t,[ l1:[ | SLOT_" + token + "(y,x) ] ],[(l2,y,dp,<<e,t>,t>)],[ l2=l1 ],[" + symslot + "]>" + + " ;; <x,l1,t,[ l1:[ | empty(y,x) ] ],[(l2,y,dp,<<e,t>,t>)],[ l2=l1 ],[]>"}; result.add(passpartEntry); - result.add(passpartEntryEmpty); } else if (pos.equals("VPASS")) { String[] passEntry = {token, "(S DP[subj] (VP V:'" + token + "'))", - "<x,l1,t,[ l1:[|], l4:[ | SLOT_" + token + "(y,x) ] ],[(l2,x,subj,<<e,t>,t>),(l3,y,obj,<<e,t>,t>)],[ l2<l1,l3<l1,l4<scope(l2),l4<scope(l3) ],[" + symslot + "]>"}; - String[] passEntryEmpty = {token, - "(S DP[subj] (VP V:'" + token + "'))", - "<x,l1,t,[ l1:[|], l4:[ | empty(y,x) ] ],[(l2,x,subj,<<e,t>,t>),(l3,y,obj,<<e,t>,t>)],[ l2<l1,l3<l1,l4<scope(l2),l4<scope(l3) ],[]>"}; + "<x,l1,t,[ l1:[|], l4:[ | SLOT_" + token + "(y,x) ] ],[(l2,x,subj,<<e,t>,t>),(l3,y,obj,<<e,t>,t>)],[ l2<l1,l3<l1,l4<scope(l2),l4<scope(l3) ],[" + symslot + "]>" + + " ;; <x,l1,t,[ l1:[|], l4:[ | empty(y,x) ] ],[(l2,x,subj,<<e,t>,t>),(l3,y,obj,<<e,t>,t>)],[ l2<l1,l3<l1,l4<scope(l2),l4<scope(l3) ],[]>"}; result.add(passEntry); - result.add(passEntryEmpty); } else if (pos.equals("VPASSIN")) { String[] passEntry1 = {token, @@ -237,68 +232,51 @@ else if (pos.equals("GERUNDIN")) { String[] gerundinEntry1 = {token, "(NP NP* V:'" + token + "' DP[obj]))", - "<x,l1,t,[ l1:[ | SLOT_" + token + "(x,y) ] ],[(l2,y,obj,<<e,t>,t>)],[ l2=l1 ],[" + symslot + "]>"}; + "<x,l1,t,[ l1:[ | SLOT_" + token + "(x,y) ] ],[(l2,y,obj,<<e,t>,t>)],[ l2=l1 ],[" + symslot + "]>" + + " ;; <x,l1,t,[ l1:[ | empty(x,y) ] ],[(l2,y,obj,<<e,t>,t>)],[ l2=l1 ],[]>"}; String[] gerundinEntry2 = {token, "(ADJ V:'" + token + "' DP[obj]))", - "<x,l1,<e,t>,[ l1:[ | SLOT_" + token + "(x,y) ] ],[(l2,y,obj,<<e,t>,t>)],[ l2=l1 ],[" + symslot + "]>"}; - String[] gerundinEntry1Empty = {token, - "(NP NP* V:'" + token + "' DP[obj]))", - "<x,l1,t,[ l1:[ | empty(x,y) ] ],[(l2,y,obj,<<e,t>,t>)],[ l2=l1 ],[]>"}; - String[] gerundinEntry2Empty = {token, - "(ADJ V:'" + token + "' DP[obj]))", - "<x,l1,<e,t>,[ l1:[ | empty(x,y) ] ],[(l2,y,obj,<<e,t>,t>)],[ l2=l1 ],[]>"}; + "<x,l1,<e,t>,[ l1:[ | SLOT_" + token + "(x,y) ] ],[(l2,y,obj,<<e,t>,t>)],[ l2=l1 ],[" + symslot + "]>" + + " ;; <x,l1,<e,t>,[ l1:[ | empty(x,y) ] ],[(l2,y,obj,<<e,t>,t>)],[ l2=l1 ],[]>"}; result.add(gerundinEntry1); result.add(gerundinEntry2); - result.add(gerundinEntry1Empty); - result.add(gerundinEntry2Empty); } else if (pos.equals("VPREP")) { String[] passEntry = {token, "(S DP[subj] (VP V:'" + token + "' DP[obj]))", - "<x,l1,t,[ l1:[|], l4:[ | 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) ],[" + symslot + "]>"}; + "<x,l1,t,[ l1:[|], l4:[ | 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) ],[" + symslot + "]>" + + " ;; <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) ],[]>"}; String[] whEntry = {token, "(S DP[obj] (VP DP[subj] V:'" + token + "'))", - "<x,l1,t,[ l1:[|], l4:[ | 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) ],[" + symslot + "]>"}; - String[] passEntryEmpty = {token, - "(S DP[subj] (VP V:'" + token + "' DP[obj]))", - "<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) ],[]>"}; - String[] whEntryEmpty = {token, - "(S DP[obj] (VP DP[subj] V:'" + token + "'))", - "<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) ],[]>"}; + "<x,l1,t,[ l1:[|], l4:[ | 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) ],[" + symslot + "]>" + + " ;; <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(passEntry); result.add(whEntry); - result.add(passEntryEmpty); - result.add(whEntryEmpty); } else if (pos.equals("VBD") || pos.equals("VBZ") || pos.equals("VBP")) { String[] vEntry = {token, "(S DP[subj] (VP V:'" + token + "' DP[obj]))", - "<x,l1,t,[ l1:[|], l4:[ | 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) ],[" + symslot + "]>"}; - String[] vEntryEmpty = {token, - "(S DP[subj] (VP V:'" + token + "' DP[obj]))", - "<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) ],[]>"}; + "<x,l1,t,[ l1:[|], l4:[ | 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) ],[" + symslot + "]>" + + " ;; <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(vEntry); - result.add(vEntryEmpty); } else if (pos.equals("VB")) { String[] whEntry = {token, "(S DP[obj] (VP DP[subj] V:'" + token + "'))", - "<x,l1,t,[ l1:[|], l4:[ | 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) ],[" + symslot + "]>"}; - String[] whEntryEmpty = {token, - "(S DP[obj] (VP DP[subj] V:'" + token + "'))", - "<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) ],[]>"}; + "<x,l1,t,[ l1:[|], l4:[ | 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) ],[" + symslot + "]>" + + " ;; <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); - result.add(whEntryEmpty); } else if (pos.equals("VBG") || pos.equals("VBN")) { String[] gerEntry = {token, "(NP NP* (VP V:'" + token + "' DP[dp]))", - "<x,l1,t,[ l1:[ | SLOT_" + token + "(x,y) ] ],[(l2,y,dp,<<e,t>,t>)],[ l2=l1 ],[" + symslot + "]>"}; - String[] gerEntryEmpty = {token, - "(NP NP* (VP V:'" + token + "' DP[dp]))", - "<x,l1,t,[ l1:[ | empty(x,y) ] ],[(l2,y,dp,<<e,t>,t>)],[ l2=l1 ],[]>"}; + "<x,l1,t,[ l1:[ | SLOT_" + token + "(x,y) ] ],[(l2,y,dp,<<e,t>,t>)],[ l2=l1 ],[" + symslot + "]>" + + " ;; <x,l1,t,[ l1:[ | empty(x,y) ] ],[(l2,y,dp,<<e,t>,t>)],[ l2=l1 ],[]>"}; + String[] wasGerEntry = {token, + "(S DP[comp] (VP V:'was' DP[subject] V:'" + token + "'))", + "<y,l1,t,[ l1:[ | SLOT_" + token + "(y,z) ] ],[(l2,y,comp,<<e,t>,t>), (l3,z,subject,<<e,t>,t>) ],[ l2=l1, l3=l1 ],[" + symslot + "]>"}; result.add(gerEntry); - result.add(gerEntryEmpty); + result.add(wasGerEntry); } else if (pos.equals("WHEN")) { String dateSlot = "SLOT_" + token + "/PROPERTY/" + token + "Date"; @@ -347,8 +325,8 @@ result.add(adjEntry); } if (pos.equals("JJH")) { - String[] howEntry = {"how "+token, - "(DP WH:'how' ADJ:'" + token.toLowerCase() + "')", + String[] howEntry = {token, + "(DP WH:'" + token.toLowerCase() + "')", "<x,l1,<<e,t>,t>,[ l1:[ ?j,x | SLOT_" + token + "(x,j) ] ],[],[],["+slot+"]>"}; result.add(howEntry); } @@ -393,15 +371,17 @@ } /* PREPOSITIONS */ else if (equalsOneOf(pos,preps)) { - String slot = "SLOT_" + token + "/SYMPROPERTY/"; + String slot = "SLOT_" + token + "/SYMPROPERTY/" + token; String[] npAdjunct = {token, "(NP NP* (PP P:'" + token.toLowerCase() + "' DP[pobj]))", - "<x,l1,<e,t>,[ l1:[ | SLOT_" + token + "(x,y) ] ],[(l2,y,pobj,<<e,t>,t>)],[l2=l1],["+slot+"]>"}; - String[] npAdjunctEmpty = {token, - "(NP NP* (PP P:'" + token.toLowerCase() + "' DP[pobj]))", - "<x,l1,<e,t>,[ l1:[ | empty(x,y) ] ],[(l2,y,pobj,<<e,t>,t>)],[l2=l1],[]>"}; + "<x,l1,<e,t>,[ l1:[ | SLOT_" + token + "(x,y) ] ],[(l2,y,pobj,<<e,t>,t>)],[l2=l1],["+slot+"]>" + + " ;; <x,l1,<e,t>,[ l1:[ | empty(x,y) ] ],[(l2,y,pobj,<<e,t>,t>)],[l2=l1],[]>"}; + String[] vpAdjunct = {token, + "(VP VP* (PP P:'" + token.toLowerCase() + "' DP[pobj]))", + "<x,l1,t,[ l1:[ | SLOT_" + token + "(x,y) ] ],[(l2,y,pobj,<<e,t>,t>)],[l2=l1],["+slot+"]>" + + " ;; <x,l1,t,[ l1:[ | empty(x,y) ] ],[(l2,y,pobj,<<e,t>,t>)],[l2=l1],[]>"}; result.add(npAdjunct); - result.add(npAdjunctEmpty); + result.add(vpAdjunct); } } Modified: trunk/components-ext/src/main/resources/tbsl/evaluation/dbpedia-test-questions-tagged(ideal).xml =================================================================== --- trunk/components-ext/src/main/resources/tbsl/evaluation/dbpedia-test-questions-tagged(ideal).xml 2011-10-31 09:29:27 UTC (rev 3342) +++ trunk/components-ext/src/main/resources/tbsl/evaluation/dbpedia-test-questions-tagged(ideal).xml 2011-10-31 09:33:13 UTC (rev 3343) @@ -60,7 +60,7 @@ <string>What/WP is/VBZ the/DT revenue/NN of/IN IBM/NNP</string> </question> <question id="38"> -<string>Which/WDT states/VBZ border/VBZ Utah/NNP</string> +<string>Which/WDT states/NNS border/VBZ Utah/NNP</string> </question> <question id="13"> <string>In/IN which/WDT country/NN is/VBZ the/DT Limerick/NNP Lake/NNP</string> Modified: trunk/components-ext/src/main/resources/tbsl/lexicon/english.lex =================================================================== --- trunk/components-ext/src/main/resources/tbsl/lexicon/english.lex 2011-10-31 09:29:27 UTC (rev 3342) +++ trunk/components-ext/src/main/resources/tbsl/lexicon/english.lex 2011-10-31 09:33:13 UTC (rev 3343) @@ -18,8 +18,8 @@ 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 ],[]> - is there || (S DP[dp] V:'is' C:'there') || <x, l1, t, [ l1:[ | ] ], [ (l2,x,dp,<<e,t>,t>) ], [ l2=l1 ],[]> - are there || (S DP[dp] V:'are' C:'there') || <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 ],[]> // TO BE: YES/NO QUESTIONS @@ -93,7 +93,7 @@ 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],[]> + // how || (DP DET:'how' ADJ[adj]) || <x,l1,<<e,t>,t>,[ l1:[?x,|] ],[ (x,l2,adj,<e,t>) ],[l2=l1],[]> // EMPTY STUFF This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2011-10-31 14:14:41
|
Revision: 3344 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=3344&view=rev Author: christinaunger Date: 2011-10-31 14:14:31 +0000 (Mon, 31 Oct 2011) Log Message: ----------- [tbsl] fixes for dbpedia:train Modified Paths: -------------- 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/templator/SlotBuilder.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/ltag/parser/GrammarFilter.java =================================================================== --- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/ltag/parser/GrammarFilter.java 2011-10-31 09:33:13 UTC (rev 3343) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/ltag/parser/GrammarFilter.java 2011-10-31 14:14:31 UTC (rev 3344) @@ -299,8 +299,11 @@ semName = semName.substring(1); out.add(new Pair<String,String>("(NP NP* ADJ:'"+ w +"' " + rawNames + ")", "<x,l1,<e,t>,[ l1:[ y | SLOT_title(x,y), regex(y,'" + semName + "') ] ], [],[],[ SLOT_title/PROPERTY/title^name ]>")); + out.add(new Pair<String,String>("(NP NP* ADJ:'"+ w +"' " + rawNames + ")", "<x,l1,<e,t>,[ l1:[|] ],[],[],[ x/RESOURCE/"+semName+"]>")); out.add(new Pair<String,String>("(DP DP* ADJ:'"+ w +"' " + rawNames + ")", "<x,l1,<<e,t>,t>,[ l1:[ y | SLOT_title(x,y), regex(y,'" + semName + "') ] ], [],[],[ SLOT_title/PROPERTY/title^name ]>")); + out.add(new Pair<String,String>("(DP DP* ADJ:'"+ w +"' " + rawNames + ")", "<x,l1,<<e,t>,t>,[ l1:[|] ],[],[],[ x/RESOURCE/"+semName+"]>")); out.add(new Pair<String,String>("(ADJ ADJ:'"+ w +"' " + rawNames + ")", "<x,l1,<e,t>,[ l1:[ y | SLOT_title(x,y), regex(y,'" + semName + "') ] ], [],[],[ SLOT_title/PROPERTY/title^name ]>")); + out.add(new Pair<String,String>("(ADJ ADJ:'"+ w +"' " + rawNames + ")", "<x,l1,<e,t>,[ l1:[|] ],[],[],[ x/RESOURCE/"+semName+"]>")); return out; 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 2011-10-31 09:33:13 UTC (rev 3343) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/ltag/parser/Preprocessor.java 2011-10-31 14:14:31 UTC (rev 3344) @@ -227,18 +227,22 @@ m = nnpPattern.matcher(flat); while (m.find()) { flat = flat.replaceFirst(m.group(1),m.group(2) + "_" + m.group(3)); + m = nnpPattern.matcher(flat); } m = nnpPattern.matcher(flat); while (m.find()) { flat = flat.replaceFirst(m.group(1),m.group(2) + "_" + m.group(3)); + m = nnpPattern.matcher(flat); } m = nnPattern.matcher(flat); while (m.find()) { flat = flat.replaceFirst(m.group(1),m.group(2) + "_" + m.group(3)); + m = nnPattern.matcher(flat); } m = nnnnpPattern.matcher(flat); while (m.find()) { flat = flat.replaceFirst(m.group(1),m.group(2) + "/JJ"); + m = nnnnpPattern.matcher(flat); } return flat; Modified: trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/templator/SlotBuilder.java =================================================================== --- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/templator/SlotBuilder.java 2011-10-31 09:33:13 UTC (rev 3343) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/templator/SlotBuilder.java 2011-10-31 14:14:31 UTC (rev 3344) @@ -246,11 +246,15 @@ "(S DP[subj] (VP V:'" + token + "' DP[obj]))", "<x,l1,t,[ l1:[|], l4:[ | 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) ],[" + symslot + "]>" + " ;; <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) ],[]>"}; + String[] passEntry2 = {token, + "(S DP[subj] (VP V:'" + token + "' NUM[num]))", + "<x,l1,t,[ l1:[|], l4:[ y | SLOT_" + token + "(x,y), DATE(y,z) ] ],[(l2,x,subj,<<e,t>,t>),(l3,z,num,e)],[ l2<l1,l3<l1,l4<scope(l2),l4<scope(l3) ],[" + symslot + "]>"}; String[] whEntry = {token, "(S DP[obj] (VP DP[subj] V:'" + token + "'))", "<x,l1,t,[ l1:[|], l4:[ | 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) ],[" + symslot + "]>" + " ;; <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(passEntry); + result.add(passEntry2); result.add(whEntry); } else if (pos.equals("VBD") || pos.equals("VBZ") || pos.equals("VBP")) { @@ -279,7 +283,7 @@ result.add(wasGerEntry); } else if (pos.equals("WHEN")) { - String dateSlot = "SLOT_" + token + "/PROPERTY/" + token + "Date"; + String dateSlot = "SLOT_" + token + "/PROPERTY/" + token +"^" + token + "_date"; String tokenSlot = "SLOT_" + token + "/PROPERTY/" + token; String[] whenEntry1 = {token, "(S DP[subj] (VP V:'" + token + "'))", @@ -292,7 +296,7 @@ result.add(whenEntry2); } else if (pos.equals("WHERE")) { - String placeSlot = "SLOT_" + token + "/PROPERTY/" + token + "Place"; + String placeSlot = "SLOT_" + token + "/PROPERTY/" + token + "^" + token + "_place"; String tokenSlot = "SLOT_" + token + "/PROPERTY/" + token; String[] whereEntry1 = {token, "(S DP[subj] (VP V:'" + token + "'))", 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-31 09:33:13 UTC (rev 3343) +++ trunk/components-ext/src/main/resources/tbsl/evaluation/dbpedia-train-tagged(ideal).xml 2011-10-31 14:14:31 UTC (rev 3344) @@ -1958,7 +1958,7 @@ </answers> </question> <question id="10"> -<string>Who/WP was/VBD the/DT wife/NN of/IN President/NNP Lincoln/NNP</string> +<string>Who/WP was/VBD the/DT wife/NN of/IN president/NN Lincoln/NNP</string> <query> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> @@ -1985,7 +1985,7 @@ </answers> </question> <question id="9"> -<string>Who/WP developed/VBD the/DT video/NN game/NN World/NN of/IN Warcraft/NNP</string> +<string>Who/WP developed/VBD the/DT video/NN game/NN World/NNP of/NNP Warcraft/NNP</string> <query> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> @@ -25473,7 +25473,7 @@ </answers> </question> <question id="17"> -<string>In/IN which/WDT programming/NN language/NN is/VBZ GIMP/RB written/VBN</string> +<string>In/IN which/WDT programming/NN language/NN is/VBZ GIMP/NNP written/VBN</string> <query> PREFIX prop: <http://dbpedia.org/property/> PREFIX res: <http://dbpedia.org/resource/> Modified: trunk/components-ext/src/main/resources/tbsl/lexicon/english.lex =================================================================== --- trunk/components-ext/src/main/resources/tbsl/lexicon/english.lex 2011-10-31 09:33:13 UTC (rev 3343) +++ trunk/components-ext/src/main/resources/tbsl/lexicon/english.lex 2011-10-31 14:14:31 UTC (rev 3344) @@ -86,7 +86,7 @@ the least || (DET DET:'the' DET:'least') || <y, l1, e, [ l1:[ | l2:[ y | ] THELEAST y l3:[|] ] ], [], [],[]> // CHEAT! - highest || (NP ADJ:'highest' NP*) || <x, l1, e, [ l1:[ | maximum(a,x,x) ] ], [], [],[]> ;; <x, l1, e, [ l1:[ | SLOT_high(x), maximum(a,x,x) ] ],[],[],[ SLOT_high/PROPERTY/height^elevation ]> + highest || (NP ADJ:'highest' NP*) || <x, l1, e, [ l1:[ | maximum(a,x,x) ] ], [], [],[]> ;; <x, l1, e, [ l1:[ j | SLOT_high(x,j), maximum(a,j,j) ] ],[],[],[ SLOT_high/PROPERTY/height^elevation ]> // COUNT 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],[]> @@ -158,7 +158,7 @@ there || (DP (NP EX:'there')) || <x,l1,<<e,t>,t>,[l1:[|]],[],[],[]> -// ORDINAL NUMBERS (1-10) +// NUMBERS (1-10) // --------------------- one || (NP NUM:'one' NP*) || <x,l1,<e,t>,[l1:[x|count(x,1)]],[],[],[]> @@ -181,4 +181,4 @@ seven || (NUM NUM:'seven') || <x,l1,e,[l1:[x|equal(x,7)]],[],[],[]> eight || (NUM NUM:'eight') || <x,l1,e,[l1:[x|equal(x,8)]],[],[],[]> nine || (NUM NUM:'nine') || <x,l1,e,[l1:[x|equal(x,9)]],[],[],[]> - ten || (NUM NUM:'ten') || <x,l1,e,[l1:[x|equal(x,10)]],[],[],[]> + ten || (NUM NUM:'ten') || <x,l1,e,[l1:[x|equal(x,10)]],[],[],[]> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2011-11-03 19:32:31
|
Revision: 3371 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=3371&view=rev Author: christinaunger Date: 2011-11-03 19:32:25 +0000 (Thu, 03 Nov 2011) Log Message: ----------- [tbsl] yet another two bug fixes (template generation) Modified Paths: -------------- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/ltag/parser/GrammarFilter.java trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/templator/SlotBuilder.java trunk/components-ext/src/main/resources/tbsl/lexicon/english.lex 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 2011-11-03 17:28:10 UTC (rev 3370) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/ltag/parser/GrammarFilter.java 2011-11-03 19:32:25 UTC (rev 3371) @@ -298,11 +298,11 @@ } semName = semName.substring(1); - out.add(new Pair<String,String>("(NP NP* ADJ:'"+ w +"' " + rawNames + ")", "<x,l1,<e,t>,[ l1:[ y | SLOT_title(x,y), regex(y,'" + semName + "') ] ], [],[],[ SLOT_title/PROPERTY/title^name ]>")); + out.add(new Pair<String,String>("(NP NP* ADJ:'"+ w +"' " + rawNames + ")", "<x,l1,<e,t>,[ l1:[ y | SLOT_title(x,y), regex(y,'" + semName + "') ] ], [],[],[ SLOT_title/PROPERTY/title^name^label ]>")); out.add(new Pair<String,String>("(NP NP* ADJ:'"+ w +"' " + rawNames + ")", "<x,l1,<e,t>,[ l1:[|] ],[],[],[ x/RESOURCE/"+semName+"]>")); - out.add(new Pair<String,String>("(DP DP* ADJ:'"+ w +"' " + rawNames + ")", "<x,l1,<<e,t>,t>,[ l1:[ y | SLOT_title(x,y), regex(y,'" + semName + "') ] ], [],[],[ SLOT_title/PROPERTY/title^name ]>")); + out.add(new Pair<String,String>("(DP DP* ADJ:'"+ w +"' " + rawNames + ")", "<x,l1,<<e,t>,t>,[ l1:[ y | SLOT_title(x,y), regex(y,'" + semName + "') ] ], [],[],[ SLOT_title/PROPERTY/title^name^label ]>")); out.add(new Pair<String,String>("(DP DP* ADJ:'"+ w +"' " + rawNames + ")", "<x,l1,<<e,t>,t>,[ l1:[|] ],[],[],[ x/RESOURCE/"+semName+"]>")); - out.add(new Pair<String,String>("(ADJ ADJ:'"+ w +"' " + rawNames + ")", "<x,l1,<e,t>,[ l1:[ y | SLOT_title(x,y), regex(y,'" + semName + "') ] ], [],[],[ SLOT_title/PROPERTY/title^name ]>")); + out.add(new Pair<String,String>("(ADJ ADJ:'"+ w +"' " + rawNames + ")", "<x,l1,<e,t>,[ l1:[ y | SLOT_title(x,y), regex(y,'" + semName + "') ] ], [],[],[ SLOT_title/PROPERTY/title^name^label ]>")); out.add(new Pair<String,String>("(ADJ ADJ:'"+ w +"' " + rawNames + ")", "<x,l1,<e,t>,[ l1:[|] ],[],[],[ x/RESOURCE/"+semName+"]>")); return out; Modified: trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/templator/SlotBuilder.java =================================================================== --- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/templator/SlotBuilder.java 2011-11-03 17:28:10 UTC (rev 3370) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/templator/SlotBuilder.java 2011-11-03 19:32:25 UTC (rev 3371) @@ -261,7 +261,8 @@ String[] vEntry = {token, "(S DP[subj] (VP V:'" + token + "' DP[obj]))", "<x,l1,t,[ l1:[|], l4:[ | 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) ],[" + symslot + "]>" + - " ;; <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) ],[]>"}; + " ;; <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) ],[]>" + + " ;; <x,l1,t,[ l1:[|], l4:[ | empty(y,x) ] ],[(l2,x,subj,<<e,t>,t>),(l3,y,obj,<<e,t>,t>)],[ l2<l1,l3<l1,l4<scope(l2),l4<scope(l3) ],[]>"}; result.add(vEntry); } else if (pos.equals("VB")) { Modified: trunk/components-ext/src/main/resources/tbsl/lexicon/english.lex =================================================================== --- trunk/components-ext/src/main/resources/tbsl/lexicon/english.lex 2011-11-03 17:28:10 UTC (rev 3370) +++ trunk/components-ext/src/main/resources/tbsl/lexicon/english.lex 2011-11-03 19:32:25 UTC (rev 3371) @@ -69,7 +69,6 @@ at least || (DP DET:'at' DET:'least' NUM[num] NP[noun]) || <y,l1,<<e,t>,t>,[l1:[ y,j |count(a,y,j), greaterorequal(j,x) ]],[(l2,y,noun,<e,t>),(l3,x,num,e)],[ l1=l2, l2=l3 ],[]> at most || (DP DET:'at' DET:'most' NUM[num] NP[noun]) || <y,l1,<<e,t>,t>,[l1:[ y,j | count(a,y,j), smallerorequal(j,x) ]],[(l2,y,noun,<e,t>),(l3,x,num,e)],[ l1=l2, l2=l3 ],[]> exactly || (DP DET:'exactly' NUM[num] NP[noun]) || <y,l1,<<e,t>,t>,[l1:[ y,j | count(y,j), equals(j,x) ]],[(l2,y,noun,<e,t>),(l3,x,num,e)],[ l1=l2, l2=l3 ],[]> - s || (DP DP* DET:'s' NP[noun]) || - other || (NP ADJ:'other' NP*) || <x,l1,<e,t>,[ l1:[ | ] ], [],[],[]> total || (NP ADJ:'total' NP[np]) || <s,l1,<e,t>,[ l1:[ ?s | sum(a,x,s) ] ], [ (l2,x,np,<e,t>) ],[ l2=l1 ],[]> @@ -86,7 +85,7 @@ the least || (DET DET:'the' DET:'least') || <y, l1, e, [ l1:[ | l2:[ y | ] THELEAST y l3:[|] ] ], [], [],[]> // CHEAT! - highest || (NP ADJ:'highest' NP*) || <x, l1, e, [ l1:[ | maximum(a,x,x) ] ], [], [],[]> ;; <x, l1, e, [ l1:[ j | SLOT_high(x,j), maximum(a,j,j) ] ],[],[],[ SLOT_high/PROPERTY/height^elevation ]> + highest || (NP ADJ:'highest' NP*) || <x, l1, e, [ l1:[ | maximum(x) ] ], [], [],[]> ;; <x, l1, e, [ l1:[ j | SLOT_high(x,j), maximum(j) ] ],[],[],[ SLOT_high/PROPERTY/height^elevation ]> // COUNT 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],[]> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2011-11-09 10:02:17
|
Revision: 3390 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=3390&view=rev Author: christinaunger Date: 2011-11-09 10:02:03 +0000 (Wed, 09 Nov 2011) Log Message: ----------- [tbsl] update BasicSlotBuilder 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/templator/BasicSlotBuilder.java trunk/components-ext/src/main/resources/tbsl/lexicon/english.lex 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 2011-11-08 13:59:11 UTC (rev 3389) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/converter/DRS2BasicSPARQL_Converter.java 2011-11-09 10:02:03 UTC (rev 3390) @@ -23,6 +23,7 @@ import org.dllearner.algorithm.tbsl.sparql.SPARQL_QueryType; import org.dllearner.algorithm.tbsl.sparql.SPARQL_Term; import org.dllearner.algorithm.tbsl.sparql.Slot; +import org.dllearner.algorithm.tbsl.sparql.SlotType; public class DRS2BasicSPARQL_Converter { @@ -56,8 +57,13 @@ } private BasicQueryTemplate convert(DRS drs, BasicQueryTemplate temp, boolean negate) { - + +// System.out.println("--- DRS (before): " + drs); // DEBUG redundantEqualRenaming(drs); + if (!restructureEmpty(drs)) { + return null; + } + System.out.println("--- DRS (after) : " + drs); // DEBUG for (DRS_Condition condition : drs.getConditions()) { convertCondition(condition,temp); @@ -359,4 +365,71 @@ usedInts.add(fresh); return fresh; } + + private boolean 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); + } + } + if (emptyConditions.isEmpty()) { + return true; + } + + boolean globalsuccess = false; + for (Simple_DRS_Condition c : emptyConditions) { + String nounToExpand = c.getArguments().get(1).getValue(); + String fallbackNoun = c.getArguments().get(0).getValue(); + boolean success = false; + loop: + for (Simple_DRS_Condition sc : drs.getAllSimpleConditions()) { + if (sc.getArguments().size() == 1 && sc.getArguments().get(0).getValue().equals(nounToExpand)) { + for (Slot s : slots) { + if (s.getAnchor().equals(sc.getPredicate())) { + if (s.getSlotType().equals(SlotType.CLASS) || s.getSlotType().equals(SlotType.UNSPEC)) { + s.setSlotType(SlotType.PROPERTY); + List<DiscourseReferent> newargs = new ArrayList<DiscourseReferent>(); + newargs.add(c.getArguments().get(0)); + newargs.add(sc.getArguments().get(0)); + sc.setArguments(newargs); + success = true; + globalsuccess = true; + break loop; + } + } + } + } + } + if (!success) { // do the same for fallbackNoun + loop: + for (Simple_DRS_Condition sc : drs.getAllSimpleConditions()) { + if (sc.getArguments().size() == 1 && sc.getArguments().get(0).getValue().equals(fallbackNoun)) { + for (Slot s : slots) { + if (s.getAnchor().equals(sc.getPredicate())) { + if (s.getSlotType().equals(SlotType.CLASS) || s.getSlotType().equals(SlotType.UNSPEC)) { + s.setSlotType(SlotType.PROPERTY); + List<DiscourseReferent> newargs = new ArrayList<DiscourseReferent>(); + newargs.add(c.getArguments().get(1)); + newargs.add(sc.getArguments().get(0)); + sc.setArguments(newargs); + success = true; + globalsuccess = true; + break loop; + } + } + } + } + } + } + } + + if (globalsuccess) { + for (Simple_DRS_Condition c : emptyConditions) { + drs.removeCondition(c); + } + } + return globalsuccess; + } } 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 2011-11-08 13:59:11 UTC (rev 3389) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/templator/BasicSlotBuilder.java 2011-11-09 10:02:03 UTC (rev 3390) @@ -136,23 +136,27 @@ if (pos.equals("PASSIVE")) { String[] passEntry1 = {token, "(S DP[subj] (VP V:'" + token + "' DP[obj]))", - "<x,l1,t,[ l1:[|], l4:[ p | SLOT_" + token + "(p), p(y,x) ] ],[(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:[ p | SLOT_" + token + "(p), p(y,x) ] ],[(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(y,x) ] ],[(l2,x,subj,<<e,t>,t>),(l3,y,obj,<<e,t>,t>)],[ l2<l1,l3<l1,l4<scope(l2),l4<scope(l3) ],[]>"}; String[] passEntry2 = {token, "(S DP[wh] (VP DP[dp] V:'" + token + "'))", - "<x,l1,t,[ l1:[|], l4:[ p | SLOT_" + token + "(p), p(y,x) ] ],[(l2,x,wh,<<e,t>,t>),(l3,y,dp,<<e,t>,t>)],[ l2<l1,l3<l1,l4<scope(l2),l4<scope(l3) ],[" + slot + "]>"}; + "<x,l1,t,[ l1:[|], l4:[ p | SLOT_" + token + "(p), p(y,x) ] ],[(l2,x,wh,<<e,t>,t>),(l3,y,dp,<<e,t>,t>)],[ l2<l1,l3<l1,l4<scope(l2),l4<scope(l3) ],[" + slot + "]>" + + " ;; <x,l1,t,[ l1:[|], l4:[ | empty(x,y) ] ],[(l2,x,wh,<<e,t>,t>),(l3,y,dp,<<e,t>,t>)],[ l2<l1,l3<l1,l4<scope(l2),l4<scope(l3) ],[]>"}; result.add(passEntry1); result.add(passEntry2); } else if (pos.equals("PASSPART")) { String[] passpartEntry = {token, "(NP NP* (VP V:'" + token + "' DP[dp]))", - "<x,l1,t,[ l1:[ p | SLOT_" + token + "(p), p(y,x) ] ],[(l2,y,dp,<<e,t>,t>)],[ l2=l1 ],[" + slot + "]>"}; + "<x,l1,t,[ l1:[ p | SLOT_" + token + "(p), p(y,x) ] ],[(l2,y,dp,<<e,t>,t>)],[ l2=l1 ],[" + slot + "]>" + + " ;; <x,l1,t,[ l1:[ | empty(y,x) ] ],[(l2,y,dp,<<e,t>,t>)],[ l2=l1 ],[]>"}; result.add(passpartEntry); } else if (pos.equals("VPASS")) { String[] passEntry = {token, "(S DP[subj] (VP V:'" + token + "'))", - "<x,l1,t,[ l1:[|], l4:[ p | SLOT_" + token + "(p), p(y,x) ] ],[(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:[ p | SLOT_" + token + "(p), p(y,x) ] ],[(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(y,x) ] ],[(l2,x,subj,<<e,t>,t>),(l3,y,obj,<<e,t>,t>)],[ l2<l1,l3<l1,l4<scope(l2),l4<scope(l3) ],[]>"}; result.add(passEntry); } else if (pos.equals("VPASSIN")) { @@ -164,39 +168,51 @@ else if (pos.equals("GERUNDIN")) { String[] gerundinEntry1 = {token, "(NP NP* V:'" + token + "' DP[obj]))", - "<x,l1,t,[ l1:[ p | SLOT_" + token + "(p), p(y,x) ] ],[(l2,y,obj,<<e,t>,t>)],[ l2=l1 ],[" + slot + "]>"}; + "<x,l1,t,[ l1:[ p | SLOT_" + token + "(p), p(y,x) ] ],[(l2,y,obj,<<e,t>,t>)],[ l2=l1 ],[" + slot + "]>" + + " ;; <x,l1,t,[ l1:[ | empty(x,y) ] ],[(l2,y,obj,<<e,t>,t>)],[ l2=l1 ],[]>"}; String[] gerundinEntry2 = {token, "(ADJ V:'" + token + "' DP[obj]))", - "<x,l1,<e,t>,[ l1:[ p | SLOT_" + token + "(p), p(y,x) ] ],[(l2,y,obj,<<e,t>,t>)],[ l2=l1 ],[" + slot + "]>"}; + "<x,l1,<e,t>,[ l1:[ p | SLOT_" + token + "(p), p(y,x) ] ],[(l2,y,obj,<<e,t>,t>)],[ l2=l1 ],[" + slot + "]>" + + " ;; <x,l1,<e,t>,[ l1:[ | empty(x,y) ] ],[(l2,y,obj,<<e,t>,t>)],[ l2=l1 ],[]>"}; result.add(gerundinEntry1); result.add(gerundinEntry2); } else if (pos.equals("VPREP")) { String[] passEntry = {token, "(S DP[subj] (VP V:'" + token + "' DP[obj]))", - "<x,l1,t,[ l1:[|], l4:[ p | SLOT_" + token + "(p), p(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:[ p | SLOT_" + token + "(p), p(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) ],[]>"}; String[] whEntry = {token, "(S DP[obj] (VP DP[subj] V:'" + token + "'))", - "<x,l1,t,[ l1:[|], l4:[ p | SLOT_" + token + "(p), p(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:[ p | SLOT_" + token + "(p), p(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(passEntry); result.add(whEntry); } else if (pos.equals("VBD") || pos.equals("VBZ") || pos.equals("VBP")) { String[] vEntry = {token, "(S DP[subj] (VP V:'" + token + "' DP[obj]))", - "<x,l1,t,[ l1:[|], l4:[ p | SLOT_" + token + "(p), p(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:[ p | SLOT_" + token + "(p), p(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) ],[]>" + + " ;; <x,l1,t,[ l1:[|], l4:[ | empty(y,x) ] ],[(l2,x,subj,<<e,t>,t>),(l3,y,obj,<<e,t>,t>)],[ l2<l1,l3<l1,l4<scope(l2),l4<scope(l3) ],[]>"}; result.add(vEntry); } else if (pos.equals("VB")) { String[] whEntry = {token, "(S DP[obj] (VP DP[subj] V:'" + token + "'))", - "<x,l1,t,[ l1:[|], l4:[ p | SLOT_" + token + "(p), p(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:[ p | SLOT_" + token + "(p), p(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); } else if (pos.equals("VBG") || pos.equals("VBN")) { String[] gerEntry = {token, "(NP NP* (VP V:'" + token + "' DP[dp]))", - "<x,l1,t,[ l1:[ p | SLOT_" + token + "(p), p(x,y) ] ],[(l2,y,dp,<<e,t>,t>)],[ l2=l1 ],[" + slot + "]>"}; + "<x,l1,t,[ l1:[ p | SLOT_" + token + "(p), p(x,y) ] ],[(l2,y,dp,<<e,t>,t>)],[ l2=l1 ],[" + slot + "]>" + + ";; <x,l1,t,[ l1:[ | empty(x,y) ] ],[(l2,y,dp,<<e,t>,t>)],[ l2=l1 ],[]>"}; + String[] wasGerEntry = {token, + "(S DP[comp] (VP V:'was' DP[subject] V:'" + token + "'))", + "<y,l1,t,[ l1:[ | SLOT_" + token + "(p), p(y,z) ] ],[(l2,y,comp,<<e,t>,t>), (l3,z,subject,<<e,t>,t>) ],[ l2=l1, l3=l1 ],[" + slot + "]>"}; + result.add(wasGerEntry); result.add(gerEntry); } else if (pos.equals("WHEN")) { @@ -275,8 +291,14 @@ else if (equalsOneOf(pos,preps)) { String[] npAdjunct = {token, "(NP NP* (PP P:'" + token.toLowerCase() + "' DP[pobj]))", - "<x,l1,<e,t>,[ l1:[ | SLOT_" + token + "(p), p(x,y) ] ],[(l2,y,pobj,<<e,t>,t>)],[l2=l1],[]>"}; + "<x,l1,<e,t>,[ l1:[ | SLOT_" + token + "(p), p(x,y) ] ],[(l2,y,pobj,<<e,t>,t>)],[l2=l1],[]>" + + " ;; <x,l1,<e,t>,[ l1:[ | empty(x,y) ] ],[(l2,y,pobj,<<e,t>,t>)],[l2=l1],[]>"}; + String[] vpAdjunct = {token, + "(VP VP* (PP P:'" + token.toLowerCase() + "' DP[pobj]))", + "<x,l1,t,[ l1:[ | SLOT_" + token + "(p), p(x,y) ] ],[(l2,y,pobj,<<e,t>,t>)],[l2=l1],[]>" + + " ;; <x,l1,t,[ l1:[ | empty(x,y) ] ],[(l2,y,pobj,<<e,t>,t>)],[l2=l1],[]>"}; result.add(npAdjunct); + result.add(vpAdjunct); } } Modified: trunk/components-ext/src/main/resources/tbsl/lexicon/english.lex =================================================================== --- trunk/components-ext/src/main/resources/tbsl/lexicon/english.lex 2011-11-08 13:59:11 UTC (rev 3389) +++ trunk/components-ext/src/main/resources/tbsl/lexicon/english.lex 2011-11-09 10:02:03 UTC (rev 3390) @@ -117,6 +117,7 @@ which || (DP WH:'which') || <x, l1, <<e,t>,t>, [ l1:[ ?x | ] ], [], [], []> how many || (DP WH:'how' ADJ:'many' NP[noun]) || <y, l1, <<e,t>,t>, [ l1:[ | l2:[ y | ] HOWMANY y l3:[|] ] ], [ (l4,y,noun,<e,t>) ], [ l4=l2 ],[]> who || (DP WH:'who') || <x, l1, <<e,t>,t>, [ l1:[ ?x | ] ], [], [], []> + whom || (DP WH:'whom') || <x, l1, <<e,t>,t>, [ l1:[ ?x | ] ], [], [], []> when || (S WH:'when' S[s]) || <x, l1, t, [ l1:[ ?x | SLOT_p(y,x) ] ], [(l2,y,s,t)], [l2=l1], [ SLOT_p/PROPERTY/date ]> when || (DP WH:'when') || <y, l1, <<e,t>,t>, [ l1:[ ?x | SLOT_p(y,x) ] ], [], [], [ SLOT_p/PROPERTY/date ]> where || (S WH:'where' S[s]) || <x, l1, t, [ l1:[ ?x | SLOT_p(y,x) ] ], [(l2,y,s,t)], [l2=l1], [ SLOT_p/PROPERTY/place ]> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2012-01-05 13:54:14
|
Revision: 3527 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=3527&view=rev Author: christinaunger Date: 2012-01-05 13:54:07 +0000 (Thu, 05 Jan 2012) Log Message: ----------- [tbsl] fixed entry for "highest" Modified Paths: -------------- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/sem/drs/DRS.java trunk/components-ext/src/main/resources/tbsl/lexicon/english.lex Modified: trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/sem/drs/DRS.java =================================================================== --- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/sem/drs/DRS.java 2012-01-04 15:01:50 UTC (rev 3526) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/sem/drs/DRS.java 2012-01-05 13:54:07 UTC (rev 3527) @@ -505,7 +505,7 @@ drs1.replaceReferent(oldV,newV); } - // Hack: If it looks the same, it is the same. + // If it looks the same, it is the same. DRS_Constructor dc = new DRS_Constructor(); if (dc.construct(drs1.toString()).equals(dc.construct(drs2.toString()))) { Modified: trunk/components-ext/src/main/resources/tbsl/lexicon/english.lex =================================================================== --- trunk/components-ext/src/main/resources/tbsl/lexicon/english.lex 2012-01-04 15:01:50 UTC (rev 3526) +++ trunk/components-ext/src/main/resources/tbsl/lexicon/english.lex 2012-01-05 13:54:07 UTC (rev 3527) @@ -84,8 +84,8 @@ the most || (DET DET:'the' DET:'most') || <y, l1, e, [ l1:[ | l2:[ y | ] THEMOST y l3:[|] ] ], [], [],[]> the least || (DET DET:'the' DET:'least') || <y, l1, e, [ l1:[ | l2:[ y | ] THELEAST y l3:[|] ] ], [], [],[]> - // CHEAT! - highest || (NP ADJ:'highest' NP*) || <x, l1, e, [ l1:[ | maximum(x) ] ], [], [],[]> ;; <x, l1, e, [ l1:[ j | SLOT_high(x,j), maximum(j) ] ],[],[],[ SLOT_high/PROPERTY/height^elevation ]> + // NECESSARY "CHEAT" + highest || (NP ADJ:'highest' NP*) || <x, l1, e, [ l1:[ | maximum(x) ] ], [], [],[]> ;; <x, l1, e, [ l1:[ j | SLOT_high(x,j), maximum(j) ] ],[],[],[ SLOT_high/PROPERTY/height ]> // COUNT 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],[]> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2012-01-05 17:44:31
|
Revision: 3531 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=3531&view=rev Author: christinaunger Date: 2012-01-05 17:44:19 +0000 (Thu, 05 Jan 2012) Log Message: ----------- [tbsl] added HAVING-part to basic templates 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/Preprocessor.java trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/sparql/BasicQueryTemplate.java trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/templator/BasicTemplator.java Added Paths: ----------- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/sparql/SPARQL_Having.java trunk/components-ext/src/main/resources/tbsl/lexicon/basic_english.lex 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-01-05 17:42:15 UTC (rev 3530) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/converter/DRS2BasicSPARQL_Converter.java 2012-01-05 17:44:19 UTC (rev 3531) @@ -16,6 +16,7 @@ import org.dllearner.algorithm.tbsl.sparql.Path; import org.dllearner.algorithm.tbsl.sparql.SPARQL_Aggregate; import org.dllearner.algorithm.tbsl.sparql.SPARQL_Filter; +import org.dllearner.algorithm.tbsl.sparql.SPARQL_Having; import org.dllearner.algorithm.tbsl.sparql.SPARQL_OrderBy; import org.dllearner.algorithm.tbsl.sparql.SPARQL_Pair; import org.dllearner.algorithm.tbsl.sparql.SPARQL_PairType; @@ -242,21 +243,41 @@ } } else if (predicate.equals("count")) { - // COUNT(?x) AS ?c - if (!literal) { - temp.addSelTerm(new SPARQL_Term(simple.getArguments().get(0).getValue(), SPARQL_Aggregate.COUNT, simple.getArguments().get(1).getValue())); - return temp; + if (simple.getArguments().size() == 1) { + temp.addSelTerm(new SPARQL_Term(simple.getArguments().get(0).getValue(), SPARQL_Aggregate.COUNT)); } else { - String fresh = "c"+createFresh(); - temp.addSelTerm(new SPARQL_Term(simple.getArguments().get(0).getValue(), SPARQL_Aggregate.COUNT, fresh)); - temp.addFilter(new SPARQL_Filter( - new SPARQL_Pair( - new SPARQL_Term(fresh), - new SPARQL_Term(simple.getArguments().get(1).getValue(),true), - SPARQL_PairType.EQ))); - return temp; + if (!literal) { + temp.addSelTerm(new SPARQL_Term(simple.getArguments().get(0).getValue(), SPARQL_Aggregate.COUNT, simple.getArguments().get(1).getValue())); + return temp; + } + else { // COUNT(?x) AS ?c + // String fresh = "c"+createFresh(); + // temp.addSelTerm(new SPARQL_Term(simple.getArguments().get(0).getValue(), SPARQL_Aggregate.COUNT, fresh)); + // temp.addFilter(new SPARQL_Filter( + // new SPARQL_Pair( + // new SPARQL_Term(fresh), + // new SPARQL_Term(simple.getArguments().get(1).getValue(),true), + // SPARQL_PairType.EQ))); + temp.addHaving(new SPARQL_Having("COUNT(?"+simple.getArguments().get(0).getValue() + ") = "+simple.getArguments().get(1).getValue())); + return temp; + } } + } else if (predicate.equals("count_greater")) { + temp.addHaving(new SPARQL_Having("COUNT(?"+simple.getArguments().get(0).getValue() + ") > "+simple.getArguments().get(1).getValue())); + return temp; + } else if (predicate.equals("count_less")) { + temp.addHaving(new SPARQL_Having("COUNT(?"+simple.getArguments().get(0).getValue() + ") < "+simple.getArguments().get(1).getValue())); + return temp; + } else if (predicate.equals("count_greatereq")) { + temp.addHaving(new SPARQL_Having("COUNT(?"+simple.getArguments().get(0).getValue() + ") >= "+simple.getArguments().get(1).getValue())); + return temp; + } else if (predicate.equals("count_lesseq")) { + temp.addHaving(new SPARQL_Having("COUNT(?"+simple.getArguments().get(0).getValue() + ") <= "+simple.getArguments().get(1).getValue())); + return temp; + } else if (predicate.equals("count_eq")) { + temp.addHaving(new SPARQL_Having("COUNT(?"+simple.getArguments().get(0).getValue() + ") = "+simple.getArguments().get(1).getValue())); + return temp; } else if (predicate.equals("sum")) { temp.addSelTerm(new SPARQL_Term(simple.getArguments().get(1).getValue(), SPARQL_Aggregate.SUM)); return temp; 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-01-05 17:42:15 UTC (rev 3530) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/ltag/parser/Preprocessor.java 2012-01-05 17:44:19 UTC (rev 3531) @@ -87,7 +87,7 @@ Pattern vpassPattern = Pattern.compile("\\s(\\w+/VBD.(\\w+)/VBN)"); Pattern vpassinPattern = Pattern.compile("\\s((\\w+)/VPASS.\\w+/IN)"); Pattern gerundinPattern = Pattern.compile("\\s((\\w+)/((VBG)|(VBN)).\\w+/IN)"); - Pattern vprepPattern = Pattern.compile("\\s((\\w+)/V[A-Z]+\\s\\w+/(IN|TO))"); + Pattern vprepPattern = Pattern.compile("\\s((\\w+)(?<!have)/V[A-Z]+\\s\\w+/(IN|TO))"); Pattern whenPattern = Pattern.compile("(?i)(when/WRB\\s(.+\\s)(\\w+)/((V[A-Z]+)|(PASS[A-Z]+)))"); Pattern wherePattern = Pattern.compile("(?i)(where/WRB\\s(.+\\s)(\\w+)/((V[A-Z]+)|(PASS[A-Z]+)))"); Pattern adjsPattern = Pattern.compile("((\\w+)/JJ.(\\w+)/JJ)"); Modified: trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/sparql/BasicQueryTemplate.java =================================================================== --- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/sparql/BasicQueryTemplate.java 2012-01-05 17:42:15 UTC (rev 3530) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/sparql/BasicQueryTemplate.java 2012-01-05 17:44:19 UTC (rev 3531) @@ -13,6 +13,7 @@ Set<Path> conditions; Set<SPARQL_Term> orderBy; Set<SPARQL_Filter> filter; + Set<SPARQL_Having> having; SPARQL_QueryType qt = SPARQL_QueryType.SELECT; List<Slot> slots; @@ -27,6 +28,7 @@ conditions = new HashSet<Path>(); orderBy = new HashSet<SPARQL_Term>(); filter = new HashSet<SPARQL_Filter>(); + having = new HashSet<SPARQL_Having>(); slots = new ArrayList<Slot>(); } @@ -71,6 +73,10 @@ } retVal += "}\n"; + + for (SPARQL_Having h : having) { + retVal += h + "\n"; + } if (orderBy != null && !orderBy.isEmpty()) { @@ -152,6 +158,14 @@ this.filter.add(f); } + + public Set<SPARQL_Having> getHavings() { + return having; + } + + public void addHaving(SPARQL_Having h) { + having.add(h); + } public Set<SPARQL_Term> getOrderBy() { @@ -241,7 +255,10 @@ public int hashCode() { final int prime = 31; int result = 1; + result = prime * result + + ((conditions == null) ? 0 : conditions.hashCode()); result = prime * result + ((filter == null) ? 0 : filter.hashCode()); + result = prime * result + ((having == null) ? 0 : having.hashCode()); result = prime * result + limit; result = prime * result + offset; result = prime * result + ((orderBy == null) ? 0 : orderBy.hashCode()); @@ -263,11 +280,21 @@ if (getClass() != obj.getClass()) return false; BasicQueryTemplate other = (BasicQueryTemplate) obj; + if (conditions == null) { + if (other.conditions != null) + return false; + } else if (!conditions.equals(other.conditions)) + return false; if (filter == null) { if (other.filter != null) return false; } else if (!filter.equals(other.filter)) return false; + if (having == null) { + if (other.having != null) + return false; + } else if (!having.equals(other.having)) + return false; if (limit != other.limit) return false; if (offset != other.offset) @@ -300,4 +327,5 @@ return true; } + } Added: trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/sparql/SPARQL_Having.java =================================================================== --- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/sparql/SPARQL_Having.java (rev 0) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/sparql/SPARQL_Having.java 2012-01-05 17:44:19 UTC (rev 3531) @@ -0,0 +1,14 @@ +package org.dllearner.algorithm.tbsl.sparql; + +public class SPARQL_Having { + + public String filter; + + public SPARQL_Having(String s) { + filter = s; + } + + public String toString() { + return "HAVING (" + filter + ")"; + } +} Property changes on: trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/sparql/SPARQL_Having.java ___________________________________________________________________ Added: svn:mime-type + text/plain 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-01-05 17:42:15 UTC (rev 3530) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/templator/BasicTemplator.java 2012-01-05 17:44:19 UTC (rev 3531) @@ -24,7 +24,7 @@ public class BasicTemplator { - String[] GRAMMAR_FILES = {"tbsl/lexicon/english.lex"}; + String[] GRAMMAR_FILES = {"tbsl/lexicon/basic_english.lex"}; PartOfSpeechTagger tagger; LTAGLexicon g; Added: trunk/components-ext/src/main/resources/tbsl/lexicon/basic_english.lex =================================================================== --- trunk/components-ext/src/main/resources/tbsl/lexicon/basic_english.lex (rev 0) +++ trunk/components-ext/src/main/resources/tbsl/lexicon/basic_english.lex 2012-01-05 17:44:19 UTC (rev 3531) @@ -0,0 +1,185 @@ + +// TO BE +// ------ + + is || (S DP[subject] (VP V:'is' DP[object])) || <x, l1, t, [ l1:[ | ], l2:[ | x=y ] ], [ (l3,x,subject,<<e,t>,t>), (l4,y,object,<<e,t>,t>) ], [ l3<l1, l4<l1, l2<scope(l3), l2<scope(l4) ],[]> + is || (S DP[subject] (VP V:'is' ADJ[comp])) || <x, l1, t, [ l1:[ | x=y ]], [ (l2,x,subject,<<e,t>,t>), (l3,y,comp,<e,t>) ], [ l2=l1, l3=l2 ],[]> + was || (S DP[subject] (VP V:'was' DP[object])) || <x, l1, t, [ l1:[ | ], l2:[ | x=y ] ], [ (l3,x,subject,<<e,t>,t>), (l4,y,object,<<e,t>,t>) ], [ l3<l1, l4<l1, l2<scope(l3), l2<scope(l4) ],[]> + was || (S DP[subject] (VP V:'was' ADJ[comp])) || <x, l1, t, [ l1:[ | x=y ]], [ (l2,x,subject,<<e,t>,t>), (l3,y,comp,<e,t>) ], [ l2=l1, l3=l2 ],[]> + which is || (NP NP* (S C:'which' (VP V:'is' DP[object]))) || <x, l1, t, [ l1:[ | x=y ] ], [ (l2,y,object,<<e,t>,t>) ], [ l2=l1 ],[]> + that is || (NP NP* (S C:'that' (VP V:'is' DP[object]))) || <x, l1, t, [ l1:[ | x=y ] ], [ (l2,y,object,<<e,t>,t>) ], [ l2=l1 ],[]> + + are || (S DP[subject] (VP V:'are' DP[object])) || <x, l1, t, [ l1:[ | ], l2:[ | x=y ] ], [ (l3,x,subject,<<e,t>,t>), (l4,y,object,<<e,t>,t>) ], [ l3<l1, l4<l1, l2<scope(l3), l2<scope(l4) ],[]> + are || (S DP[subject] (VP V:'are' ADJ[comp])) || <x, l1, t, [ l1:[ | x=y ]], [ (l2,x,subject,<<e,t>,t>), (l3,y,comp,<e,t>) ], [ l2=l1, l3=l2 ],[]> + were || (S DP[subject] (VP V:'were' DP[object])) || <x, l1, t, [ l1:[ | ], l2:[ | x=y ] ], [ (l3,x,subject,<<e,t>,t>), (l4,y,object,<<e,t>,t>) ], [ l3<l1, l4<l1, l2<scope(l3), l2<scope(l4) ],[]> + were || (S DP[subject] (VP V:'were' ADJ[comp])) || <x, l1, t, [ l1:[ | x=y ]], [ (l2,x,subject,<<e,t>,t>), (l3,y,comp,<e,t>) ], [ l2=l1, l3=l2 ],[]> + which are || (NP NP* (S C:'which' (VP V:'are' DP[object]))) || <x, l1, t, [ l1:[ | x=y ] ], [ (l2,y,object,<<e,t>,t>) ], [ l2=l1 ],[]> + that are || (NP NP* (S C:'that' (VP V:'are' DP[object]))) || <x, l1, t, [ l1:[ | x=y ] ], [ (l2,y,object,<<e,t>,t>) ], [ l2=l1 ],[]> + + 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 ],[]> + 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 ],[]> + +// TO BE: YES/NO QUESTIONS + + is || (S (VP V:'is' DP[subject] DP[object])) || <x, l1, t, [ l1:[ | ], l2:[ | x=y ] ], [ (l3,x,subject,<<e,t>,t>), (l4,y,object,<<e,t>,t>) ], [ l3<l1, l4<l1, l2<scope(l3), l2<scope(l4) ],[]> + is || (S (VP V:'is' DP[subject] ADJ[comp])) || <x, l1, t, [ l1:[ | x=y ]], [ (l2,x,subject,<<e,t>,t>), (l3,y,comp,<e,t>) ], [ l2=l1, l3=l2 ],[]> + was || (S V:'was' DP[subject] DP[object]) || <x, l1, t, [ l1:[ | ], l2:[ | x=y ] ], [ (l3,x,subject,<<e,t>,t>), (l4,y,object,<<e,t>,t>) ], [ l3<l1, l4<l1, l2<scope(l3), l2<scope(l4) ],[]> + was || (S V:'was' DP[subject] ADJ[comp]) || <x, l1, t, [ l1:[ | x=y ]], [ (l2,x,subject,<<e,t>,t>), (l3,y,comp,<e,t>) ], [ l2=l1, l3=l2 ],[]> + are || (S V:'are' DP[subject] DP[object]) || <x, l1, t, [ l1:[ | ], l2:[ | x=y ] ], [ (l3,x,subject,<<e,t>,t>), (l4,y,object,<<e,t>,t>) ], [ l3<l1, l4<l1, l2<scope(l3), l2<scope(l4) ],[]> + are || (S V:'are' DP[subject] ADJ[comp]) || <x, l1, t, [ l1:[ | x=y ]], [ (l2,x,subject,<<e,t>,t>), (l3,y,comp,<e,t>) ], [ l2=l1, l3=l2 ],[]> + were || (S V:'were' DP[subject] DP[object]) || <x, l1, t, [ l1:[ | ], l2:[ | x=y ] ], [ (l3,x,subject,<<e,t>,t>), (l4,y,object,<<e,t>,t>) ], [ l3<l1, l4<l1, l2<scope(l3), l2<scope(l4) ],[]> + were || (S V:'were' DP[subject] ADJ[comp]) || <x, l1, t, [ l1:[ | x=y ]], [ (l2,x,subject,<<e,t>,t>), (l3,y,comp,<e,t>) ], [ l2=l1, l3=l2 ],[]> + + did || (S V:'did' S*) || <x,l1,t,[ l1:[|] ],[],[],[]> + +// IMPERATIVES +// --------------------- + + give me || (S (VP V:'give' (DP N:'me') DP[object])) || <x,l1,t,[ l1:[ ?x | x=y ] ],[ (l2,y,object,<<e,t>,t>) ],[ l1=l2 ],[]> + name || (S (VP V:'name' DP[object])) || <x,l1,t,[ l1:[ ?x | x=y ] ],[ (l2,y,object,<<e,t>,t>) ],[ l1=l2 ],[]> +// give me all || (S (VP V:'give' (DP N:'me') DET:'all' DP[object])) || <x,l1,t,[ l1:[ ?x | x=y ] ],[ (l2,y,object,<<e,t>,t>) ],[ l1=l2 ],[]> +// name all || (S (VP V:'name' DET:'all' DP[object])) || <x,l1,t,[ l1:[ ?x | x=y ] ],[ (l2,y,object,<<e,t>,t>) ],[ l1=l2 ],[]> + show me || (S (VP V:'show' (DP N:'me') DP[object])) || <x,l1,t,[ l1:[ ?x | x=y ] ],[ (l2,y,object,<<e,t>,t>) ],[ l1=l2 ],[]> + show || (S (VP V:'show' DP[object])) || <x,l1,t,[ l1:[ ?x | x=y ] ],[ (l2,y,object,<<e,t>,t>) ],[ l1=l2 ],[]> + list me || (S (VP V:'list' (DP N:'me') DP[object])) || <x,l1,t,[ l1:[ ?x | x=y ] ],[ (l2,y,object,<<e,t>,t>) ],[ l1=l2 ],[]> + list || (S (VP V:'list' DP[object])) || <x,l1,t,[ l1:[ ?x | x=y ] ],[ (l2,y,object,<<e,t>,t>) ],[ l1=l2 ],[]> + + +// DETERMINER +// ---------- + + a || (DP DET:'a' NP[noun]) || <y, l1, <<e,t>,t>, [ l1:[ | l2:[ y | ] SOME y l3:[|] ] ], [ (l4,y,noun,<e,t>) ], [ l4=l2 ],[]> + an || (DP DET:'an' NP[noun]) || <y, l1, <<e,t>,t>, [ l1:[ | l2:[ y | ] SOME y l3:[|] ] ], [ (l4,y,noun,<e,t>) ], [ l4=l2 ],[]> + all || (DP DET:'all' NP[noun]) || <y, l1, <<e,t>,t>, [ l1:[ | l2:[ y | ] EVERY y l3:[|] ] ], [ (l4,y,noun,<e,t>) ], [ l4=l2 ],[]> + all the || (DP DET:'all' DET:'the' NP[noun]) || <y, l1, <<e,t>,t>, [ l1:[ y | ] ], [ (l2,y,noun,<e,t>) ], [ l2=l1 ],[]> + every || (DP DET:'every' NP[noun]) || <y, l1, <<e,t>,t>, [ l1:[ | l2:[ y | ] EVERY y l3:[|] ] ], [ (l4,y,noun,<e,t>) ], [ l4=l2 ],[]> + no || (DP DET:'no' NP[noun]) || <y, l1, <<e,t>,t>, [ l1:[ | l2:[ y | ] NO y l3:[|] ] ], [ (l4,y,noun,<e,t>) ], [ l4=l2 ],[]> + each || (DP DET:'each' NP[noun]) || <y, l1, <<e,t>,t>, [ l1:[ | l2:[ y | ] EVERY y l3:[|] ] ], [ (l4,y,noun,<e,t>) ], [ l4=l2 ],[]> + the most || (DP DET:'the' ADJ:'most' NP[noun]) || <y, l1, <<e,t>,t>, [ l1:[ | l2:[ y | ] THEMOST y l3:[|] ] ], [ (l4,y,noun,<e,t>) ], [ l4=l2 ],[]> + the least || (DP DET:'the' ADJ:'least' NP[noun]) || <y, l1, <<e,t>,t>, [ l1:[ | l2:[ y | ] THELEAST y l3:[|] ] ], [ (l4,y,noun,<e,t>) ], [ l4=l2 ],[]> + most || (DP DET:'most' NP[noun]) || <y, l1, <<e,t>,t>, [ l1:[ | l2:[ y | ] MOST y l3:[|] ] ], [ (l4,y,noun,<e,t>) ], [ l4=l2 ],[]> + a few || (DP DET:'a' ADJ:'few' NP[noun]) || <y, l1, <<e,t>,t>, [ l1:[ | l2:[ y | ] AFEW y l3:[|] ] ], [ (l4,y,noun,<e,t>) ], [ l4=l2 ],[]> + some || (DP DET:'some' NP[noun]) || <x, l1, <<e,t>,t>, [ l1:[ x | ] ], [ (l2,x,noun,<e,t>) ], [ l2=l1 ],[]> + which || (DP DET:'which' NP[noun]) || <y, l1, <<e,t>,t>, [ l1:[ ?y | ] ], [ (l2,y,noun,<e,t>) ], [ l2=l1 ],[]> + what || (DP DET:'what' NP[noun]) || <y, l1, <<e,t>,t>, [ l1:[ ?y | ] ], [ (l2,y,noun,<e,t>) ], [ l2=l1 ],[]> + many || (DP DET:'many' NP[noun]) || <y, l1, <<e,t>,t>, [ l1:[ | l2:[ y | ] MANY y l3:[|] ] ], [ (l4,y,noun,<e,t>) ], [ l4=l2 ],[]> + the || (DP DET:'the' NP[noun]) || <x, l1, <<e,t>,t>, [ l1:[x|] ], [ (l2,x,noun,<e,t>) ], [ l2=l1 ],[]> + at least || (DP DET:'at' DET:'least' NUM[num] NP[noun]) || <y,l1,<<e,t>,t>,[l1:[ y | count_greatereq(y,x) ]],[(l2,y,noun,<e,t>),(l3,x,num,e)],[ l1=l2, l2=l3 ],[]> + at most || (DP DET:'at' DET:'most' NUM[num] NP[noun]) || <y,l1,<<e,t>,t>,[l1:[ y | count_lesseq(y,x) ]],[(l2,y,noun,<e,t>),(l3,x,num,e)],[ l1=l2, l2=l3 ],[]> + exactly || (DP DET:'exactly' NUM[num] NP[noun]) || <y,l1,<<e,t>,t>,[l1:[ y | count_eq(y,x) ]],[(l2,y,noun,<e,t>),(l3,x,num,e)],[ l1=l2, l2=l3 ],[]> + + other || (NP ADJ:'other' NP*) || <x,l1,<e,t>,[ l1:[ | ] ], [],[],[]> + total || (NP ADJ:'total' NP[np]) || <s,l1,<e,t>,[ l1:[ ?s | sum(a,x,s) ] ], [ (l2,x,np,<e,t>) ],[ l2=l1 ],[]> + + 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) ] ], [],[],[]> + 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 |] ], [],[],[]> + the || (DET DET:'the') || <x,l1,e, [ l1:[ x |] ], [],[],[]> + the most || (DET DET:'the' DET:'most') || <y, l1, e, [ l1:[ | l2:[ y | ] THEMOST y l3:[|] ] ], [], [],[]> + the least || (DET DET:'the' DET:'least') || <y, l1, e, [ l1:[ | l2:[ y | ] THELEAST y l3:[|] ] ], [], [],[]> + + // NECESSARY "CHEAT" + highest || (NP ADJ:'highest' NP*) || <x, l1, e, [ l1:[ | maximum(x) ] ], [], [],[]> ;; <x, l1, e, [ l1:[ j | SLOT_high(x,j), maximum(j) ] ],[],[],[ SLOT_high/PROPERTY/height ]> + + // COUNT + more than || (DP DET:'more' DET:'than' NUM[num] NP[np]) || <y,l1,<<e,t>,t>,[ l1:[ y,c | count_greater(y,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_less(y,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],[]> + + +// EMPTY STUFF +// ------------ + + 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) ],[]> + 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],[]> + + people || (NP N:'people') || <x,l1,<e,t>,[ l1:[|] ],[],[],[]> + + +// WH WORDS +// -------- + + what || (DP WH:'what') || <x, l1, <<e,t>,t>, [ l1:[ ?x | ] ], [], [], []> + which || (DP WH:'which') || <x, l1, <<e,t>,t>, [ l1:[ ?x | ] ], [], [], []> + how many || (DP WH:'how' ADJ:'many' NP[noun]) || <y, l1, <<e,t>,t>, [ l1:[ | l2:[ y | ] HOWMANY y l3:[|] ] ], [ (l4,y,noun,<e,t>) ], [ l4=l2 ],[]> + who || (DP WH:'who') || <x, l1, <<e,t>,t>, [ l1:[ ?x | ] ], [], [], []> + whom || (DP WH:'whom') || <x, l1, <<e,t>,t>, [ l1:[ ?x | ] ], [], [], []> + when || (S WH:'when' S[s]) || <x, l1, t, [ l1:[ ?x | SLOT_p(y,x) ] ], [(l2,y,s,t)], [l2=l1], [ SLOT_p/PROPERTY/date ]> + when || (DP WH:'when') || <y, l1, <<e,t>,t>, [ l1:[ ?x | SLOT_p(y,x) ] ], [], [], [ SLOT_p/PROPERTY/date ]> + where || (S WH:'where' S[s]) || <x, l1, t, [ l1:[ ?x | SLOT_p(y,x) ] ], [(l2,y,s,t)], [l2=l1], [ SLOT_p/PROPERTY/place ]> + where || (DP WH:'where') || <y, l1, <<e,t>,t>, [ l1:[ ?x | SLOT_p(y,x) ] ], [], [], [ SLOT_p/PROPERTY/place ]> + where in || (DP WH:'where' (PP P:'in' DP[dp])) || <y, l1, <<e,t>,t>, [ l1:[ ?x | SLOT_p(y,x), SLOT_in(x,z) ] ], [(l2,z,dp,<<e,t>,t>)], [l2=l1], [ SLOT_p/PROPERTY/place ]> + + +// NEGATION +// -------- + + not || (ADJ NEG:'not' ADJ*) || <x,l2,t,[ l1:[ | NOT l2:[|] ] ],[],[],[]> + not || (VP NEG:'not' VP*) || <x,l2,t,[ l1:[ | NOT l2:[|] ] ],[],[],[]> + did not || (VP V:'did' NEG:'not' VP*) || <x,l2,t,[ l1:[ | NOT l2:[|] ] ],[],[],[]> + does not || (VP V:'does' NEG:'not' VP*) || <x,l2,t,[ l1:[ | NOT l2:[|] ] ],[],[],[]> + do not || (VP V:'do' NEG:'not' VP*) || <x,l2,t,[ l1:[ | NOT l2:[|] ] ],[],[],[]> + + +// COORDINATION +// ------------ + + and || (S S* CC:'and' S[s]) || <x,l1,t,[l1:[|]],[(l2,y,s,t)],[l1=l2],[]> + and || (DP DP* CC:'and' DP[dp]) || <x,l1,<<e,t>,t>,[l1:[|]],[(l2,y,dp,<<e,t>,t>)],[l1=l2],[]> + and || (NP NP* CC:'and' NP[np]) || <x,l1,<e,t>,[l1:[|]],[(l2,y,np,<e,t>)],[l1=l2],[]> + and || (VP VP* CC:'and' VP[vp]) || - + and || (ADJ ADJ* CC:'and' ADJ[adj]) || - + + as well as || (NP NP* CC:'as' CC:'well' CC:'as' NP[np]) || <x,l1,<e,t>,[l1:[|]],[(l2,y,np,<e,t>)],[l1=l2],[]> + + or || (S S* CC:'or' S[2]) || - + or || (DP DP* CC:'or' DP[2]) || - + or || (NP NP* CC:'or' NP[2]) || - + or || (VP VP* CC:'or' VP[2]) || - + or || (ADJ ADJ* CC:'or' ADJ[2]) || - + + +// EXISTENTIAL +// ----------- + + there || (DP (NP EX:'there')) || <x,l1,<<e,t>,t>,[l1:[|]],[],[],[]> + + +// NUMBERS (1-10) +// --------------------- + + one || (NP NUM:'one' NP*) || <x,l1,<e,t>,[l1:[x|count(x,1)]],[],[],[]> + two || (NP NUM:'two' NP*) || <x,l1,<e,t>,[l1:[x|count(x,2)]],[],[],[]> + three || (NP NUM:'three' NP*) || <x,l1,<e,t>,[l1:[x|count(x,3)]],[],[],[]> + four || (NP NUM:'four' NP*) || <x,l1,<e,t>,[l1:[x|count(x,4)]],[],[],[]> + five || (NP NUM:'five' NP*) || <x,l1,<e,t>,[l1:[x|count(x,5)]],[],[],[]> + six || (NP NUM:'six' NP*) || <x,l1,<e,t>,[l1:[x|count(x,6)]],[],[],[]> + seven || (NP NUM:'seven' NP*) || <x,l1,<e,t>,[l1:[x|count(x,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)]],[],[],[]> + four || (NUM NUM:'four') || <x,l1,e,[l1:[x|equal(x,4)]],[],[],[]> + five || (NUM NUM:'five') || <x,l1,e,[l1:[x|equal(x,5)]],[],[],[]> + six || (NUM NUM:'six') || <x,l1,e,[l1:[x|equal(x,6)]],[],[],[]> + seven || (NUM NUM:'seven') || <x,l1,e,[l1:[x|equal(x,7)]],[],[],[]> + eight || (NUM NUM:'eight') || <x,l1,e,[l1:[x|equal(x,8)]],[],[],[]> + nine || (NUM NUM:'nine') || <x,l1,e,[l1:[x|equal(x,9)]],[],[],[]> + ten || (NUM NUM:'ten') || <x,l1,e,[l1:[x|equal(x,10)]],[],[],[]> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2012-06-11 19:02:05
|
Revision: 3733 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=3733&view=rev Author: christinaunger Date: 2012-06-11 19:01:59 +0000 (Mon, 11 Jun 2012) Log Message: ----------- [tbsl] minor corrections and extensions in lexicon and template refinement Modified Paths: -------------- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/sparql/Template.java trunk/components-ext/src/main/resources/tbsl/lexicon/english_oxford.lex Modified: trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/sparql/Template.java =================================================================== --- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/sparql/Template.java 2012-06-11 17:06:18 UTC (rev 3732) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/sparql/Template.java 2012-06-11 19:01:59 UTC (rev 3733) @@ -56,11 +56,23 @@ } for (String arg : args) { for (Slot s : argslots) { - if (s.anchor.equals("SLOT_arg") && s.words.contains(arg.replace("?",""))) { + if (s.words.contains(arg.replace("?",""))) { if (s.type.equals(SlotType.LITERAL)) slot.type = SlotType.DATATYPEPROPERTY; else if (s.type.equals(SlotType.RESOURCE)) slot.type = SlotType.OBJECTPROPERTY; } } + if (slot.type.equals(SlotType.PROPERTY) || slot.type.equals(SlotType.SYMPROPERTY)) { // still + Set<String> values = new HashSet<String>(); + for (SPARQL_Triple triple : query.conditions) { + if (triple.property.toString().equals("?"+slot.anchor)) values.add(triple.value.toString()); + } + for (SPARQL_Triple triple : query.conditions) { + for (String val : values) { + if (triple.variable.toString().equals(val) && triple.property.toString().equals("rdf:type")) + slot.type = SlotType.OBJECTPROPERTY; + } + } + } } } } 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-11 17:06:18 UTC (rev 3732) +++ trunk/components-ext/src/main/resources/tbsl/lexicon/english_oxford.lex 2012-06-11 19:01:59 UTC (rev 3733) @@ -2,7 +2,7 @@ // PREPOSITIONS close to || (NP NP* (PP P:'close' P:'to' DP[dp])) || <x,l1,<e,t>, [ l1:[ | SLOT_closeto(x,y) ] ], [ (l2,y,dp,<<e,t>,t>) ], [ l2=l1 ],[ SLOT_closeto/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 ]> + 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 ]> 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 ]> @@ -12,9 +12,9 @@ with || (NP NP* (PP P:'with' DP[dp])) || <x,l1,<e,t>, [ l1:[ | empty(x,y) ] ], [ (l2,y,dp,<<e,t>,t>) ], [ l2=l1 ],[]> with || (NP NP* (PP P:'with' NUM[num] DP[dp])) || <x,l1,<e,t>, [ l1:[ | empty(x,y), count(y,z) ] ], [ (l2,y,dp,<<e,t>,t>),(l3,z,num,e) ], [ l2=l1,l3=l1 ],[ SLOT_arg/RESOURCE/y ]> - with || (NP NP* (PP P:'with' NUM[num] DP[dp])) || <x,l1,<e,t>, [ l1:[ | empty(x,y), equals(y,z) ] ], [ (l2,y,dp,<<e,t>,t>),(l3,z,num,e) ], [ l2=l1,l3=l1 ],[ SLOT_arg/LITERAL/y ]> + with || (NP NP* (PP P:'with' NUM[num] DP[dp])) || <x,l1,<e,t>, [ l1:[ | empty(x,y), equal(y,z) ] ], [ (l2,y,dp,<<e,t>,t>),(l3,z,num,e) ], [ l2=l1,l3=l1 ],[ SLOT_arg/LITERAL/y ]> + square meters || (DP N:'square' N:'meters') || <x,l1,<<e,t>,t>>, [l1:[ | SLOT_size(x,y) ]], [],[],[SLOT_size/DATATYPEPROPERTY/size ]> - // MONTHS january || (DP DP:'january') || <x,l1,<<e,t>,t>, [ l1:[ x | xsd:month(x,1) ]], [],[],[]> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2012-06-13 10:32:01
|
Revision: 3737 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=3737&view=rev Author: christinaunger Date: 2012-06-13 10:31:55 +0000 (Wed, 13 Jun 2012) Log Message: ----------- [tbsl] "with ... and ..." (jetzt aber!) Modified Paths: -------------- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/ltag/parser/GrammarFilter.java trunk/components-ext/src/main/resources/tbsl/lexicon/english_oxford.lex 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-06-12 17:24:58 UTC (rev 3736) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/ltag/parser/GrammarFilter.java 2012-06-13 10:31:55 UTC (rev 3737) @@ -1,9 +1,6 @@ package org.dllearner.algorithm.tbsl.ltag.parser; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Iterator; -import java.util.List; +import java.util.*; import org.apache.log4j.Logger; import org.dllearner.algorithm.tbsl.ltag.data.Category; @@ -129,20 +126,20 @@ * input token matches the regular expression "\d", a new * auxiliary tree is added to the parseGrammar. */ - - try { - TreeNode tree = c.construct("NUM:'" + token + "'"); - TreeNode tree2 = c.construct("(NP NUM:'" + token + "' NP*)"); - + Set<Pair<String,String>> ps = new HashSet<Pair<String,String>>(); + ps.add(new Pair<String,String>("NUM:'" + token + "'","<x,l1,e,[l1:[ x | equal(x," + token + ")]],[],[],[ SLOT_arg/LITERAL/x ]>")); + ps.add(new Pair<String,String>("(NP NUM:'" + token + "' NP*)","<x,l1,<e,t>,[l1:[ | count(x," + token + ")]],[],[],[ SLOT_arg/RESOURCE/x ]>")); + + for (Pair<String,String> p : ps) { + + try { + TreeNode tree = c.construct(p.getFirst()); + int gid = grammar.addTree(grammar.size(), new Pair<String,TreeNode>(token,tree), - Collections.singletonList("<x,l1,e,[l1:[ x | equal(x," + token + ")]],[],[],[ SLOT_arg/LITERAL/x ]>")); + Collections.singletonList(p.getSecond())); add(parseG, tree, gid-1, localID); + temps.add(gid-1); localID++; - -// int gid = grammar.addTree(grammar.size(), new Pair<String,TreeNode>(token,tree2), -// Collections.singletonList("<x,l1,<e,t>,[l1:[ | count(x," + token + ")]],[],[],[ SLOT_arg/RESOURCE/x ]>")); -// add(parseG, tree2, gid-1, localID); -// localID++; foundCandidates = true; coveredTokens.add(token); @@ -150,6 +147,7 @@ } catch (ParseException e) { e.printStackTrace(); } + } } else { /* 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-12 17:24:58 UTC (rev 3736) +++ trunk/components-ext/src/main/resources/tbsl/lexicon/english_oxford.lex 2012-06-13 10:31:55 UTC (rev 3737) @@ -11,8 +11,6 @@ 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 ]> with || (NP NP* (PP P:'with' DP[dp])) || <x,l1,<e,t>, [ l1:[ | empty(x,y) ] ], [ (l2,y,dp,<<e,t>,t>) ], [ l2=l1 ],[]> - with || (NP NP* (PP P:'with' NUM[num] DP[dp])) || <x,l1,<e,t>, [ l1:[ | empty(x,y), count(y,z) ] ], [ (l2,y,dp,<<e,t>,t>),(l3,z,num,e) ], [ l2=l1,l3=l1 ],[ SLOT_arg/RESOURCE/y ]> - with || (NP NP* (PP P:'with' NUM[num] DP[dp])) || <x,l1,<e,t>, [ l1:[ | empty(x,y), equal(y,z) ] ], [ (l2,y,dp,<<e,t>,t>),(l3,z,num,e) ], [ l2=l1,l3=l1 ],[ SLOT_arg/LITERAL/y ]> square meters || (DP N:'square' N:'meters') || <x,l1,<<e,t>,t>>, [l1:[ | SLOT_size(x,y) ]], [],[],[SLOT_size/DATATYPEPROPERTY/size ]> // MONTHS This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2012-06-14 15:30:10
|
Revision: 3741 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=3741&view=rev Author: christinaunger Date: 2012-06-14 15:30:01 +0000 (Thu, 14 Jun 2012) Log Message: ----------- [tbsl] basic update for regex descriptions, more filtering conditions on templates, and ASK -> SELECT hack Modified Paths: -------------- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/converter/DRS2SPARQL_Converter.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/sparql/Template.java trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/templator/Templator.java trunk/components-ext/src/main/resources/tbsl/lexicon/english.lex trunk/components-ext/src/main/resources/tbsl/lexicon/english_oxford.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 2012-06-14 14:54:54 UTC (rev 3740) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/converter/DRS2SPARQL_Converter.java 2012-06-14 15:30:01 UTC (rev 3741) @@ -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; @@ -30,8 +27,8 @@ public class DRS2SPARQL_Converter { - // suppresses console output - private boolean silent = true; + private boolean silent = true; // suppresses console output + private boolean oxford = true; List<Slot> slots; Template template; List<Integer> usedInts; @@ -100,7 +97,8 @@ if (!restructureEmpty(drs)) { return null; } -// System.out.println("--- DRS (after) : " + drs); // DEBUG + replaceRegextoken(drs); + // System.out.println("--- DRS (after) : " + drs); // DEBUG for (DiscourseReferent referent : drs.collectDRs()) { if (referent.isMarked()) { @@ -318,6 +316,21 @@ new SPARQL_Term(simple.getArguments().get(1).getValue(),true), SPARQL_PairType.REGEX))); } + else if (predicate.equals("regextoken")) { + String arg = simple.getArguments().get(1).getValue(); + String regex = null; + for (Slot slot : slots) { + if (slot.getAnchor().equals(arg)) { + if (!slot.getWords().isEmpty()) regex = slot.getWords().get(0); + } + } + if (regex != null) { + query.addFilter(new SPARQL_Filter(new SPARQL_Pair( + new SPARQL_Term(simple.getArguments().get(0).getValue(),false), + new SPARQL_Term("'"+regex+"'",false), + SPARQL_PairType.REGEX))); + } + } else { if (arity == 1) { SPARQL_Term term = new SPARQL_Term(simple.getArguments().get(0).getValue(),false);term.setIsVariable(true); @@ -333,6 +346,45 @@ } } } + + // TODO this is a hack in order to avoid ASK queries if DP is parsed + if (oxford) { + Hashtable<String,Integer> vs = new Hashtable<String,Integer>(); + String v1; String v2; + for (SPARQL_Triple c : query.getConditions()) { + v1 = c.getVariable().toString().replace("?",""); + v2 = c.getValue().toString().replace("?",""); + // is it a slot variable? + boolean v1isSlotVar = false; + boolean v2isSlotVar = false; + for (Slot s : slots) { + if (s.getAnchor().equals(v1)) v1isSlotVar = true; + if (s.getAnchor().equals(v2)) v2isSlotVar = true; + } + if (!v1isSlotVar && !v1.matches("[0..9]+") && !v1.contains("count")) { + if (vs.containsKey(v1)) vs.put(v1,vs.get(v1)+1); + else vs.put(v1,1); + } + if (!v2isSlotVar && !v2.matches("[0..9]+") && !v2.contains("count")) { + if (vs.containsKey(v2)) vs.put(v2,vs.get(v2)+1); + else vs.put(v2,1); + } + } + + int max = 0; String maxvar = null; + for (String var : vs.keySet()) { + if (vs.get(var) > max) { + max = vs.get(var); + maxvar = var; + } + } + if (maxvar != null) { + SPARQL_Term term = new SPARQL_Term(maxvar); + term.setIsVariable(true); + query.addSelTerm(term); + } + } + return query; } @@ -340,41 +392,41 @@ Set<Simple_DRS_Condition> equalsConditions = new HashSet<Simple_DRS_Condition>(); for (Simple_DRS_Condition c : drs.getAllSimpleConditions()) { - if(c.getPredicate().equals("equal")) { - equalsConditions.add(c); - } + if(c.getPredicate().equals("equal")) equalsConditions.add(c); } DiscourseReferent firstArg; DiscourseReferent secondArg; boolean firstIsURI; boolean secondIsURI; + boolean firstIsInt; + boolean secondIsInt; for (Simple_DRS_Condition c : equalsConditions) { - firstArg = c.getArguments().get(0); + firstArg = c.getArguments().get(0); secondArg = c.getArguments().get(1); firstIsURI = isUri(firstArg.getValue()); secondIsURI = isUri(secondArg.getValue()); + firstIsInt = firstArg.getValue().matches("[0..9]+"); + secondIsInt = secondArg.getValue().matches("[0..9]+"); - boolean oneArgIsInt = firstArg.toString().matches("[0..9]") || secondArg.toString().matches("[0..9]"); - drs.removeCondition(c); - if (firstIsURI) { - drs.replaceEqualRef(secondArg, firstArg, false); + if (firstIsURI || firstIsInt) { + drs.replaceEqualRef(secondArg, firstArg, true); for (Slot s : slots) { if (s.getAnchor().equals(secondArg.getValue())) { s.setAnchor(firstArg.getValue()); } } - } else if (secondIsURI) { - drs.replaceEqualRef(firstArg, secondArg, false); + } else if (secondIsURI || secondIsInt) { + drs.replaceEqualRef(firstArg, secondArg, true); for (Slot s : slots) { if (s.getAnchor().equals(firstArg.getValue())) { s.setAnchor(secondArg.getValue()); } } - } else if (!oneArgIsInt) { + } else { drs.replaceEqualRef(firstArg, secondArg, false); for (Slot s : slots) { if (s.getAnchor().equals(firstArg.getValue())) { @@ -396,6 +448,55 @@ } } + private void replaceRegextoken(DRS drs) { + + Set<Simple_DRS_Condition> cs = new HashSet<Simple_DRS_Condition>(); + for (Simple_DRS_Condition c : drs.getAllSimpleConditions()) { + if(c.getPredicate().equals("regextoken")) cs.add(c); + } + + String var; + String newvar; + String regex = ""; + String[] forbidden = {"regextoken","regex","count","minimum","maximum","greater","less","greaterorequal","lessorequal","equal","sum"}; + Set<Simple_DRS_Condition> used = new HashSet<Simple_DRS_Condition>(); + + for (Simple_DRS_Condition c : cs) { + var = c.getArguments().get(1).getValue(); + newvar = c.getArguments().get(0).getValue(); + for (Simple_DRS_Condition cond : drs.getAllSimpleConditions()) { + boolean takeit = false; + for (DiscourseReferent dr : cond.getArguments()) { + if (dr.getValue().equals(var)) { + takeit = true; + for (String f : forbidden) if (f.equals(cond.getPredicate())) takeit= false; + } + } + if (takeit) { + regex += cond.getPredicate().replace("SLOT","") + " "; + used.add(cond); + } + else { + for (DiscourseReferent dr : cond.getArguments()) { + if (dr.getValue().equals(var)) dr.setValue(newvar); + } + } + } + if (!regex.isEmpty()) { + c.getArguments().remove(1); + c.getArguments().add(new DiscourseReferent("'"+regex.trim()+"'")); + c.setPredicate("regex"); + } + for (Slot s : slots) { + if (s.getWords().contains(var)) { + s.getWords().remove(var); + s.getWords().add(newvar); + } + } + } + for (Simple_DRS_Condition cond : used) drs.removeCondition(cond); + } + private boolean restructureEmpty(DRS drs) { 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-06-14 14:54:54 UTC (rev 3740) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/ltag/parser/Preprocessor.java 2012-06-14 15:30:01 UTC (rev 3741) @@ -18,6 +18,9 @@ static final String[] genericReplacements = { "[!?.,;]", "" }; static final String[] englishReplacements = { "don't", "do not", "doesn't", "does not" }; + static final String[] hackReplacements = { " 1 "," one "," 2 "," two "," 3 "," three "," 4 "," four "," 5 "," five "," 6 "," six "," 7 "," seven ", + " 8 "," eight "," 9 "," nine "," 10 "," ten "," 11 "," eleven "," 12 "," twelve "," 13 "," thirteen "," 14 "," fourteen "," 15 "," fifteen ", + " 16 "," sixteen "," 17 "," seventeen "," 18 "," eighteen "," 19 "," nineteen "," 20 "," twenty "}; static boolean USE_NER; static boolean VERBOSE; static NER ner; @@ -49,7 +52,9 @@ replacements.addAll(Arrays.asList(repl)); replacements.addAll(Arrays.asList(englishReplacements)); replacements.addAll(Arrays.asList(genericReplacements)); + replacements.addAll(Arrays.asList(hackReplacements)); + s = s.replaceAll(",\\s"," and "); for (int i = 0; i < replacements.size(); i += 2) { s = s.replaceAll(replacements.get(i), replacements.get(i + 1)); } Modified: trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/sparql/Template.java =================================================================== --- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/sparql/Template.java 2012-06-14 14:54:54 UTC (rev 3740) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/sparql/Template.java 2012-06-14 15:30:01 UTC (rev 3741) @@ -33,7 +33,28 @@ public Template checkandrefine() { Set<Slot> argslots = new HashSet<Slot>(); - for (Slot slot : slots) if (slot.anchor.equals("SLOT_arg")) argslots.add(slot); + for (Slot slot : slots) if (slot.anchor.equals("SLOT_arg")) { + String var = slot.words.get(0); + // check for clash (v=LITERAL && v=RESOURCE) + for (Slot s : argslots) { + if (s.words.get(0).equals(slot.words.get(0)) && !s.type.equals(slot.type)) + return null; + } + // check for clash (v=LITERAL && p(...,v)=OBJECTPROPERTY) || (v=RESOURCE && p(...,v)=DATATYPEPROPERTY) + SlotType clashing = null; + if (slot.type.equals(SlotType.LITERAL)) clashing = SlotType.OBJECTPROPERTY; + else if (slot.type.equals(SlotType.RESOURCE)) clashing = SlotType.DATATYPEPROPERTY; + for (Slot s : slots) { + if (clashing != null && s.type.equals(clashing)) { + for (SPARQL_Triple triple : query.conditions) { + if (triple.property.toString().equals("?"+s.anchor)) { + if (triple.value.toString().equals("?"+var)) return null; + } + } + } + } + argslots.add(slot); + } for (Slot slot : slots) { // check for clashes Modified: trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/templator/Templator.java =================================================================== --- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/templator/Templator.java 2012-06-14 14:54:54 UTC (rev 3740) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/templator/Templator.java 2012-06-14 15:30:01 UTC (rev 3741) @@ -32,9 +32,9 @@ public class Templator { private static final Logger logger = Logger.getLogger(Templator.class); + + String[] GRAMMAR_FILES = {"tbsl/lexicon/english.lex","tbsl/lexicon/english_oxford.lex"}; - String[] GRAMMAR_FILES = {"tbsl/lexicon/english.lex","tbsl/lexicon/english_oxford.lex"}; - 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"}; @@ -49,8 +49,8 @@ WordNet wordnet; LingPipeLemmatizer lem = new LingPipeLemmatizer(); - DUDE2UDRS_Converter d2u = new DUDE2UDRS_Converter(); - DRS2SPARQL_Converter d2s = new DRS2SPARQL_Converter(); + DUDE2UDRS_Converter d2u = new DUDE2UDRS_Converter(); + DRS2SPARQL_Converter d2s = new DRS2SPARQL_Converter(); boolean ONE_SCOPE_ONLY = true; boolean UNTAGGED_INPUT = true; Modified: trunk/components-ext/src/main/resources/tbsl/lexicon/english.lex =================================================================== --- trunk/components-ext/src/main/resources/tbsl/lexicon/english.lex 2012-06-14 14:54:54 UTC (rev 3740) +++ trunk/components-ext/src/main/resources/tbsl/lexicon/english.lex 2012-06-14 15:30:01 UTC (rev 3741) @@ -172,6 +172,16 @@ eight || (NP NUM:'eight' NP*) || <x,l1,<e,t>,[l1:[x|count(x,8)]],[],[],[ SLOT_arg/RESOURCE/x ]> nine || (NP NUM:'nine' NP*) || <x,l1,<e,t>,[l1:[x|count(x,9)]],[],[],[ SLOT_arg/RESOURCE/x ]> ten || (NP NUM:'ten' NP*) || <x,l1,<e,t>,[l1:[x|count(x,10)]],[],[],[ SLOT_arg/RESOURCE/x ]> + eleven || (NP NUM:'one' NP*) || <x,l1,<e,t>,[l1:[x|count(x,11)]],[],[],[ SLOT_arg/RESOURCE/x ]> + twelve || (NP NUM:'two' NP*) || <x,l1,<e,t>,[l1:[x|count(x,12)]],[],[],[ SLOT_arg/RESOURCE/x ]> + thirteen || (NP NUM:'thirteen' NP*) || <x,l1,<e,t>,[l1:[x|count(x,13)]],[],[],[ SLOT_arg/RESOURCE/x ]> + fourteen || (NP NUM:'fourteen' NP*) || <x,l1,<e,t>,[l1:[x|count(x,14)]],[],[],[ SLOT_arg/RESOURCE/x ]> + fifteen || (NP NUM:'fifteen' NP*) || <x,l1,<e,t>,[l1:[x|count(x,15)]],[],[],[ SLOT_arg/RESOURCE/x ]> + sixteen || (NP NUM:'sixteen' NP*) || <x,l1,<e,t>,[l1:[x|count(x,16)]],[],[],[ SLOT_arg/RESOURCE/x ]> + seventeen || (NP NUM:'seventeen' NP*) || <x,l1,<e,t>,[l1:[x|count(x,17)]],[],[],[ SLOT_arg/RESOURCE/x ]> + eighteen || (NP NUM:'eighteen' NP*) || <x,l1,<e,t>,[l1:[x|count(x,18)]],[],[],[ SLOT_arg/RESOURCE/x ]> + nineteen || (NP NUM:'nineteen' NP*) || <x,l1,<e,t>,[l1:[x|count(x,19)]],[],[],[ SLOT_arg/RESOURCE/x ]> + twenty || (NP NUM:'twenty' NP*) || <x,l1,<e,t>,[l1:[x|count(x,20)]],[],[],[ SLOT_arg/RESOURCE/x ]> one || (NUM NUM:'one') || <x,l1,e,[l1:[x|equal(x,1)]],[],[],[ SLOT_arg/LITERAL/x ]> two || (NUM NUM:'two') || <x,l1,e,[l1:[x|equal(x,2)]],[],[],[ SLOT_arg/LITERAL/x ]> @@ -183,4 +193,13 @@ eight || (NUM NUM:'eight') || <x,l1,e,[l1:[x|equal(x,8)]],[],[],[ SLOT_arg/LITERAL/x ]> nine || (NUM NUM:'nine') || <x,l1,e,[l1:[x|equal(x,9)]],[],[],[ SLOT_arg/LITERAL/x ]> ten || (NUM NUM:'ten') || <x,l1,e,[l1:[x|equal(x,10)]],[],[],[ SLOT_arg/LITERAL/x ]> - + eleven || (NUM NUM:'eleven') || <x,l1,e,[l1:[x|equal(x,11)]],[],[],[ SLOT_arg/LITERAL/x ]> + twelve || (NUM NUM:'twelve') || <x,l1,e,[l1:[x|equal(x,12)]],[],[],[ SLOT_arg/LITERAL/x ]> + thirteen || (NUM NUM:'thirteen') || <x,l1,e,[l1:[x|equal(x,13)]],[],[],[ SLOT_arg/LITERAL/x ]> + fourteen || (NUM NUM:'fourteen') || <x,l1,e,[l1:[x|equal(x,14)]],[],[],[ SLOT_arg/LITERAL/x ]> + fifteen || (NUM NUM:'fifteen') || <x,l1,e,[l1:[x|equal(x,15)]],[],[],[ SLOT_arg/LITERAL/x ]> + sixteen || (NUM NUM:'sixteen') || <x,l1,e,[l1:[x|equal(x,16)]],[],[],[ SLOT_arg/LITERAL/x ]> + seventeen || (NUM NUM:'seventeen') || <x,l1,e,[l1:[x|equal(x,17)]],[],[],[ SLOT_arg/LITERAL/x ]> + eighteen || (NUM NUM:'eighteen') || <x,l1,e,[l1:[x|equal(x,18)]],[],[],[ SLOT_arg/LITERAL/x ]> + nineteen || (NUM NUM:'nineteen') || <x,l1,e,[l1:[x|equal(x,19)]],[],[],[ SLOT_arg/LITERAL/x ]> + twenty || (NUM NUM:'twenty') || <x,l1,e,[l1:[x|equal(x,20)]],[],[],[ SLOT_arg/LITERAL/x ]> 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-14 14:54:54 UTC (rev 3740) +++ trunk/components-ext/src/main/resources/tbsl/lexicon/english_oxford.lex 2012-06-14 15:30:01 UTC (rev 3741) @@ -10,7 +10,7 @@ for less than . pounds || (NP NP* (PP P:'for' (NP NUM[num] N:'pounds'))) || <x,l1,<e,t>, [ l1:[ | SLOT_price(x,y), less(y,z) ] ], [ (l2,y,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 ]> - with || (NP NP* (PP P:'with' DP[dp])) || <x,l1,<e,t>, [ l1:[ | empty(x,y) ] ], [ (l2,y,dp,<<e,t>,t>) ], [ l2=l1 ],[]> + 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 ]> square meters || (DP N:'square' N:'meters') || <x,l1,<<e,t>,t>>, [l1:[ | SLOT_size(x,y) ]], [],[],[SLOT_size/DATATYPEPROPERTY/size ]> // MONTHS @@ -26,4 +26,4 @@ september || (DP DP:'september') || <x,l1,<<e,t>,t>, [ l1:[ x | xsd:month(x,9) ]], [],[],[]> october || (DP DP:'october') || <x,l1,<<e,t>,t>, [ l1:[ x | xsd:month(x,10) ]], [],[],[]> november || (DP DP:'november') || <x,l1,<<e,t>,t>, [ l1:[ x | xsd:month(x,11) ]], [],[],[]> - december || (DP DP:'december') || <x,l1,<<e,t>,t>, [ l1:[ x | xsd:month(x,12) ]], [],[],[]> \ No newline at end of file + december || (DP DP:'december') || <x,l1,<<e,t>,t>, [ l1:[ x | xsd:month(x,12) ]], [],[],[]> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2012-06-14 17:15:02
|
Revision: 3742 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=3742&view=rev Author: christinaunger Date: 2012-06-14 17:14:55 +0000 (Thu, 14 Jun 2012) Log Message: ----------- [tbsl] some more hacks - ?\195?\164h... domain adaptations Modified Paths: -------------- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/converter/DRS2SPARQL_Converter.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/templator/SlotBuilder.java trunk/components-ext/src/main/resources/tbsl/lexicon/english_oxford.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 2012-06-14 15:30:01 UTC (rev 3741) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/converter/DRS2SPARQL_Converter.java 2012-06-14 17:14:55 UTC (rev 3742) @@ -98,7 +98,7 @@ return null; } replaceRegextoken(drs); - // System.out.println("--- DRS (after) : " + drs); // DEBUG +// System.out.println("--- DRS (after) : " + drs); // DEBUG for (DiscourseReferent referent : drs.collectDRs()) { if (referent.isMarked()) { @@ -325,7 +325,8 @@ } } if (regex != null) { - query.addFilter(new SPARQL_Filter(new SPARQL_Pair( + query.addFilter(new SPARQL_Filter( + new SPARQL_Pair( new SPARQL_Term(simple.getArguments().get(0).getValue(),false), new SPARQL_Term("'"+regex+"'",false), SPARQL_PairType.REGEX))); @@ -458,7 +459,7 @@ String var; String newvar; String regex = ""; - String[] forbidden = {"regextoken","regex","count","minimum","maximum","greater","less","greaterorequal","lessorequal","equal","sum"}; + String[] forbidden = {"regextoken","regex","count","minimum","maximum","greater","less","greaterorequal","lessorequal","equal","sum","location","description"}; Set<Simple_DRS_Condition> used = new HashSet<Simple_DRS_Condition>(); for (Simple_DRS_Condition c : cs) { 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-06-14 15:30:01 UTC (rev 3741) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/ltag/parser/Preprocessor.java 2012-06-14 17:14:55 UTC (rev 3742) @@ -220,8 +220,8 @@ } m = adjnounPattern.matcher(condensedstring); while (m.find()) { - 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"); + 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"); } m = adjnprepPattern.matcher(condensedstring); while (m.find()) { Modified: trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/templator/SlotBuilder.java =================================================================== --- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/templator/SlotBuilder.java 2012-06-14 15:30:01 UTC (rev 3741) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/templator/SlotBuilder.java 2012-06-14 17:14:55 UTC (rev 3742) @@ -68,7 +68,7 @@ // words.addAll(wordnet.getBestSynonyms(token)); } - String tokenfluent = token.replaceAll(" ","").replaceAll("_",""); + String tokenfluent = token.replaceAll(" ","_");//.replaceAll("_",""); String slotX = "x/" + type + "/"; String slotP = "SLOT_" + tokenfluent + "/" + type + "/"; String slotC = "SLOT_" + tokenfluent + "/CLASS/"; @@ -165,23 +165,30 @@ else if(pos.equals("JJNN") && token.contains("_")) { String[] tokens = token.split("_"); String nntoken = tokens[tokens.length-1]; + String jjtoken = token.replace("SLOT_","").replace(nntoken,"").replace("_"," ").trim(); String slotfluent = "SLOT_" + tokenfluent + "/CLASS/" + token; String slotnn = "SLOT_" + nntoken + "/CLASS/" + nntoken; - String semantics = "<x,l1,<e,t>,[ l1:[ | SLOT_" + tokenfluent + "(x) ] ],[],[],[" + slotfluent + "]> " + - ";; <x,l1,<e,t>,[ l1:[ | SLOT_" + nntoken + "(x)"; - String slots = slotnn; - for (int i=0; i<(tokens.length-1); i++) { - semantics += ", SLOT_" + tokens[i] + "(x)"; - slots += ",SLOT_" + tokens[i] + "/CLASS/" + tokens[i]; - } - semantics += "] ],[],[],[" + slots + "]>"; +// String semantics = "<x,l1,<e,t>,[ l1:[ | SLOT_" + tokenfluent + "(x) ] ],[],[],[" + slotfluent + "]> " + +// ";; <x,l1,<e,t>,[ l1:[ | SLOT_" + nntoken + "(x)"; +// String slots = slotnn; +// for (int i=0; i<(tokens.length-1); i++) { +// semantics += ", SLOT_" + tokens[i] + "(x)"; +// slots += ",SLOT_" + tokens[i] + "/CLASS/" + tokens[i]; +// } +// semantics += "] ],[],[],[" + slots + "]>"; String[] npEntry = {token, "(NP " + treetoken + " )", - semantics }; -// "<x,l1,<e,t>,[ l1:[ | SLOT_" + tokenfluent + "(x) ] ],[],[],[" + slotfluent + "]> ;; " + -// "<x,l1,<e,t>,[ l1:[ | SLOT_" + nntoken + "(x), SLOT_" + jjtoken + "(x) ] ],[],[],[" + slotnn + "," + slotjj + "]>"}; + // semantics }; + "<x,l1,<e,t>,[ l1:[ | SLOT_" + tokenfluent + "(x) ] ],[],[],[" + slotfluent + "]> ;; " + + "<x,l1,<e,t>,[ l1:[ | SLOT_" + nntoken + "(x), SLOT_description(x,y), regex(y,'"+ jjtoken +"')] ],[],[],[" + slotnn + ",SLOT_description/DATATYPEPROPERTY/description ]>"}; + String[] dpEntry = {token, + "(DP (NP " + treetoken + " ))", + // semantics }; + "<x,l1,<<e,t>,t>,[ l1:[ x | SLOT_" + tokenfluent + "(x) ] ],[],[],[" + slotfluent + "]> ;; " + + "<x,l1,<<e,t>,t>,[ l1:[ x | SLOT_" + nntoken + "(x), SLOT_description(x,y), regex(y,'"+ jjtoken +"')] ],[],[],[" + slotnn + ",SLOT_description/DATATYPEPROPERTY/description ]>"}; result.add(npEntry); + result.add(dpEntry); } else if (pos.equals("NNSAME")) { String slot = "SLOT_" + token + "/" + type + "/" + token; 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-14 15:30:01 UTC (rev 3741) +++ trunk/components-ext/src/main/resources/tbsl/lexicon/english_oxford.lex 2012-06-14 17:14:55 UTC (rev 3742) @@ -6,8 +6,10 @@ 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' (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' (NP NUM[num] N:'pounds'))) || <x,l1,<e,t>, [ l1:[ | SLOT_price(x,y), less(y,z) ] ], [ (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:'more' 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 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 ]> 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 ]> 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 ]> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2012-06-15 14:46:56
|
Revision: 3750 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=3750&view=rev Author: christinaunger Date: 2012-06-15 14:46:46 +0000 (Fri, 15 Jun 2012) Log Message: ----------- [tbsl] a few more lexical extensions Modified Paths: -------------- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/converter/DRS2SPARQL_Converter.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/templator/SlotBuilder.java trunk/components-ext/src/main/resources/tbsl/lexicon/english_oxford.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 2012-06-15 14:20:33 UTC (rev 3749) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/converter/DRS2SPARQL_Converter.java 2012-06-15 14:46:46 UTC (rev 3750) @@ -470,7 +470,7 @@ for (DiscourseReferent dr : cond.getArguments()) { if (dr.getValue().equals(var)) { takeit = true; - for (String f : forbidden) if (f.equals(cond.getPredicate())) takeit= false; + for (String f : forbidden) if (cond.getPredicate().contains(f)) takeit= false; } } if (takeit) { 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-06-15 14:20:33 UTC (rev 3749) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/ltag/parser/Preprocessor.java 2012-06-15 14:46:46 UTC (rev 3750) @@ -96,6 +96,7 @@ Pattern whenPattern = Pattern.compile("\\A(when/WRB\\s(.+\\s)(\\w+)/((V[A-Z]+)|(PASS[A-Z]+)))"); Pattern wherePattern = Pattern.compile("\\A(where/WRB\\s(.+\\s)(\\w+)/((V[A-Z]+)|(PASS[A-Z]+)))"); Pattern adjsPattern = Pattern.compile("((\\w+)/JJ.(\\w+)/JJ)"); + Pattern adjnnpPattern = Pattern.compile("((\\w+)(?<!many)/JJ.(\\w+)/NNP(S)?)"); Pattern adjnounPattern = Pattern.compile("((\\w+)(?<!many)/JJ.(\\w+)/NN(S)?)"); Pattern adjnprepPattern = Pattern.compile("((\\w+)(?<!many)/JJ.(\\w+)/NPREP)"); @@ -217,7 +218,12 @@ while (m.find()) { if (VERBOSE) logger.trace("Replacing " + m.group(1) + " by " + m.group(2)+"_"+m.group(3)+"/JJ"); condensedstring = condensedstring.replaceFirst(m.group(1),m.group(2)+"_"+m.group(3)+"/JJ"); - } + } + m = adjnnpPattern.matcher(condensedstring); + while (m.find()) { + if (VERBOSE) logger.trace("Replacing " + m.group(1) + " by " + m.group(2)+"_"+m.group(3)+"/NNP"); + condensedstring = condensedstring.replaceFirst(m.group(1),m.group(2)+"_"+m.group(3)+"/NNP"); + } m = adjnounPattern.matcher(condensedstring); while (m.find()) { if (VERBOSE) logger.trace("Replacing " + m.group(1) + " by " + m.group(2)+"_"+m.group(3)+"/JJNN"); Modified: trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/templator/SlotBuilder.java =================================================================== --- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/templator/SlotBuilder.java 2012-06-15 14:20:33 UTC (rev 3749) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/templator/SlotBuilder.java 2012-06-15 14:46:46 UTC (rev 3750) @@ -79,14 +79,16 @@ } // treetoken String treetoken = "N:'" + token.toLowerCase() + "'"; - if (token.trim().contains(" ")) { - String[] tokenParts = token.split(" "); - treetoken = ""; - for (String t : tokenParts) { - treetoken += " N:'" + t.toLowerCase() + "'"; - } - treetoken = treetoken.trim(); + String[] tokenParts; + if (token.trim().contains(" ")) tokenParts = token.split(" "); +// else if (token.contains("_")) tokenParts = token.split("_"); + else { tokenParts = new String[1]; tokenParts[0] = token; } + treetoken = ""; + for (String t : tokenParts) { + treetoken += " N:'" + t.toLowerCase() + "'"; } + treetoken = treetoken.trim(); + // if (pos.equals("NN") || pos.equals("NNS")) { /* DP */ @@ -165,7 +167,7 @@ else if(pos.equals("JJNN") && token.contains("_")) { String[] tokens = token.split("_"); String nntoken = tokens[tokens.length-1]; - String jjtoken = token.replace("SLOT_","").replace(nntoken,"").replace("_"," ").trim(); + String jjtoken = token.replace("SLOT_","").replace(nntoken,"").trim(); String slotfluent = "SLOT_" + tokenfluent + "/CLASS/" + token; String slotnn = "SLOT_" + nntoken + "/CLASS/" + nntoken; // String semantics = "<x,l1,<e,t>,[ l1:[ | SLOT_" + tokenfluent + "(x) ] ],[],[],[" + slotfluent + "]> " + @@ -302,6 +304,10 @@ String[] wasGerEntry = {token, "(S DP[comp] (VP V:'was' DP[subject] V:'" + token + "'))", "<y,l1,t,[ l1:[ | SLOT_" + token + "(y,z) ] ],[(l2,y,comp,<<e,t>,t>), (l3,z,subject,<<e,t>,t>) ],[ l2=l1, l3=l1 ],[" + symslot + "]>"}; + String[] adjEntry = {token, + "(NP ADJ:'"+token+"' NP*)", + "<x,l1,<e,t>,[ l1:[ | SLOT_description(x,y), regex(y,'"+ token +"')] ],[],[],[ SLOT_description/DATATYPEPROPERTY/description ]>"}; + result.add(adjEntry); result.add(gerEntry); result.add(wasGerEntry); } @@ -331,6 +337,8 @@ result.add(whereEntry1); result.add(whereEntry2); } + + // TODO relative clauses missing! } /* ADJECTIVES */ 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-15 14:20:33 UTC (rev 3749) +++ trunk/components-ext/src/main/resources/tbsl/lexicon/english_oxford.lex 2012-06-15 14:46:46 UTC (rev 3750) @@ -2,12 +2,18 @@ // PREPOSITIONS close to || (NP NP* (PP P:'close' P:'to' DP[dp])) || <x,l1,<e,t>, [ l1:[ | SLOT_closeto(x,y) ] ], [ (l2,y,dp,<<e,t>,t>) ], [ l2=l1 ],[ SLOT_closeto/OBJECTPROPERTY/near ]> + near || (NP NP* (PP P:'near' DP[dp])) || <x,l1,<e,t>, [ l1:[ | SLOT_near(x,y) ] ], [ (l2,y,dp,<<e,t>,t>) ], [ l2=l1 ],[ SLOT_near/OBJECTPROPERTY/near ]> + nearby || (NP NP* (PP P:'nearby' DP[dp])) || <x,l1,<e,t>, [ l1:[ | SLOT_nearby(x,y) ] ], [ (l2,y,dp,<<e,t>,t>) ], [ l2=l1 ],[ SLOT_nearby/OBJECTPROPERTY/near ]> + within walking distance from || (NP NP* (PP P:'within' (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/near ]> + within minutes of || (NP NP* (PP P:'within' (NP N:'minutes' P:'of' DP[dp]))) || <x,l1,<e,t>, [ l1:[ | SLOT_near(x,y) ] ], [ (l2,y,dp,<<e,t>,t>) ], [ l2=l1 ],[ SLOT_near/OBJECTPROPERTY/near ]> + in walking distance from || (NP NP* (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/near ]> + 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/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 ]> 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:'more' 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 less 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), 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 ]> 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 ]> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2012-06-16 10:15:06
|
Revision: 3753 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=3753&view=rev Author: christinaunger Date: 2012-06-16 10:15:00 +0000 (Sat, 16 Jun 2012) Log Message: ----------- [tbsl] repaired count problem Modified Paths: -------------- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/converter/DRS2SPARQL_Converter.java trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/sem/drs/DRS_Quantifier.java trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/sem/drs/reader/DRSParser.java trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/sem/drs/reader/DRSParser.jj trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/sem/dudes/reader/DUDE_Parser.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/sem/dudes/reader/DUDE_ParserTokenManager.java trunk/components-ext/src/main/resources/tbsl/lexicon/english.lex trunk/components-ext/src/main/resources/tbsl/lexicon/english_oxford.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 2012-06-16 04:19:36 UTC (rev 3752) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/converter/DRS2SPARQL_Converter.java 2012-06-16 10:15:00 UTC (rev 3753) @@ -251,7 +251,17 @@ if (predicate.equals("count")) { // COUNT(?x) AS ?c - query.addSelTerm(new SPARQL_Term(simple.getArguments().get(0).getValue(), SPARQL_Aggregate.COUNT, simple.getArguments().get(1).getValue())); + if (simple.getArguments().get(1).getValue().matches("[0-9]+")) { + String fresh = "v"+createFresh(); + query.addSelTerm(new SPARQL_Term(simple.getArguments().get(0).getValue(), SPARQL_Aggregate.COUNT, fresh)); + query.addFilter(new SPARQL_Filter( + new SPARQL_Pair( + new SPARQL_Term(fresh,false), + new SPARQL_Term(simple.getArguments().get(1).getValue(),literal), + SPARQL_PairType.EQ))); + } else { + query.addSelTerm(new SPARQL_Term(simple.getArguments().get(0).getValue(), SPARQL_Aggregate.COUNT, simple.getArguments().get(1).getValue())); + } return query; } else if (predicate.equals("sum")) { query.addSelTerm(new SPARQL_Term(simple.getArguments().get(1).getValue(), SPARQL_Aggregate.SUM)); @@ -313,25 +323,9 @@ query.addFilter(new SPARQL_Filter( new SPARQL_Pair( new SPARQL_Term(simple.getArguments().get(0).getValue(),false), - new SPARQL_Term(simple.getArguments().get(1).getValue(),true), + new SPARQL_Term(simple.getArguments().get(1).getValue().replace("_","").trim(),true), SPARQL_PairType.REGEX))); } - else if (predicate.equals("regextoken")) { - String arg = simple.getArguments().get(1).getValue(); - String regex = null; - for (Slot slot : slots) { - if (slot.getAnchor().equals(arg)) { - if (!slot.getWords().isEmpty()) regex = slot.getWords().get(0); - } - } - if (regex != null) { - query.addFilter(new SPARQL_Filter( - new SPARQL_Pair( - new SPARQL_Term(simple.getArguments().get(0).getValue(),false), - new SPARQL_Term("'"+regex+"'",false), - SPARQL_PairType.REGEX))); - } - } else { if (arity == 1) { SPARQL_Term term = new SPARQL_Term(simple.getArguments().get(0).getValue(),false);term.setIsVariable(true); @@ -409,8 +403,8 @@ secondArg = c.getArguments().get(1); firstIsURI = isUri(firstArg.getValue()); secondIsURI = isUri(secondArg.getValue()); - firstIsInt = firstArg.getValue().matches("[0..9]+"); - secondIsInt = secondArg.getValue().matches("[0..9]+"); + firstIsInt = firstArg.getValue().matches("(\\?)?[0..9]+"); + secondIsInt = secondArg.getValue().matches("(\\?)?[0..9]+"); drs.removeCondition(c); if (firstIsURI || firstIsInt) { Modified: trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/sem/drs/DRS_Quantifier.java =================================================================== --- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/sem/drs/DRS_Quantifier.java 2012-06-16 04:19:36 UTC (rev 3752) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/sem/drs/DRS_Quantifier.java 2012-06-16 10:15:00 UTC (rev 3753) @@ -1,5 +1,5 @@ package org.dllearner.algorithm.tbsl.sem.drs; public enum DRS_Quantifier { - SOME, EVERY, MOST, MANY, HOWMANY, THEMOST, FEW, NO, THELEAST + SOME, EVERY, MOST, MANY, HOWMANY, THEMOST, FEW, NO, THELEAST, OR } Modified: trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/sem/drs/reader/DRSParser.java =================================================================== --- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/sem/drs/reader/DRSParser.java 2012-06-16 04:19:36 UTC (rev 3752) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/sem/drs/reader/DRSParser.java 2012-06-16 10:15:00 UTC (rev 3753) @@ -194,6 +194,7 @@ 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);} + if (quantifier.toString().equals("OR")) {drs.setQuantifier(DRS_Quantifier.OR);} {if (true) return drs;} } else { @@ -523,6 +524,11 @@ return false; } + private boolean jj_3_22() { + if (jj_scan_token(A)) return true; + return false; + } + private boolean jj_3_12() { if (jj_scan_token(HOWMANY)) return true; return false; @@ -544,8 +550,13 @@ return false; } - private boolean jj_3_22() { - if (jj_scan_token(A)) return true; + private boolean jj_3R_3() { + Token xsp; + xsp = jj_scanpos; + if (jj_3_22()) { + jj_scanpos = xsp; + if (jj_3_23()) return true; + } return false; } @@ -560,16 +571,6 @@ return false; } - private boolean jj_3R_3() { - Token xsp; - xsp = jj_scanpos; - if (jj_3_22()) { - jj_scanpos = xsp; - if (jj_3_23()) return true; - } - return false; - } - private boolean jj_3_5() { if (jj_scan_token(5)) return true; if (jj_3R_2()) return true; @@ -581,11 +582,6 @@ return false; } - private boolean jj_3_14() { - if (jj_scan_token(NO)) return true; - return false; - } - private boolean jj_3R_4() { Token xsp; xsp = jj_scanpos; @@ -596,6 +592,11 @@ return false; } + private boolean jj_3_14() { + if (jj_scan_token(NO)) return true; + return false; + } + private boolean jj_3R_1() { if (jj_3R_4()) return true; Token xsp; Modified: trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/sem/drs/reader/DRSParser.jj =================================================================== --- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/sem/drs/reader/DRSParser.jj 2012-06-16 04:19:36 UTC (rev 3752) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/sem/drs/reader/DRSParser.jj 2012-06-16 10:15:00 UTC (rev 3753) @@ -191,6 +191,7 @@ 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);} + if (quantifier.toString().equals("OR")) {drs.setQuantifier(DRS_Quantifier.OR);} return drs; Modified: trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/sem/dudes/reader/DUDE_Parser.java =================================================================== --- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/sem/dudes/reader/DUDE_Parser.java 2012-06-16 04:19:36 UTC (rev 3752) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/sem/dudes/reader/DUDE_Parser.java 2012-06-16 10:15:00 UTC (rev 3753) @@ -412,6 +412,7 @@ 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);} + if (quantifier.toString().equals("OR")) {drs.setQuantifier(DRS_Quantifier.OR);} {if (true) return drs;} } else { @@ -830,14 +831,6 @@ finally { jj_save(39, xla); } } - private boolean jj_3R_13() { - if (jj_3R_7()) return true; - Token xsp; - xsp = jj_scanpos; - if (jj_3_36()) jj_scanpos = xsp; - return false; - } - private boolean jj_3_12() { if (jj_scan_token(2)) return true; if (jj_3R_1()) return true; @@ -891,17 +884,17 @@ return false; } + private boolean jj_3_38() { + if (jj_scan_token(C)) return true; + return false; + } + private boolean jj_3R_11() { if (jj_scan_token(LABEL)) return true; if (jj_scan_token(11)) return true; return false; } - private boolean jj_3_38() { - if (jj_scan_token(C)) return true; - return false; - } - private boolean jj_3R_16() { if (jj_3R_7()) return true; if (jj_scan_token(14)) return true; @@ -923,19 +916,13 @@ return false; } - private boolean jj_3_23() { - if (jj_scan_token(MOST)) return true; - return false; - } - private boolean jj_3_37() { if (jj_scan_token(A)) return true; return false; } - private boolean jj_3_30() { - if (jj_3R_10()) return true; - if (jj_scan_token(6)) return true; + private boolean jj_3_23() { + if (jj_scan_token(MOST)) return true; return false; } @@ -949,6 +936,12 @@ return false; } + private boolean jj_3_30() { + if (jj_3R_10()) return true; + if (jj_scan_token(6)) return true; + return false; + } + private boolean jj_3_34() { if (jj_scan_token(2)) return true; if (jj_3R_4()) return true; @@ -993,17 +986,17 @@ return false; } + private boolean jj_3R_4() { + if (jj_3R_16()) return true; + return false; + } + private boolean jj_3_10() { if (jj_scan_token(9)) return true; if (jj_scan_token(LABEL)) return true; return false; } - private boolean jj_3R_4() { - if (jj_3R_16()) return true; - return false; - } - private boolean jj_3_28() { if (jj_scan_token(NO)) return true; return false; @@ -1175,6 +1168,14 @@ return false; } + private boolean jj_3R_13() { + if (jj_3R_7()) return true; + Token xsp; + xsp = jj_scanpos; + if (jj_3_36()) jj_scanpos = xsp; + return false; + } + private boolean jj_3R_8() { if (jj_3R_10()) return true; Token xsp; 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-06-16 04:19:36 UTC (rev 3752) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/sem/dudes/reader/DUDE_Parser.jj 2012-06-16 10:15:00 UTC (rev 3753) @@ -382,6 +382,7 @@ 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);} + if (quantifier.toString().equals("OR")) {drs.setQuantifier(DRS_Quantifier.OR);} return drs; @@ -504,8 +505,8 @@ //TOKEN: {<WORD: (["a"-"z","A"-"Z","_",".","#",":","0"-"9"])+>} //TOKEN: {<DR: (["?","!"])?(["a"-"z","A"-"Z","0"-"9","."])+>} -TOKEN: {<A: (["a"-"z","A"-"Z","0"-"9","'","_"])+>} -TOKEN: {<B: (["a"-"z","A"-"Z","_",".","#","0"-"9"])+":"(["a"-"z","A"-"Z","_",".","#","0"-"9"])+>} // oder eher: SLOT_([...])+ +TOKEN: {<A: (["a"-"z","A"-"Z","0"-"9","'","_","-"])+>} +TOKEN: {<B: (["a"-"z","A"-"Z","_",".","#","0"-"9"])+":"(["a"-"z","A"-"Z","_",".","#","0"-"9","-"])+>} // oder eher: SLOT_([...])+ TOKEN: {<C: ["?","!"](["a"-"z","A"-"Z","0"-"9"])+>} Token dr() : { Token t; }{ (t=<A> | t=<C>) { return t; } } Modified: trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/sem/dudes/reader/DUDE_ParserTokenManager.java =================================================================== --- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/sem/dudes/reader/DUDE_ParserTokenManager.java 2012-06-16 04:19:36 UTC (rev 3752) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/sem/dudes/reader/DUDE_ParserTokenManager.java 2012-06-16 10:15:00 UTC (rev 3753) @@ -403,7 +403,7 @@ jjCheckNAddTwoStates(3, 4); else if (curChar == 58) jjCheckNAdd(5); - if ((0x3ff008000000000L & l) != 0L) + if ((0x3ff208000000000L & l) != 0L) { if (kind > 26) kind = 26; @@ -417,7 +417,7 @@ jjCheckNAdd(9); else if ((0x8000000200000000L & l) != 0L) jjCheckNAdd(7); - if ((0x3ff008000000000L & l) != 0L) + if ((0x3ff208000000000L & l) != 0L) { if (kind > 26) kind = 26; @@ -432,7 +432,7 @@ jjstateSet[jjnewStateCnt++] = 1; break; case 2: - if ((0x3ff008000000000L & l) == 0L) + if ((0x3ff208000000000L & l) == 0L) break; if (kind > 26) kind = 26; @@ -443,7 +443,7 @@ jjCheckNAddTwoStates(3, 4); break; case 5: - if ((0x3ff400800000000L & l) == 0L) + if ((0x3ff600800000000L & l) == 0L) break; if (kind > 27) kind = 27; Modified: trunk/components-ext/src/main/resources/tbsl/lexicon/english.lex =================================================================== --- trunk/components-ext/src/main/resources/tbsl/lexicon/english.lex 2012-06-16 04:19:36 UTC (rev 3752) +++ trunk/components-ext/src/main/resources/tbsl/lexicon/english.lex 2012-06-16 10:15:00 UTC (rev 3753) @@ -142,8 +142,6 @@ and || (S S* CC:'and' S[s]) || <x,l1,t,[l1:[|]],[(l2,y,s,t)],[l1=l2],[]> and || (DP DP* CC:'and' DP[dp]) || <x,l1,<<e,t>,t>,[l1:[|]],[(l2,y,dp,<<e,t>,t>)],[l1=l2],[]> and || (NP NP* CC:'and' NP[np]) || <x,l1,<e,t>,[l1:[|x=y]],[(l2,y,np,<e,t>)],[l1=l2],[]> - and || (VP VP* CC:'and' VP[vp]) || - - and || (ADJ ADJ* CC:'and' ADJ[adj]) || - but || (S S* CC:'but' S[s]) || <x,l1,t,[l1:[|]],[(l2,y,s,t)],[l1=l2],[]> but || (DP DP* CC:'but' DP[dp]) || <x,l1,<<e,t>,t>,[l1:[|]],[(l2,y,dp,<<e,t>,t>)],[l1=l2],[]> @@ -151,11 +149,10 @@ as well as || (NP NP* CC:'as' CC:'well' CC:'as' NP[np]) || <x,l1,<e,t>,[l1:[|]],[(l2,y,np,<e,t>)],[l1=l2],[]> - or || (S S* CC:'or' S[2]) || - - or || (DP DP* CC:'or' DP[2]) || - - or || (NP NP* CC:'or' NP[2]) || - - or || (VP VP* CC:'or' VP[2]) || - - or || (ADJ ADJ* CC:'or' ADJ[2]) || - + or || (S S* CC:'or' S[cc]) || <y, l2, <<e,t>,t>, [ l1:[ | l2:[ | ] OR y l3:[|] ] ], [ (l4,y,cc,<e,t>) ], [ l4=l3 ],[]> + or || (DP DP* CC:'or' DP[cc]) || <y, l2, <<e,t>,t>, [ l1:[ | l2:[ | ] OR y l3:[|] ] ], [ (l4,y,cc,<e,t>) ], [ l4=l3 ],[]> + or || (NP NP* CC:'or' NP[cc]) || <y, l2, <<e,t>,t>, [ l1:[ | l2:[ | ] OR y l3:[|] ] ], [ (l4,y,cc,<e,t>) ], [ l4=l3 ],[]> + or || (ADJ ADJ* CC:'or' ADJ[cc]) || - // EXISTENTIAL 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-16 04:19:36 UTC (rev 3752) +++ trunk/components-ext/src/main/resources/tbsl/lexicon/english_oxford.lex 2012-06-16 10:15:00 UTC (rev 3753) @@ -4,10 +4,10 @@ close to || (NP NP* (PP P:'close' P:'to' DP[dp])) || <x,l1,<e,t>, [ l1:[ | SLOT_closeto(x,y) ] ], [ (l2,y,dp,<<e,t>,t>) ], [ l2=l1 ],[ SLOT_closeto/OBJECTPROPERTY/near ]> near || (NP NP* (PP P:'near' DP[dp])) || <x,l1,<e,t>, [ l1:[ | SLOT_near(x,y) ] ], [ (l2,y,dp,<<e,t>,t>) ], [ l2=l1 ],[ SLOT_near/OBJECTPROPERTY/near ]> nearby || (NP NP* (PP P:'nearby' DP[dp])) || <x,l1,<e,t>, [ l1:[ | SLOT_nearby(x,y) ] ], [ (l2,y,dp,<<e,t>,t>) ], [ l2=l1 ],[ SLOT_nearby/OBJECTPROPERTY/near ]> - within walking distance from || (NP NP* (PP P:'within' (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/near ]> - within minutes of || (NP NP* (PP P:'within' (NP N:'minutes' P:'of' DP[dp]))) || <x,l1,<e,t>, [ l1:[ | SLOT_near(x,y) ] ], [ (l2,y,dp,<<e,t>,t>) ], [ l2=l1 ],[ SLOT_near/OBJECTPROPERTY/near ]> - in walking distance from || (NP NP* (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/near ]> - 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/near ]> + within walking distance from || (NP NP* (PP P:'within' (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 ]> + within minutes of || (NP NP* (PP P:'within' (NP N:'minutes' P:'of' 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 walking distance from || (NP NP* (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 ]> 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 ]> 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 ]> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2012-06-18 07:37:36
|
Revision: 3757 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=3757&view=rev Author: christinaunger Date: 2012-06-18 07:37:27 +0000 (Mon, 18 Jun 2012) Log Message: ----------- [tbsl] "Oh look... is it a stockbroker? Is it a quantity Surveyor? Is it a church warden? NO! It's Bicycle Repair Man!" Modified Paths: -------------- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/converter/DRS2SPARQL_Converter.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/sparql/SPARQL_Pair.java 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 2012-06-18 07:16:33 UTC (rev 3756) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/converter/DRS2SPARQL_Converter.java 2012-06-18 07:37:27 UTC (rev 3757) @@ -474,7 +474,7 @@ } } if (takeit) { - regex += cond.getPredicate().replace("SLOT","") + " "; + regex += cond.getPredicate().replace("SLOT_","") + " "; used.add(cond); } else { @@ -488,6 +488,7 @@ c.getArguments().add(new DiscourseReferent("'"+regex.trim()+"'")); c.setPredicate("regex"); } + else {} // TODO should not happen! for (Slot s : slots) { if (s.getWords().contains(var)) { s.getWords().remove(var); 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-06-18 07:16:33 UTC (rev 3756) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/ltag/parser/Preprocessor.java 2012-06-18 07:37:27 UTC (rev 3757) @@ -223,7 +223,7 @@ while (m.find()) { // if (!m.group(4).startsWith("NNP")) { 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"); + condensedstring = condensedstring.replaceFirst(m.group(1),m.group(2)+"_"+m.group(3)+"/JJNN "); // } } m = adjnprepPattern.matcher(condensedstring); Modified: trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/sparql/SPARQL_Pair.java =================================================================== --- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/sparql/SPARQL_Pair.java 2012-06-18 07:16:33 UTC (rev 3756) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/sparql/SPARQL_Pair.java 2012-06-18 07:37:27 UTC (rev 3757) @@ -33,7 +33,7 @@ case B: return "BOUND(" + a + ")"; case EQ: - return a + " == " + b; + return a + " = " + b; case GT: return a + " > " + b; case GTEQ: Modified: trunk/components-ext/src/main/resources/tbsl/lexicon/english.lex =================================================================== --- trunk/components-ext/src/main/resources/tbsl/lexicon/english.lex 2012-06-18 07:16:33 UTC (rev 3756) +++ trunk/components-ext/src/main/resources/tbsl/lexicon/english.lex 2012-06-18 07:37:27 UTC (rev 3757) @@ -68,7 +68,7 @@ many || (DP DET:'many' NP[noun]) || <y, l1, <<e,t>,t>, [ l1:[ | l2:[ y | ] MANY y l3:[|] ] ], [ (l4,y,noun,<e,t>) ], [ l4=l2 ],[]> the || (DP DET:'the' NP[noun]) || <x, l1, <<e,t>,t>, [ l1:[x|] ], [ (l2,x,noun,<e,t>) ], [ l2=l1 ],[]> at least || (DP DET:'at' DET:'least' NUM[num] NP[noun]) || <y,l1,<<e,t>,t>,[l1:[ y,j |count(a,y,j), greaterorequal(j,x) ]],[(l2,y,noun,<e,t>),(l3,x,num,e)],[ l1=l2, l2=l3 ],[]> - at most || (DP DET:'at' DET:'most' NUM[num] NP[noun]) || <y,l1,<<e,t>,t>,[l1:[ y,j | count(a,y,j), smallerorequal(j,x) ]],[(l2,y,noun,<e,t>),(l3,x,num,e)],[ l1=l2, l2=l3 ],[]> + at most || (DP DET:'at' DET:'most' NUM[num] NP[noun]) || <y,l1,<<e,t>,t>,[l1:[ y,j | count(a,y,j), lessorequal(j,x) ]],[(l2,y,noun,<e,t>),(l3,x,num,e)],[ l1=l2, l2=l3 ],[]> exactly || (DP DET:'exactly' NUM[num] NP[noun]) || <y,l1,<<e,t>,t>,[l1:[ y,j | count(y,j), equals(j,x) ]],[(l2,y,noun,<e,t>),(l3,x,num,e)],[ l1=l2, l2=l3 ],[]> other || (NP ADJ:'other' NP*) || <x,l1,<e,t>,[ l1:[ | ] ], [],[],[]> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2012-06-18 10:50:56
|
Revision: 3759 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=3759&view=rev Author: christinaunger Date: 2012-06-18 10:50:46 +0000 (Mon, 18 Jun 2012) Log Message: ----------- [tbsl] added proper support for "[PP] and [PP]" Modified Paths: -------------- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/converter/DRS2SPARQL_Converter.java trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/templator/Templator.java trunk/components-ext/src/main/resources/tbsl/lexicon/english.lex trunk/components-ext/src/main/resources/tbsl/lexicon/english_oxford.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 2012-06-18 07:44:24 UTC (rev 3758) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/converter/DRS2SPARQL_Converter.java 2012-06-18 10:50:46 UTC (rev 3759) @@ -76,9 +76,7 @@ slots = ls; Query q = convert(drs, new Query(), false); - if (q == null) { - return null; - } + if (q == null) return null; q.setPrefixes(prefixes); template.setQuery(q); @@ -87,12 +85,13 @@ System.out.println("... done"); } + usedInts = new ArrayList<Integer>(); return template; } private Query convert(DRS drs, Query query, boolean negate) { -// System.out.println("--- DRS (before): " + drs); // DEBUG +// System.out.println("\n--- DRS (before): " + drs); // DEBUG redundantEqualRenaming(drs); if (!restructureEmpty(drs)) { return null; @@ -474,10 +473,10 @@ } } if (takeit) { - regex += cond.getPredicate().replace("SLOT_","") + " "; + regex += cond.getPredicate().replace("SLOT","").replaceAll("_"," "); used.add(cond); } - else { + else if (!cond.getPredicate().equals("regextoken")) { for (DiscourseReferent dr : cond.getArguments()) { if (dr.getValue().equals(var)) dr.setValue(newvar); } @@ -488,7 +487,7 @@ c.getArguments().add(new DiscourseReferent("'"+regex.trim()+"'")); c.setPredicate("regex"); } - else {} // TODO should not happen! + else { used.add(c); } // TODO should not happen! for (Slot s : slots) { if (s.getWords().contains(var)) { s.getWords().remove(var); @@ -497,6 +496,41 @@ } } for (Simple_DRS_Condition cond : used) drs.removeCondition(cond); + + // postprocessing + boolean success = false; + Set<Simple_DRS_Condition> oldconds = new HashSet<Simple_DRS_Condition>(); + for (Simple_DRS_Condition c : drs.getAllSimpleConditions()) { + String d = ""; + String d2 = ""; + String newregex = ""; + if (c.getPredicate().equals("SLOT_description")) { + d = c.getArguments().get(0).getValue(); + d2 = c.getArguments().get(1).getValue(); + for (Simple_DRS_Condition cond : drs.getAllSimpleConditions()) { + if (cond.getPredicate().equals("SLOT_description") && cond.getArguments().get(1).getValue().equals(d)) { + oldconds.add(c); + success = true; + break; + } + } + } + if (success) { + for (Simple_DRS_Condition cond : drs.getAllSimpleConditions()) { + if (cond.getPredicate().equals("regex") && + (cond.getArguments().get(0).getValue().equals(d) || cond.getArguments().get(0).getValue().equals(d2))) { + newregex += cond.getArguments().get(1).getValue().replaceAll("'","").replaceAll("_"," ").trim() + " "; + oldconds.add(cond); + } + } + for (Simple_DRS_Condition cond : oldconds) drs.removeCondition(cond); + List<DiscourseReferent> newrefs = new ArrayList<DiscourseReferent>(); + newrefs.add(new DiscourseReferent(d)); + newrefs.add(new DiscourseReferent("'"+newregex.trim()+"'")); + drs.addCondition(new Simple_DRS_Condition("regex",newrefs)); + break; + } + } } Modified: trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/templator/Templator.java =================================================================== --- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/templator/Templator.java 2012-06-18 07:44:24 UTC (rev 3758) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/templator/Templator.java 2012-06-18 10:50:46 UTC (rev 3759) @@ -57,7 +57,7 @@ boolean UNTAGGED_INPUT = true; boolean USE_NER = false; boolean USE_WORDNET = true; - boolean VERBOSE = true; + boolean VERBOSE = false; private String taggedInput; Modified: trunk/components-ext/src/main/resources/tbsl/lexicon/english.lex =================================================================== --- trunk/components-ext/src/main/resources/tbsl/lexicon/english.lex 2012-06-18 07:44:24 UTC (rev 3758) +++ trunk/components-ext/src/main/resources/tbsl/lexicon/english.lex 2012-06-18 10:50:46 UTC (rev 3759) @@ -142,10 +142,14 @@ and || (S S* CC:'and' S[s]) || <x,l1,t,[l1:[|]],[(l2,y,s,t)],[l1=l2],[]> and || (DP DP* CC:'and' DP[dp]) || <x,l1,<<e,t>,t>,[l1:[|]],[(l2,y,dp,<<e,t>,t>)],[l1=l2],[]> and || (NP NP* CC:'and' NP[np]) || <x,l1,<e,t>,[l1:[|x=y]],[(l2,y,np,<e,t>)],[l1=l2],[]> + and || (PP PP* CC:'and' PP[pp]) || <x,l1,<e,t>,[l1:[|x=y]],[(l2,y,pp,<e,t>)],[l1=l2],[]> + and || (ADJ ADJ* CC:'and' ADJ[adj]) || <x,l1,<e,t>,[l1:[|]],[(l2,y,adj,<e,t>)],[l1=l2],[]> but || (S S* CC:'but' S[s]) || <x,l1,t,[l1:[|]],[(l2,y,s,t)],[l1=l2],[]> but || (DP DP* CC:'but' DP[dp]) || <x,l1,<<e,t>,t>,[l1:[|]],[(l2,y,dp,<<e,t>,t>)],[l1=l2],[]> but || (NP NP* CC:'but' NP[np]) || <x,l1,<e,t>,[l1:[|x=y]],[(l2,y,np,<e,t>)],[l1=l2],[]> + but || (PP PP* CC:'but' PP[pp]) || <x,l1,<e,t>,[l1:[|x=y]],[(l2,y,pp,<e,t>)],[l1=l2],[]> + but || (ADJ ADJ* CC:'but' ADJ[adj]) || <x,l1,<e,t>,[l1:[|]],[(l2,y,adj,<e,t>)],[l1=l2],[]> as well as || (NP NP* CC:'as' CC:'well' CC:'as' NP[np]) || <x,l1,<e,t>,[l1:[|]],[(l2,y,np,<e,t>)],[l1=l2],[]> 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 07:44:24 UTC (rev 3758) +++ trunk/components-ext/src/main/resources/tbsl/lexicon/english_oxford.lex 2012-06-18 10:50:46 UTC (rev 3759) @@ -2,26 +2,37 @@ // PREPOSITIONS close to || (NP NP* (PP P:'close' P:'to' DP[dp])) || <x,l1,<e,t>, [ l1:[ | SLOT_closeto(x,y) ] ], [ (l2,y,dp,<<e,t>,t>) ], [ l2=l1 ],[ SLOT_closeto/OBJECTPROPERTY/near ]> + close to || (PP P:'close' P:'to' DP[dp]) || <x,l1,<e,t>, [ l1:[ | SLOT_closeto(x,y) ] ], [ (l2,y,dp,<<e,t>,t>) ], [ l2=l1 ],[ SLOT_closeto/OBJECTPROPERTY/near ]> near || (NP NP* (PP P:'near' DP[dp])) || <x,l1,<e,t>, [ l1:[ | SLOT_near(x,y) ] ], [ (l2,y,dp,<<e,t>,t>) ], [ l2=l1 ],[ SLOT_near/OBJECTPROPERTY/near ]> + near || (PP P:'near' DP[dp]) || <x,l1,<e,t>, [ l1:[ | SLOT_near(x,y) ] ], [ (l2,y,dp,<<e,t>,t>) ], [ l2=l1 ],[ SLOT_near/OBJECTPROPERTY/near ]> nearby || (NP NP* (PP P:'nearby' DP[dp])) || <x,l1,<e,t>, [ l1:[ | SLOT_nearby(x,y) ] ], [ (l2,y,dp,<<e,t>,t>) ], [ l2=l1 ],[ SLOT_nearby/OBJECTPROPERTY/near ]> + nearby || (PP P:'nearby' DP[dp]) || <x,l1,<e,t>, [ l1:[ | SLOT_nearby(x,y) ] ], [ (l2,y,dp,<<e,t>,t>) ], [ l2=l1 ],[ SLOT_nearby/OBJECTPROPERTY/near ]> within walking distance from || (NP NP* (PP P:'within' (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 ]> + within walking distance from || (PP P:'within' (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 ]> within minutes of || (NP NP* (PP P:'within' (NP N:'minutes' P:'of' 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 ]> + within minutes of || (PP P:'within' (NP N:'minutes' P:'of' 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 walking distance from || (NP NP* (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 ]> + 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 ]> - 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 ]> - 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 ]> + 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 || (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 ]> + 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 ]> 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 ]> square meters || (DP N:'square' N:'meters') || <x,l1,<<e,t>,t>>, [l1:[ | SLOT_size(x,y) ]], [],[],[SLOT_size/DATATYPEPROPERTY/size ]> // MONTHS This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2012-07-04 15:43:01
|
Revision: 3771 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=3771&view=rev Author: christinaunger Date: 2012-07-04 15:42:53 +0000 (Wed, 04 Jul 2012) Log Message: ----------- [tbsl] Added support for "or" (translated as UNION). This still needs to be tested for complex questions. Modified Paths: -------------- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/converter/DRS2SPARQL_Converter.java trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/sem/drs/Complex_DRS_Condition.java trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/sem/drs/DRS.java trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/sem/drs/DRS_Condition.java trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/sem/drs/Negated_DRS.java trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/sem/drs/Simple_DRS_Condition.java trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/sem/drs/reader/DRSParser.java trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/sem/drs/reader/DRSParser.jj trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/sem/drs/reader/DRSParserConstants.java trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/sem/drs/reader/DRSParserTokenManager.java trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/sem/dudes/data/Argument.java trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/sem/dudes/data/Dude.java trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/sem/dudes/reader/DUDE_Parser.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/sem/dudes/reader/DUDE_ParserConstants.java trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/sem/dudes/reader/DUDE_ParserTokenManager.java trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/sem/util/CompositeType.java trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/sem/util/DominanceConstraint.java trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/sem/util/ElementaryType.java trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/sem/util/Label.java trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/sem/util/Type.java trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/sparql/Query.java trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/sparql/SPARQL_Triple.java trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/sparql/Slot.java trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/templator/Templator.java trunk/components-ext/src/main/resources/tbsl/lexicon/english.lex Added Paths: ----------- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/sparql/SPARQL_Union.java 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 2012-07-03 14:16:28 UTC (rev 3770) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/converter/DRS2SPARQL_Converter.java 2012-07-04 15:42:53 UTC (rev 3771) @@ -9,20 +9,7 @@ import org.dllearner.algorithm.tbsl.sem.drs.DiscourseReferent; import org.dllearner.algorithm.tbsl.sem.drs.Negated_DRS; import org.dllearner.algorithm.tbsl.sem.drs.Simple_DRS_Condition; -import org.dllearner.algorithm.tbsl.sparql.Query; -import org.dllearner.algorithm.tbsl.sparql.SPARQL_Aggregate; -import org.dllearner.algorithm.tbsl.sparql.SPARQL_Filter; -import org.dllearner.algorithm.tbsl.sparql.SPARQL_OrderBy; -import org.dllearner.algorithm.tbsl.sparql.SPARQL_Pair; -import org.dllearner.algorithm.tbsl.sparql.SPARQL_PairType; -import org.dllearner.algorithm.tbsl.sparql.SPARQL_Prefix; -import org.dllearner.algorithm.tbsl.sparql.SPARQL_Property; -import org.dllearner.algorithm.tbsl.sparql.SPARQL_QueryType; -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; +import org.dllearner.algorithm.tbsl.sparql.*; public class DRS2SPARQL_Converter { @@ -133,7 +120,7 @@ Set<SPARQL_Triple> statements = new HashSet<SPARQL_Triple>(); for (DRS_Condition condition : drs.getConditions()) { - Set<SPARQL_Triple> scondition = convertCondition(condition, query).getConditions(); + Set<SPARQL_Triple> scondition = convertCondition(condition,query,false).getConditions(); statements.addAll(scondition); if (negate) { for (int i = 0; i < scondition.size(); ++i) { @@ -155,71 +142,100 @@ return query; } - private Query convertCondition(DRS_Condition condition, Query query) { + private Query convertCondition(DRS_Condition condition, Query query, boolean unionMode) { + + Query out; + if (unionMode) out = new Query(); + else out = query; + if (condition.isComplexCondition()) { - if (!isSilent()) { - System.out.print("|complex:" + condition.toString()); - } + if (!isSilent()) System.out.print("|complex:" + condition.toString()); + Complex_DRS_Condition complex = (Complex_DRS_Condition) condition; DRS restrictor = complex.getRestrictor(); DRS_Quantifier quant = complex.getQuantifier(); DRS scope = complex.getScope(); - // call recursively - for (DRS_Condition cond : restrictor.getConditions()) { - query = convertCondition(cond, query); + if (quant.equals(DRS_Quantifier.OR)) { + Set<SPARQL_Triple> conds_res = new HashSet<SPARQL_Triple>(); + Set<SPARQL_Triple> conds_scope = new HashSet<SPARQL_Triple>(); + Set<SPARQL_Filter> filter_res = new HashSet<SPARQL_Filter>(); + Set<SPARQL_Filter> filter_scope = new HashSet<SPARQL_Filter>(); + // call recursively + Query dummy; + for (DRS_Condition cond : restrictor.getConditions()) { + dummy = convertCondition(cond,out,true); + conds_res.addAll(dummy.getConditions()); + filter_res.addAll(dummy.getFilters()); + query.getPrefixes().addAll(dummy.getPrefixes()); + } + for (DRS_Condition cond : scope.getConditions()) { + dummy = convertCondition(cond,out,true); + conds_scope.addAll(dummy.getConditions()); + filter_scope.addAll(dummy.getFilters()); + query.getPrefixes().addAll(dummy.getPrefixes()); + } + query.addUnion(new SPARQL_Union(conds_res,filter_res,conds_scope,filter_scope)); + // TODO also inherit order by, limit, offset, and so on? + return query; + } + else { + // call recursively + for (DRS_Condition cond : restrictor.getConditions()) { + out = convertCondition(cond,out,false); + } + for (DRS_Condition cond : scope.getConditions()) { + out = convertCondition(cond,out,false); + } + + // add the quantifier at last + DiscourseReferent ref = complex.getReferent(); + String sref = ref.getValue(); + String fresh; + if (!isSilent()) System.out.print("|quantor:" + quant); + + switch (quant) { + case HOWMANY: + out.addSelTerm(new SPARQL_Term(sref, SPARQL_Aggregate.COUNT)); + break; + case EVERY: + // probably save to ignore // TODO unless in cases like "which actor starred in every movie by spielberg?" + // query.addFilter(new SPARQL_Filter(new SPARQL_Term(sref))); + break; + case NO: + SPARQL_Filter f = new SPARQL_Filter(); + f.addNotBound(new SPARQL_Term(sref)); + out.addFilter(f); + break; + case FEW: // + break; + case MANY: // + break; + case MOST: // + break; + case SOME: // + break; + case THELEAST: + fresh = "c"+createFresh(); + out.addSelTerm(new SPARQL_Term(sref, SPARQL_Aggregate.COUNT,fresh)); + out.addOrderBy(new SPARQL_Term(fresh, SPARQL_OrderBy.ASC)); + out.setLimit(1); + break; + case THEMOST: + fresh = "c"+createFresh(); + out.addSelTerm(new SPARQL_Term(sref, SPARQL_Aggregate.COUNT,fresh)); + out.addOrderBy(new SPARQL_Term(fresh, SPARQL_OrderBy.DESC)); + out.setLimit(1); + break; + } } - for (DRS_Condition cond : scope.getConditions()) { - query = convertCondition(cond, query); - } - // add the quantifier at last - DiscourseReferent ref = complex.getReferent(); - String sref = ref.getValue(); - String fresh; - if (!isSilent()) { - System.out.print("|quantor:" + quant); - } - switch (quant) { - case HOWMANY: - query.addSelTerm(new SPARQL_Term(sref, SPARQL_Aggregate.COUNT)); - break; - case EVERY: - // probably save to ignore // TODO unless in cases like "which actor starred in every movie by spielberg?" - // query.addFilter(new SPARQL_Filter(new SPARQL_Term(sref))); - break; - case NO: - SPARQL_Filter f = new SPARQL_Filter(); - f.addNotBound(new SPARQL_Term(sref)); - query.addFilter(f); - break; - case FEW: // - break; - case MANY: // - break; - case MOST: // - break; - case SOME: // - break; - case THELEAST: - fresh = "c"+createFresh(); - query.addSelTerm(new SPARQL_Term(sref, SPARQL_Aggregate.COUNT,fresh)); - query.addOrderBy(new SPARQL_Term(fresh, SPARQL_OrderBy.ASC)); - query.setLimit(1); - break; - case THEMOST: - fresh = "c"+createFresh(); - query.addSelTerm(new SPARQL_Term(sref, SPARQL_Aggregate.COUNT,fresh)); - query.addOrderBy(new SPARQL_Term(fresh, SPARQL_OrderBy.DESC)); - query.setLimit(1); - break; - } } else if (condition.isNegatedCondition()) { if (!isSilent()) { System.out.print("|negation:" + condition.toString()); } Negated_DRS neg = (Negated_DRS) condition; - query = convert(neg.getDRS(), query, true); + out = convert(neg.getDRS(), out, true); } else { Simple_DRS_Condition simple = (Simple_DRS_Condition) condition; @@ -256,74 +272,74 @@ // COUNT(?x) AS ?c if (simple.getArguments().get(1).getValue().matches("[0-9]+")) { String fresh = "v"+createFresh(); - query.addSelTerm(new SPARQL_Term(simple.getArguments().get(0).getValue(), SPARQL_Aggregate.COUNT, fresh)); - query.addFilter(new SPARQL_Filter( + out.addSelTerm(new SPARQL_Term(simple.getArguments().get(0).getValue(), SPARQL_Aggregate.COUNT, fresh)); + out.addFilter(new SPARQL_Filter( new SPARQL_Pair( new SPARQL_Term(fresh,false), new SPARQL_Term(simple.getArguments().get(1).getValue(),literal), SPARQL_PairType.EQ))); } else { - query.addSelTerm(new SPARQL_Term(simple.getArguments().get(0).getValue(), SPARQL_Aggregate.COUNT, simple.getArguments().get(1).getValue())); + out.addSelTerm(new SPARQL_Term(simple.getArguments().get(0).getValue(), SPARQL_Aggregate.COUNT, simple.getArguments().get(1).getValue())); } - return query; + return out; } else if (predicate.equals("sum")) { - query.addSelTerm(new SPARQL_Term(simple.getArguments().get(1).getValue(), SPARQL_Aggregate.SUM)); - return query; + out.addSelTerm(new SPARQL_Term(simple.getArguments().get(1).getValue(), SPARQL_Aggregate.SUM)); + return out; } else if (predicate.equals("greater")) { - query.addFilter(new SPARQL_Filter( + out.addFilter(new SPARQL_Filter( new SPARQL_Pair( new SPARQL_Term(simple.getArguments().get(0).getValue(),false), new SPARQL_Term(simple.getArguments().get(1).getValue(),literal), SPARQL_PairType.GT))); - return query; + return out; } else if (predicate.equals("greaterorequal")) { - query.addFilter(new SPARQL_Filter( + out.addFilter(new SPARQL_Filter( new SPARQL_Pair( new SPARQL_Term(simple.getArguments().get(0).getValue(),false), new SPARQL_Term(simple.getArguments().get(1).getValue(),literal), SPARQL_PairType.GTEQ))); - return query; + return out; } else if (predicate.equals("less")) { - query.addFilter(new SPARQL_Filter( + out.addFilter(new SPARQL_Filter( new SPARQL_Pair( new SPARQL_Term(simple.getArguments().get(0).getValue(),false), new SPARQL_Term(simple.getArguments().get(1).getValue(),literal), SPARQL_PairType.LT))); - return query; + return out; } else if (predicate.equals("lessorequal")) { - query.addFilter(new SPARQL_Filter( + out.addFilter(new SPARQL_Filter( new SPARQL_Pair( new SPARQL_Term(simple.getArguments().get(0).getValue(),false), new SPARQL_Term(simple.getArguments().get(1).getValue(),literal), SPARQL_PairType.LTEQ))); - return query; + return out; } else if (predicate.equals("maximum")) { // 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; + out.addOrderBy(new SPARQL_Term(simple.getArguments().get(0).getValue(), SPARQL_OrderBy.DESC)); + out.setLimit(1); + return out; } else if (predicate.equals("minimum")) { - query.addSelTerm(new SPARQL_Term(simple.getArguments().get(0).getValue(),false)); - query.addOrderBy(new SPARQL_Term(simple.getArguments().get(0).getValue(), SPARQL_OrderBy.ASC)); - query.setLimit(1); - return query; + out.addSelTerm(new SPARQL_Term(simple.getArguments().get(0).getValue(),false)); + out.addOrderBy(new SPARQL_Term(simple.getArguments().get(0).getValue(), SPARQL_OrderBy.ASC)); + out.setLimit(1); + return out; } else if (predicate.equals("equal")) { - query.addFilter(new SPARQL_Filter( + out.addFilter(new SPARQL_Filter( new SPARQL_Pair( new SPARQL_Term(simple.getArguments().get(0).getValue(),true), new SPARQL_Term(simple.getArguments().get(1).getValue(),literal), SPARQL_PairType.EQ))); - return query; + return out; } else if (predicate.equals("DATE")) { - query.addFilter(new SPARQL_Filter( + out.addFilter(new SPARQL_Filter( new SPARQL_Pair( new SPARQL_Term(simple.getArguments().get(0).getValue(),false), new SPARQL_Term("'^"+simple.getArguments().get(1).getValue()+"'",true), SPARQL_PairType.REGEX))); } else if (predicate.equals("regex")) { - query.addFilter(new SPARQL_Filter( + out.addFilter(new SPARQL_Filter( new SPARQL_Pair( new SPARQL_Term(simple.getArguments().get(0).getValue(),false), new SPARQL_Term(simple.getArguments().get(1).getValue().replace("_","").trim(),true), @@ -332,12 +348,12 @@ else { if (arity == 1) { SPARQL_Term term = new SPARQL_Term(simple.getArguments().get(0).getValue(),false);term.setIsVariable(true); - query.addCondition(new SPARQL_Triple(term,new SPARQL_Property("type",new SPARQL_Prefix("rdf","")),prop)); + out.addCondition(new SPARQL_Triple(term,new SPARQL_Property("type",new SPARQL_Prefix("rdf","")),prop)); } else if (arity == 2) { String arg1 = simple.getArguments().get(0).getValue();SPARQL_Term term1 = new SPARQL_Term(arg1,false);term1.setIsVariable(true); String arg2 = simple.getArguments().get(1).getValue();SPARQL_Term term2 = new SPARQL_Term(arg2,false);term2.setIsVariable(true); - query.addCondition(new SPARQL_Triple(term1, prop, term2)); + out.addCondition(new SPARQL_Triple(term1, prop, term2)); } else if (arity > 2) { // TODO @@ -349,7 +365,7 @@ if (oxford) { Hashtable<String,Integer> vs = new Hashtable<String,Integer>(); String v1; String v2; - for (SPARQL_Triple c : query.getConditions()) { + for (SPARQL_Triple c : out.getConditions()) { v1 = c.getVariable().toString().replace("?",""); v2 = c.getValue().toString().replace("?",""); // is it a slot variable? @@ -379,11 +395,11 @@ if (maxvar != null) { SPARQL_Term term = new SPARQL_Term(maxvar); term.setIsVariable(true); - query.addSelTerm(term); + out.addSelTerm(term); } } - return query; + return out; } public void redundantEqualRenaming(DRS drs) { Modified: trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/sem/drs/Complex_DRS_Condition.java =================================================================== --- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/sem/drs/Complex_DRS_Condition.java 2012-07-03 14:16:28 UTC (rev 3770) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/sem/drs/Complex_DRS_Condition.java 2012-07-04 15:42:53 UTC (rev 3771) @@ -25,8 +25,7 @@ } // full constructors - public Complex_DRS_Condition(DRS_Quantifier quantifier, - DiscourseReferent referent, DRS restrictor, DRS scope) { + public Complex_DRS_Condition(DRS_Quantifier quantifier,DiscourseReferent referent, DRS restrictor, DRS scope) { m_Quantifier = quantifier; m_Referent = referent; m_Restrictor = restrictor; @@ -71,10 +70,20 @@ public String toString() { - return m_Restrictor + " " + m_Quantifier + " " + m_Referent + " " - + m_Scope + "\n"; + String out = m_Restrictor + " " + m_Quantifier + " "; + if (!m_Referent.m_Referent.equals("null")) out += m_Referent + " "; + out += m_Scope + "\n"; + return out; } + public String toTex() { + + String out = m_Restrictor.toTex() + " \\langle " + m_Quantifier + " "; + if (!m_Referent.m_Referent.equals("null")) out += m_Referent; + out += " \\rangle " + m_Scope.toTex(); + + return out; + } public void replaceLabel(Label label1, Label label2) { m_Restrictor.replaceLabel(label1, label2); @@ -100,7 +109,7 @@ Set<String> variables = new HashSet<String>(); - variables.add(m_Referent.m_Referent); + if (!m_Referent.m_Referent.equals("null")) variables.add(m_Referent.m_Referent); variables.addAll(m_Restrictor.collectVariables()); variables.addAll(m_Scope.collectVariables()); @@ -117,8 +126,8 @@ public List<Label> getAllLabels() { List<Label> result = new ArrayList<Label>(); - result.add(m_Restrictor.getLabel()); - result.add(m_Scope.getLabel()); + result.addAll(m_Restrictor.getAllLabels()); + result.addAll(m_Scope.getAllLabels()); return result; } @@ -137,8 +146,7 @@ } public DRS_Condition clone() { - return (new Complex_DRS_Condition(m_Quantifier, m_Referent, - m_Restrictor.clone(), m_Scope.clone())); + return (new Complex_DRS_Condition(m_Quantifier, m_Referent, m_Restrictor.clone(), m_Scope.clone())); } @Override Modified: trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/sem/drs/DRS.java =================================================================== --- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/sem/drs/DRS.java 2012-07-03 14:16:28 UTC (rev 3770) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/sem/drs/DRS.java 2012-07-04 15:42:53 UTC (rev 3771) @@ -110,6 +110,25 @@ return string; } + public String toTex() { + + String string =""; + if (m_Label != null) string = string += m_Label.toTex() + ":"; + string += "\\parbox{5cm}{\\Drs{"; + + for (Iterator<DiscourseReferent> i = m_DiscourseReferents.iterator(); i.hasNext();) { + string += i.next().toString(); + if (i.hasNext()) string += ","; + } + string += "}{"; + + for (DRS_Condition cond : m_DRS_Conditions) { + string += cond.toTex() + " \\\\ "; + } + string+= "}}"; + + return string; + } public Label getLabel() { Modified: trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/sem/drs/DRS_Condition.java =================================================================== --- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/sem/drs/DRS_Condition.java 2012-07-03 14:16:28 UTC (rev 3770) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/sem/drs/DRS_Condition.java 2012-07-04 15:42:53 UTC (rev 3771) @@ -13,6 +13,7 @@ // iii) a complex condition public String toString(); + public String toTex(); public void replaceReferent(String ref1, String ref2); public void replaceEqualRef(DiscourseReferent dr1, DiscourseReferent dr2, boolean isInUpperUniverse); Modified: trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/sem/drs/Negated_DRS.java =================================================================== --- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/sem/drs/Negated_DRS.java 2012-07-03 14:16:28 UTC (rev 3770) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/sem/drs/Negated_DRS.java 2012-07-04 15:42:53 UTC (rev 3771) @@ -36,6 +36,9 @@ { return "NOT "+m_DRS; } + public String toTex() { + return "\\lnot "+m_DRS.toTex(); + } public void replaceLabel(Label label1, Label label2) { m_DRS.replaceLabel(label1, label2); Modified: trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/sem/drs/Simple_DRS_Condition.java =================================================================== --- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/sem/drs/Simple_DRS_Condition.java 2012-07-03 14:16:28 UTC (rev 3770) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/sem/drs/Simple_DRS_Condition.java 2012-07-04 15:42:53 UTC (rev 3771) @@ -1,10 +1,6 @@ package org.dllearner.algorithm.tbsl.sem.drs; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashSet; -import java.util.List; -import java.util.Set; +import java.util.*; import org.dllearner.algorithm.tbsl.sem.util.Label; @@ -45,6 +41,15 @@ return m_Predicate+string; } + public String toTex() { + String out = "\\text{"+m_Predicate.replaceAll("\\_","\\\\_")+"}("; + for (Iterator<DiscourseReferent> i = m_Arguments.iterator(); i.hasNext();) { + out += i.next().toString(); + if (i.hasNext()) out += ","; + } + out += ")"; + return out; + } // get methods Modified: trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/sem/drs/reader/DRSParser.java =================================================================== --- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/sem/drs/reader/DRSParser.java 2012-07-03 14:16:28 UTC (rev 3770) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/sem/drs/reader/DRSParser.java 2012-07-04 15:42:53 UTC (rev 3771) @@ -120,12 +120,12 @@ List<DiscourseReferent> dr_list; Token dr1; Token dr2; - Token dr; + Token dr = null; Token predicate; Token quantifier; DRS drs1; DRS drs2; - if (jj_2_15(2)) { + if (jj_2_17(2)) { predicate = word(); jj_consume_token(6); dr_list = DR_List(); @@ -136,7 +136,7 @@ condition.setPredicate(predicate.toString()); condition.setArguments(dr_list); {if (true) return condition;} - } else if (jj_2_16(2)) { + } else if (jj_2_18(2)) { dr1 = dr(); jj_consume_token(8); dr2 = dr(); @@ -147,13 +147,13 @@ condition.addArgument(new DiscourseReferent(dr1.toString())); condition.addArgument(new DiscourseReferent(dr2.toString())); {if (true) return condition;} - } else if (jj_2_17(2)) { + } else if (jj_2_19(2)) { jj_consume_token(9); drs1 = DRS(); Negated_DRS drs = new Negated_DRS(); drs.setDRS(drs1); {if (true) return drs;} - } else if (jj_2_18(2)) { + } else if (jj_2_20(2)) { drs1 = DRS(); if (jj_2_6(2)) { quantifier = jj_consume_token(EVERY); @@ -173,17 +173,24 @@ quantifier = jj_consume_token(MANY); } else if (jj_2_14(2)) { quantifier = jj_consume_token(NO); + } else if (jj_2_15(2)) { + quantifier = jj_consume_token(OR); } else { jj_consume_token(-1); throw new ParseException(); } - dr = dr(); + if (jj_2_16(2)) { + dr = dr(); + } else { + ; + } drs2 = DRS(); - Complex_DRS_Condition drs; + Complex_DRS_Condition drs; drs = new Complex_DRS_Condition(); - drs.setRestrictor(drs1); + drs.setRestrictor(drs1); drs.setScope(drs2); - drs.setReferent(new DiscourseReferent(dr.toString())); + if (dr != null) drs.setReferent(new DiscourseReferent(dr.toString())); + else drs.setReferent(new DiscourseReferent("null")); if (quantifier.toString().equals("EVERY")) {drs.setQuantifier(DRS_Quantifier.EVERY);} if (quantifier.toString().equals("SOME")) {drs.setQuantifier(DRS_Quantifier.SOME);} @@ -209,7 +216,7 @@ Token dr; List<DiscourseReferent> dr_list=null; dr = dr(); - if (jj_2_19(2)) { + if (jj_2_21(2)) { jj_consume_token(5); dr_list = DR_List(); } else { @@ -236,9 +243,9 @@ final public Token dr() throws ParseException { Token t; - if (jj_2_20(2)) { + if (jj_2_22(2)) { t = jj_consume_token(A); - } else if (jj_2_21(2)) { + } else if (jj_2_23(2)) { t = jj_consume_token(C); } else { jj_consume_token(-1); @@ -250,9 +257,9 @@ final public Token word() throws ParseException { Token t; - if (jj_2_22(2)) { + if (jj_2_24(2)) { t = jj_consume_token(A); - } else if (jj_2_23(2)) { + } else if (jj_2_25(2)) { t = jj_consume_token(B); } else { jj_consume_token(-1); @@ -423,12 +430,26 @@ finally { jj_save(22, xla); } } + private boolean jj_2_24(int xla) { + jj_la = xla; jj_lastpos = jj_scanpos = token; + try { return !jj_3_24(); } + catch(LookaheadSuccess ls) { return true; } + finally { jj_save(23, xla); } + } + + private boolean jj_2_25(int xla) { + jj_la = xla; jj_lastpos = jj_scanpos = token; + try { return !jj_3_25(); } + catch(LookaheadSuccess ls) { return true; } + finally { jj_save(24, xla); } + } + private boolean jj_3_2() { if (jj_3R_1()) return true; return false; } - private boolean jj_3_18() { + private boolean jj_3_20() { if (jj_3R_5()) return true; return false; } @@ -438,13 +459,18 @@ return false; } - private boolean jj_3_19() { + private boolean jj_3_16() { + if (jj_3R_3()) return true; + return false; + } + + private boolean jj_3_21() { if (jj_scan_token(5)) return true; if (jj_3R_6()) return true; return false; } - private boolean jj_3_17() { + private boolean jj_3_19() { if (jj_scan_token(9)) return true; if (jj_3R_5()) return true; return false; @@ -466,7 +492,7 @@ } private boolean jj_3R_6() { - if (jj_3R_4()) return true; + if (jj_3R_3()) return true; return false; } @@ -475,6 +501,11 @@ return false; } + private boolean jj_3_15() { + if (jj_scan_token(OR)) return true; + return false; + } + private boolean jj_3_1() { if (jj_scan_token(LABEL)) return true; if (jj_scan_token(1)) return true; @@ -497,8 +528,13 @@ return false; } - private boolean jj_3_16() { - if (jj_3R_4()) return true; + private boolean jj_3_25() { + if (jj_scan_token(B)) return true; + return false; + } + + private boolean jj_3_18() { + if (jj_3R_3()) return true; if (jj_scan_token(8)) return true; return false; } @@ -509,11 +545,6 @@ } private boolean jj_3_23() { - if (jj_scan_token(B)) return true; - return false; - } - - private boolean jj_3_21() { if (jj_scan_token(C)) return true; return false; } @@ -524,6 +555,21 @@ return false; } + private boolean jj_3_24() { + if (jj_scan_token(A)) return true; + return false; + } + + private boolean jj_3R_4() { + Token xsp; + xsp = jj_scanpos; + if (jj_3_24()) { + jj_scanpos = xsp; + if (jj_3_25()) return true; + } + return false; + } + private boolean jj_3_22() { if (jj_scan_token(A)) return true; return false; @@ -537,13 +583,13 @@ private boolean jj_3R_7() { Token xsp; xsp = jj_scanpos; - if (jj_3_15()) { + if (jj_3_17()) { jj_scanpos = xsp; - if (jj_3_16()) { + if (jj_3_18()) { jj_scanpos = xsp; - if (jj_3_17()) { + if (jj_3_19()) { jj_scanpos = xsp; - if (jj_3_18()) return true; + if (jj_3_20()) return true; } } } @@ -560,8 +606,8 @@ return false; } - private boolean jj_3_15() { - if (jj_3R_3()) return true; + private boolean jj_3_17() { + if (jj_3R_4()) return true; if (jj_scan_token(6)) return true; return false; } @@ -577,28 +623,13 @@ return false; } - private boolean jj_3_20() { - if (jj_scan_token(A)) return true; - return false; - } - - private boolean jj_3R_4() { - Token xsp; - xsp = jj_scanpos; - if (jj_3_20()) { - jj_scanpos = xsp; - if (jj_3_21()) return true; - } - return false; - } - private boolean jj_3_14() { if (jj_scan_token(NO)) return true; return false; } private boolean jj_3R_1() { - if (jj_3R_4()) return true; + if (jj_3R_3()) return true; Token xsp; xsp = jj_scanpos; if (jj_3_4()) jj_scanpos = xsp; @@ -629,7 +660,7 @@ private static void jj_la1_init_0() { jj_la1_0 = new int[] {}; } - final private JJCalls[] jj_2_rtns = new JJCalls[23]; + final private JJCalls[] jj_2_rtns = new JJCalls[25]; private boolean jj_rescan = false; private int jj_gc = 0; @@ -813,7 +844,7 @@ /** Generate ParseException. */ public ParseException generateParseException() { jj_expentries.clear(); - boolean[] la1tokens = new boolean[28]; + boolean[] la1tokens = new boolean[29]; if (jj_kind >= 0) { la1tokens[jj_kind] = true; jj_kind = -1; @@ -827,7 +858,7 @@ } } } - for (int i = 0; i < 28; i++) { + for (int i = 0; i < 29; i++) { if (la1tokens[i]) { jj_expentry = new int[1]; jj_expentry[0] = i; @@ -854,7 +885,7 @@ private void jj_rescan_token() { jj_rescan = true; - for (int i = 0; i < 23; i++) { + for (int i = 0; i < 25; i++) { try { JJCalls p = jj_2_rtns[i]; do { @@ -884,6 +915,8 @@ case 20: jj_3_21(); break; case 21: jj_3_22(); break; case 22: jj_3_23(); break; + case 23: jj_3_24(); break; + case 24: jj_3_25(); break; } } p = p.next; Modified: trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/sem/drs/reader/DRSParser.jj =================================================================== --- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/sem/drs/reader/DRSParser.jj 2012-07-03 14:16:28 UTC (rev 3770) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/sem/drs/reader/DRSParser.jj 2012-07-04 15:42:53 UTC (rev 3771) @@ -131,7 +131,7 @@ List<DiscourseReferent> dr_list; Token dr1; Token dr2; - Token dr; + Token dr = null; Token predicate; Token quantifier; DRS drs1; @@ -174,13 +174,14 @@ | drs1=DRS() (quantifier=<EVERY> | quantifier=<SOME> | quantifier=<AFEW> | quantifier=<MOST> | quantifier=<THEMOST> | quantifier=<THELEAST> | - quantifier=<HOWMANY> | quantifier=<MANY> | quantifier=<NO>) dr=dr() drs2=DRS() + quantifier=<HOWMANY> | quantifier=<MANY> | quantifier=<NO> | quantifier=<OR>) (dr=dr())? drs2=DRS() { - Complex_DRS_Condition drs; + Complex_DRS_Condition drs; drs = new Complex_DRS_Condition(); - drs.setRestrictor(drs1); + drs.setRestrictor(drs1); drs.setScope(drs2); - drs.setReferent(new DiscourseReferent(dr.toString())); + if (dr != null) drs.setReferent(new DiscourseReferent(dr.toString())); + else drs.setReferent(new DiscourseReferent("null")); if (quantifier.toString().equals("EVERY")) {drs.setQuantifier(DRS_Quantifier.EVERY);} if (quantifier.toString().equals("SOME")) {drs.setQuantifier(DRS_Quantifier.SOME);} @@ -243,6 +244,8 @@ TOKEN: {<NO: "NO">} +TOKEN: {<OR: "OR">} + TOKEN: {<HOWMANY: "HOWMANY">} TOKEN: {<LABEL: "l"(["0"-"9"])+>} Modified: trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/sem/drs/reader/DRSParserConstants.java =================================================================== --- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/sem/drs/reader/DRSParserConstants.java 2012-07-03 14:16:28 UTC (rev 3770) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/sem/drs/reader/DRSParserConstants.java 2012-07-04 15:42:53 UTC (rev 3771) @@ -27,17 +27,19 @@ /** RegularExpression Id. */ int NO = 17; /** RegularExpression Id. */ - int HOWMANY = 18; + int OR = 18; /** RegularExpression Id. */ - int LABEL = 19; + int HOWMANY = 19; /** RegularExpression Id. */ - int A = 20; + int LABEL = 20; /** RegularExpression Id. */ - int B = 21; + int A = 21; /** RegularExpression Id. */ - int C = 22; + int B = 22; /** RegularExpression Id. */ - int QUOTED_STRING = 23; + int C = 23; + /** RegularExpression Id. */ + int QUOTED_STRING = 24; /** Lexical state. */ int DEFAULT = 0; @@ -62,6 +64,7 @@ "\"AFEW\"", "\"MANY\"", "\"NO\"", + "\"OR\"", "\"HOWMANY\"", "<LABEL>", "<A>", Modified: trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/sem/drs/reader/DRSParserTokenManager.java =================================================================== --- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/sem/drs/reader/DRSParserTokenManager.java 2012-07-03 14:16:28 UTC (rev 3770) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/sem/drs/reader/DRSParserTokenManager.java 2012-07-04 15:42:53 UTC (rev 3771) @@ -20,29 +20,29 @@ switch (pos) { case 0: - if ((active0 & 0x7fe00L) != 0L) + if ((active0 & 0xffe00L) != 0L) { - jjmatchedKind = 20; + jjmatchedKind = 21; return 4; } return -1; case 1: - if ((active0 & 0x5fc00L) != 0L) + if ((active0 & 0x9fc00L) != 0L) { if (jjmatchedPos != 1) { - jjmatchedKind = 20; + jjmatchedKind = 21; jjmatchedPos = 1; } return 4; } - if ((active0 & 0x20200L) != 0L) + if ((active0 & 0x60200L) != 0L) return 4; return -1; case 2: - if ((active0 & 0x5fc00L) != 0L) + if ((active0 & 0x9fc00L) != 0L) { - jjmatchedKind = 20; + jjmatchedKind = 21; jjmatchedPos = 2; return 4; } @@ -52,9 +52,9 @@ case 3: if ((active0 & 0x19800L) != 0L) return 4; - if ((active0 & 0x46400L) != 0L) + if ((active0 & 0x86400L) != 0L) { - jjmatchedKind = 20; + jjmatchedKind = 21; jjmatchedPos = 3; return 4; } @@ -62,27 +62,27 @@ case 4: if ((active0 & 0x400L) != 0L) return 4; - if ((active0 & 0x46000L) != 0L) + if ((active0 & 0x86000L) != 0L) { - jjmatchedKind = 20; + jjmatchedKind = 21; jjmatchedPos = 4; return 4; } return -1; case 5: - if ((active0 & 0x46000L) != 0L) + if ((active0 & 0x86000L) != 0L) { - jjmatchedKind = 20; + jjmatchedKind = 21; jjmatchedPos = 5; return 4; } return -1; case 6: - if ((active0 & 0x42000L) != 0L) + if ((active0 & 0x82000L) != 0L) return 4; if ((active0 & 0x4000L) != 0L) { - jjmatchedKind = 20; + jjmatchedKind = 21; jjmatchedPos = 6; return 4; } @@ -120,11 +120,13 @@ case 69: return jjMoveStringLiteralDfa1_0(0x400L); case 72: - return jjMoveStringLiteralDfa1_0(0x40000L); + return jjMoveStringLiteralDfa1_0(0x80000L); case 77: return jjMoveStringLiteralDfa1_0(0x10800L); case 78: return jjMoveStringLiteralDfa1_0(0x20200L); + case 79: + return jjMoveStringLiteralDfa1_0(0x40000L); case 83: return jjMoveStringLiteralDfa1_0(0x1000L); case 84: @@ -160,7 +162,11 @@ jjmatchedKind = 17; jjmatchedPos = 1; } - return jjMoveStringLiteralDfa2_0(active0, 0x41a00L); + return jjMoveStringLiteralDfa2_0(active0, 0x81a00L); + case 82: + if ((active0 & 0x40000L) != 0L) + return jjStartNfaWithStates_0(1, 18, 4); + break; case 86: return jjMoveStringLiteralDfa2_0(active0, 0x400L); default : @@ -192,7 +198,7 @@ return jjStartNfaWithStates_0(2, 9, 4); break; case 87: - return jjMoveStringLiteralDfa3_0(active0, 0x40000L); + return jjMoveStringLiteralDfa3_0(active0, 0x80000L); default : break; } @@ -216,7 +222,7 @@ case 76: return jjMoveStringLiteralDfa4_0(active0, 0x4000L); case 77: - return jjMoveStringLiteralDfa4_0(active0, 0x42000L); + return jjMoveStringLiteralDfa4_0(active0, 0x82000L); case 82: return jjMoveStringLiteralDfa4_0(active0, 0x400L); case 84: @@ -248,7 +254,7 @@ switch(curChar) { case 65: - return jjMoveStringLiteralDfa5_0(active0, 0x40000L); + return jjMoveStringLiteralDfa5_0(active0, 0x80000L); case 69: return jjMoveStringLiteralDfa5_0(active0, 0x4000L); case 79: @@ -276,7 +282,7 @@ case 65: return jjMoveStringLiteralDfa6_0(active0, 0x4000L); case 78: - return jjMoveStringLiteralDfa6_0(active0, 0x40000L); + return jjMoveStringLiteralDfa6_0(active0, 0x80000L); case 83: return jjMoveStringLiteralDfa6_0(active0, 0x2000L); default : @@ -302,8 +308,8 @@ return jjStartNfaWithStates_0(6, 13, 4); break; case 89: - if ((active0 & 0x40000L) != 0L) - return jjStartNfaWithStates_0(6, 18, 4); + if ((active0 & 0x80000L) != 0L) + return jjStartNfaWithStates_0(6, 19, 4); break; default : break; @@ -366,8 +372,8 @@ jjCheckNAdd(5); if ((0x3ff008000000000L & l) != 0L) { - if (kind > 20) - kind = 20; + if (kind > 21) + kind = 21; jjCheckNAdd(2); } break; @@ -380,23 +386,23 @@ jjCheckNAdd(7); if ((0x3ff008000000000L & l) != 0L) { - if (kind > 20) - kind = 20; + if (kind > 21) + kind = 21; jjCheckNAdd(2); } break; case 1: if ((0x3ff000000000000L & l) == 0L) break; - if (kind > 19) - kind = 19; + if (kind > 20) + kind = 20; jjstateSet[jjnewStateCnt++] = 1; break; case 2: if ((0x3ff008000000000L & l) == 0L) break; - if (kind > 20) - kind = 20; + if (kind > 21) + kind = 21; jjCheckNAdd(2); break; case 3: @@ -406,8 +412,8 @@ case 5: if ((0x3ff400800000000L & l) == 0L) break; - if (kind > 21) - kind = 21; + if (kind > 22) + kind = 22; jjCheckNAdd(5); break; case 6: @@ -417,8 +423,8 @@ case 7: if ((0x3ff000000000000L & l) == 0L) break; - if (kind > 22) - kind = 22; + if (kind > 23) + kind = 23; jjCheckNAdd(7); break; case 8: @@ -430,8 +436,8 @@ jjCheckNAddTwoStates(9, 10); break; case 10: - if (curChar == 39 && kind > 23) - kind = 23; + if (curChar == 39 && kind > 24) + kind = 24; break; default : break; } @@ -449,8 +455,8 @@ jjCheckNAddTwoStates(3, 4); if ((0x7fffffe87fffffeL & l) != 0L) { - if (kind > 20) - kind = 20; + if (kind > 21) + kind = 21; jjCheckNAdd(2); } break; @@ -459,8 +465,8 @@ jjCheckNAddTwoStates(3, 4); if ((0x7fffffe87fffffeL & l) != 0L) { - if (kind > 20) - kind = 20; + if (kind > 21) + kind = 21; jjCheckNAdd(2); } if (curChar == 108) @@ -469,8 +475,8 @@ case 2: if ((0x7fffffe87fffffeL & l) == 0L) break; - if (kind > 20) - kind = 20; + if (kind > 21) + kind = 21; jjCheckNAdd(2); break; case 3: @@ -480,15 +486,15 @@ case 5: if ((0x7fffffe87fffffeL & l) == 0L) break; - if (kind > 21) - kind = 21; + if (kind > 22) + kind = 22; jjstateSet[jjnewStateCnt++] = 5; break; case 7: if ((0x7fffffe07fffffeL & l) == 0L) break; - if (kind > 22) - kind = 22; + if (kind > 23) + kind = 23; jjstateSet[jjnewStateCnt++] = 7; break; case 9: @@ -535,7 +541,7 @@ public static final String[] jjstrLiteralImages = { "", "\72", "\133", "\174", "\135", "\54", "\50", "\51", "\75", "\116\117\124", "\105\126\105\122\131", "\115\117\123\124", "\123\117\115\105", "\124\110\105\115\117\123\124", -"\124\110\105\114\105\101\123\124", "\101\106\105\127", "\115\101\116\131", "\116\117", +"\124\110\105\114\105\101\123\124", "\101\106\105\127", "\115\101\116\131", "\116\117", "\117\122", "\110\117\127\115\101\116\131", null, null, null, null, null, null, null, null, null, }; /** Lexer state names. */ @@ -543,10 +549,10 @@ "DEFAULT", }; static final long[] jjtoToken = { - 0xffffffL, + 0x1ffffffL, }; static final long[] jjtoSkip = { - 0xf000000L, + 0x1e000000L, }; protected SimpleCharStream input_stream; private final int[] jjrounds = new int[11]; Modified: trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/sem/dudes/data/Argument.java =================================================================== --- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/sem/dudes/data/Argument.java 2012-07-03 14:16:28 UTC (rev 3770) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/sem/dudes/data/Argument.java 2012-07-04 15:42:53 UTC (rev 3771) @@ -38,6 +38,9 @@ public String toString() { return "(" + anchor + "," + referent + "," + type + "," + label + ")"; } + public String toTex() { + return "(\\text{"+anchor+"},"+referent+","+type.toTex()+","+label.toTex()+")"; + } public Argument clone() { return new Argument(anchor,referent,type,label); Modified: trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/sem/dudes/data/Dude.java =================================================================== --- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/sem/dudes/data/Dude.java 2012-07-03 14:16:28 UTC (rev 3770) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/sem/dudes/data/Dude.java 2012-07-04 15:42:53 UTC (rev 3771) @@ -388,5 +388,26 @@ } } } + + public String toTex() { + + String out = "\\Dude{"+mainReferent+","+mainLabel.toTex()+","+mainType.toTex()+"}"; + out += "{"; + for (DRS drs : components) out += drs.toTex() + " \\\\ "; + out += "}{"; + for (Argument arg : arguments) out += arg.toTex() + "\\ "; + out += "}{"; + for (Iterator<DominanceConstraint> i = dominanceConstraints.iterator(); i.hasNext();) { + out += i.next().toTex(); + if (i.hasNext()) out += ","; + } + out += "}{"; + for (Iterator<Slot> i = slots.iterator(); i.hasNext();) { + out += i.next().toTex(); + if (i.hasNext()) out += ","; + } + out += "}"; + return out; + } } \ No newline at end of file Modified: trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/sem/dudes/reader/DUDE_Parser.java =================================================================== --- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/sem/dudes/reader/DUDE_Parser.java 2012-07-03 14:16:28 UTC (rev 3770) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/sem/dudes/reader/DUDE_Parser.java 2012-07-04 15:42:53 UTC (rev 3771) @@ -338,12 +338,12 @@ List<DiscourseReferent> dr_list; Token dr1; Token dr2; - Token dr; + Token dr = null; Token predicate; Token quantifier; DRS drs1; DRS drs2; - if (jj_2_29(2)) { + if (jj_2_31(2)) { predicate = word(); jj_consume_token(10); dr_list = DR_List(); @@ -354,7 +354,7 @@ condition.setPredicate(predicate.toString()); condition.setArguments(dr_list); {if (true) return condition;} - } else if (jj_2_30(2)) { + } else if (jj_2_32(2)) { dr1 = dr(); jj_consume_token(6); dr2 = dr(); @@ -365,13 +365,13 @@ condition.addArgument(new DiscourseReferent(dr1.toString())); condition.addArgument(new DiscourseReferent(dr2.toString())); {if (true) return condition;} - } else if (jj_2_31(2)) { + } else if (jj_2_33(2)) { jj_consume_token(13); drs1 = DRS(); Negated_DRS drs = new Negated_DRS(); drs.setDRS(drs1); {if (true) return drs;} - } else if (jj_2_32(2)) { + } else if (jj_2_34(2)) { drs1 = DRS(); if (jj_2_20(2)) { quantifier = jj_consume_token(EVERY); @@ -391,17 +391,24 @@ quantifier = jj_consume_token(MANY); } else if (jj_2_28(2)) { quantifier = jj_consume_token(NO); + } else if (jj_2_29(2)) { + quantifier = jj_consume_token(OR); } else { jj_consume_token(-1); throw new ParseException(); } - dr = dr(); + if (jj_2_30(2)) { + dr = dr(); + } else { + ; + } drs2 = DRS(); - Complex_DRS_Condition drs; + Complex_DRS_Condition drs; drs = new Complex_DRS_Condition(); - drs.setRestrictor(drs1); + drs.setRestrictor(drs1); drs.setScope(drs2); - drs.setReferent(new DiscourseReferent(dr.toString())); + if (dr != null) drs.setReferent(new DiscourseReferent(dr.toString())); + else drs.setReferent(new DiscourseReferent("null")); if (quantifier.toString().equals("EVERY")) {drs.setQuantifier(DRS_Quantifier.EVERY);} if (quantifier.toString().equals("SOME")) {drs.setQuantifier(DRS_Quantifier.SOME);} @@ -427,7 +434,7 @@ Token dr; List<DiscourseReferent> dr_list=null; dr = dr(); - if (jj_2_33(2)) { + if (jj_2_35(2)) { jj_consume_token(2); dr_list = DR_List(); } else { @@ -456,7 +463,7 @@ Slot slot; List<Slot> slots = null; slot = Slot(); - if (jj_2_34(2)) { + if (jj_2_36(2)) { jj_consume_token(2); slots = Slot_List(); } else { @@ -481,7 +488,7 @@ jj_consume_token(14); type = word(); jj_consume_token(14); - if (jj_2_35(2)) { + if (jj_2_37(2)) { words = Word_List(); } else { ; @@ -507,7 +514,7 @@ Token word; List<String> words = null; word = word(); - if (jj_2_36(2)) { + if (jj_2_38(2)) { jj_consume_token(15); words = Word_List(); } else { @@ -525,9 +532,9 @@ final public Token dr() throws ParseException { Token t; - if (jj_2_37(2)) { + if (jj_2_39(2)) { t = jj_consume_token(A); - } else if (jj_2_38(2)) { + } else if (jj_2_40(2)) { t = jj_consume_token(C); } else { jj_consume_token(-1); @@ -539,9 +546,9 @@ final public Token word() throws ParseException { Token t; - if (jj_2_39(2)) { + if (jj_2_41(2)) { t = jj_consume_token(A); - } else if (jj_2_40(2)) { + } else if (jj_2_42(2)) { t = jj_consume_token(B); } else { jj_consume_token(-1); @@ -831,6 +838,20 @@ finally { jj_save(39, xla); } } + private boolean jj_2_41(int xla) { + jj_la = xla; jj_lastpos = jj_scanpos = token; + try { return !jj_3_41(); } + catch(LookaheadSuccess ls) { return true; } + finally { jj_save(40, xla); } + } + + private boolean jj_2_42(int xla) { + jj_la = xla; jj_lastpos = jj_scanpos = token; + try { return !jj_3_42(); } + catch(LookaheadSuccess ls) { return true; } + finally { jj_save(41, xla); } + } + private boolean jj_3_12() { if (jj_scan_token(2)) return true; if (jj_3R_1()) return true; @@ -848,7 +869,7 @@ return false; } - private boolean jj_3_32() { + private boolean jj_3_34() { if (jj_3R_11()) return true; return false; } @@ -858,11 +879,21 @@ return false; } + private boolean jj_3_30() { + if (jj_3R_10()) return true; + return false; + } + private boolean jj_3_3() { if (jj_3R_3()) return true; return false; } + private boolean jj_3_42() { + if (jj_scan_token(B)) return true; + return false; + } + private boolean jj_3R_1() { if (jj_3R_11()) return true; return false; @@ -873,19 +904,20 @@ return false; } - private boolean jj_3_31() { + private boolean jj_3_33() { if (jj_scan_token(13)) return true; if (jj_3R_11()) return true; return false; } private boolean jj_3_40() { - if (jj_scan_token(B)) return true; + if (jj_scan_token(C)) return true; return false; } - private boolean jj_3_38() { - if (jj_scan_token(C)) return true; + private boolean jj_3R_16() { + if (jj_3R_7()) return true; + if (jj_scan_token(14)) return true; return false; } @@ -895,13 +927,7 @@ return false; } - private boolean jj_3R_16() { - if (jj_3R_7()) return true; - if (jj_scan_token(14)) return true; - return false; - } - - private boolean jj_3_39() { + private boolean jj_3_41() { if (jj_scan_token(A)) return true; return false; } @@ -909,45 +935,50 @@ private boolean jj_3R_7() { Token xsp; xsp = jj_scanpos; - if (jj_3_39()) { + if (jj_3_41()) { jj_scanpos = xsp; - if (jj_3_40()) return true; + if (jj_3_42()) return true; } return false; } - private boolean jj_3_37() { + private boolean jj_3_39() { if (jj_scan_token(A)) return true; return false; } - private boolean jj_3_23() { - if (jj_scan_token(MOST)) return true; - return false; - } - private boolean jj_3R_10() { Token xsp; xsp = jj_scanpos; - if (jj_3_37()) { + if (jj_3_39()) { jj_scanpos = xsp; - if (jj_3_38()) return true; + if (jj_3_40()) return true; } return false; } - private boolean jj_3_30() { - if (jj_3R_10()) return true; - if (jj_scan_token(6)) return true; + private boolean jj_3_29() { + if (jj_scan_token(OR)) return true; return false; } - private boolean jj_3_34() { + private boolean jj_3_36() { if (jj_scan_token(2)) return true; if (jj_3R_4()) return true; return false; } + private boolean jj_3_23() { + if (jj_scan_token(MOST)) return true; + return false; + } + + private boolean jj_3_32() { + if (jj_3R_10()) return true; + if (jj_scan_token(6)) return true; + return false; + } + private boolean jj_3R_3() { if (jj_3R_15()) return true; return false; @@ -956,20 +987,20 @@ private boolean jj_3R_17() { Token xsp; xsp = jj_scanpos; - if (jj_3_29()) { + if (jj_3_31()) { jj_scanpos = xsp; - if (jj_3_30()) { + if (jj_3_32()) { jj_scanpos = xsp; - if (jj_3_31()) { + if (jj_3_33()) { jj_scanpos = xsp; - if (jj_3_32()) return true; + if (jj_3_34()) return true; } } } return false; } - private boolean jj_3_29() { + private boolean jj_3_31() { if (jj_3R_7()) return true; if (jj_scan_token(10)) return true; return false; @@ -981,13 +1012,13 @@ return false; } - private boolean jj_3_15() { - if (jj_3R_7()) return true; + private boolean jj_3R_4() { + if (jj_3R_16()) return true; return false; } - private boolean jj_3R_4() { - if (jj_3R_16()) return true; + private boolean jj_3_15() { + if (jj_3R_7()) return true; return false; } @@ -1034,7 +1065,7 @@ return false; } - private boolean jj_3_33() { + private boolean jj_3_35() { if (jj_scan_token(2)) return true; if (jj_3R_12()) return true; return false; @@ -1084,17 +1115,17 @@ return false; } + private boolean jj_3R_12() { + if (jj_3R_10()) return true; + return false; + } + private boolean jj_3_13() { if (jj_scan_token(2)) return true; if (jj_3R_2()) return true; return false; } - private boolean jj_3R_12() { - if (jj_3R_10()) return true; - return false; - } - private boolean jj_3_17() { if (jj_3R_9()) return true; return false; @@ -1106,12 +1137,17 @@ return false; } - private boolean jj_3_36() { + private boolean jj_3_38() { if (jj_scan_token(15)) return true; if (jj_3R_13()) return true; return false; } + private boolean jj_3_37() { + if (jj_3R_13()) return true; + return false; + } + private boolean jj_3_25() { if (jj_scan_token(THELEAST)) return true; return false; @@ -1123,11 +1159,6 @@ return false; } - private boolean jj_3_35() { - if (jj_3R_13()) return true; - return false; - } - private boolean jj_3_18() { if (jj_scan_token(2)) return true; if (jj_3R_8()) return true; @@ -1163,19 +1194,19 @@ return false; } - private boolean jj_3R_2() { - if (jj_3R_14()) return true; - return false; - } - private boolean jj_3R_13() { if (jj_3R_7()) return true; Token xsp; xsp = jj_scanpos; - if (jj_3_36()) jj_scanpos = xsp; + if (jj_3_38()) jj_scanpos = xsp; return false; } + private boolean jj_3R_2() { + if (jj_3R_14()) return true; + return false; + } + private boolean jj_3R_8() { if (jj_3R_10()) return true; Token xsp; @@ -1208,7 +1239,7 @@ private static void jj_la1_init_1() { jj_la1_1 = new int[] {}; } - final private JJCalls[] jj_2_rtns = new JJCalls[40]; + final private JJCalls[] jj_2_rtns = new JJCalls[42]; private boolean jj_rescan = false; private int jj_gc = 0; @@ -1392,7 +1423,7 @@ /** Generate ParseException. */ public ParseException generateParseException() { jj_expentries.clear(); - boolean[] la1tokens = new boolean[34]; + boolean[] la1tokens = new boolean[35]; if (jj_kind >= 0) { la1to... [truncated message content] |
From: <chr...@us...> - 2012-07-12 10:14:37
|
Revision: 3780 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=3780&view=rev Author: christinaunger Date: 2012-07-12 10:14:30 +0000 (Thu, 12 Jul 2012) Log Message: ----------- [tbsl] fix: "exactly n", "at least n", etc. now behave analogous to "more than n" etc. Modified Paths: -------------- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/converter/DRS2SPARQL_Converter.java trunk/components-ext/src/main/resources/tbsl/lexicon/english.lex trunk/components-ext/src/main/resources/tbsl/lexicon/english_oxford.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 2012-07-11 18:10:57 UTC (rev 3779) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/converter/DRS2SPARQL_Converter.java 2012-07-12 10:14:30 UTC (rev 3780) @@ -562,7 +562,7 @@ Set<Simple_DRS_Condition> emptyConditions = new HashSet<Simple_DRS_Condition>(); for (Simple_DRS_Condition c : drs.getAllSimpleConditions()) { - if(c.getPredicate().equals("empty")) { + if(c.getPredicate().equals("empty") || c.getPredicate().equals("empty_data")) { emptyConditions.add(c); } } @@ -572,8 +572,17 @@ boolean globalsuccess = false; for (Simple_DRS_Condition c : emptyConditions) { - String nounToExpand = c.getArguments().get(1).getValue(); - String fallbackNoun = c.getArguments().get(0).getValue(); + String nounToExpand; + String fallbackNoun; + boolean datatype = false; + if (c.getPredicate().equals("empty")) { + nounToExpand = c.getArguments().get(1).getValue(); + fallbackNoun = c.getArguments().get(0).getValue(); + } else { + nounToExpand = c.getArguments().get(0).getValue(); + fallbackNoun = c.getArguments().get(1).getValue(); // TODO das ist quark... + datatype = true; + } boolean success = false; loop: for (Simple_DRS_Condition sc : drs.getAllSimpleConditions()) { @@ -584,7 +593,8 @@ s.setSlotType(SlotType.PROPERTY); List<DiscourseReferent> newargs = new ArrayList<DiscourseReferent>(); newargs.add(c.getArguments().get(0)); - newargs.add(sc.getArguments().get(0)); + if (datatype) newargs.add(c.getArguments().get(1)); + else newargs.add(sc.getArguments().get(0)); sc.setArguments(newargs); success = true; globalsuccess = true; Modified: trunk/components-ext/src/main/resources/tbsl/lexicon/english.lex =================================================================== --- trunk/components-ext/src/main/resources/tbsl/lexicon/english.lex 2012-07-11 18:10:57 UTC (rev 3779) +++ trunk/components-ext/src/main/resources/tbsl/lexicon/english.lex 2012-07-12 10:14:30 UTC (rev 3780) @@ -67,10 +67,11 @@ what || (DP DET:'what' NP[noun]) || <y, l1, <<e,t>,t>, [ l1:[ ?y | ] ], [ (l2,y,noun,<e,t>) ], [ l2=l1 ],[]> many || (DP DET:'many' NP[noun]) || <y, l1, <<e,t>,t>, [ l1:[ | l2:[ y | ] MANY y l3:[|] ] ], [ (l4,y,noun,<e,t>) ], [ l4=l2 ],[]> the || (DP DET:'the' NP[noun]) || <x, l1, <<e,t>,t>, [ l1:[x|] ], [ (l2,x,noun,<e,t>) ], [ l2=l1 ],[]> - at least || (DP DET:'at' DET:'least' NUM[num] NP[noun]) || <y,l1,<<e,t>,t>,[l1:[ y,j |count(a,y,j), greaterorequal(j,x) ]],[(l2,y,noun,<e,t>),(l3,x,num,e)],[ l1=l2, l2=l3 ],[]> - at most || (DP DET:'at' DET:'most' NUM[num] NP[noun]) || <y,l1,<<e,t>,t>,[l1:[ y,j | count(a,y,j), lessorequal(j,x) ]],[(l2,y,noun,<e,t>),(l3,x,num,e)],[ l1=l2, l2=l3 ],[]> - exactly || (DP DET:'exactly' NUM[num] NP[noun]) || <y,l1,<<e,t>,t>,[l1:[ y,j | count(y,j), equals(j,x) ]],[(l2,y,noun,<e,t>),(l3,x,num,e)],[ l1=l2, l2=l3 ],[]> - + at least || (DP DET:'at' DET:'least' NUM[num] NP[noun]) || <y,l1,<<e,t>,t>,[ l1:[ y,c | count(y,c), greaterorequal(c,x) ] ],[(l2,y,noun,<e,t>),(l3,x,num,e)],[l2=l1,l3=l1],[ SLOT_arg/RESOURCE/y ]> ;; <y,l1,<<e,t>,t>,[l1:[ y | greaterorequal(y,x) ]],[(l2,y,noun,<e,t>),(l3,x,num,e)],[ l1=l2, l2=l3 ],[ SLOT_arg/LITERAL/y ]> + at most || (DP DET:'at' DET:'most' NUM[num] NP[noun]) || <y,l1,<<e,t>,t>,[ l1:[ y,c | count(y,c), lessorequal(c,x) ] ],[(l2,y,noun,<e,t>),(l3,x,num,e)],[l2=l1,l3=l1],[ SLOT_arg/RESOURCE/y ]> ;; <y,l1,<<e,t>,t>,[l1:[ y | lessorequal(y,x) ]],[(l2,y,noun,<e,t>),(l3,x,num,e)],[ l1=l2, l2=l3 ],[ SLOT_arg/LITERAL/y ]> + exactly || (DP DET:'exactly' NUM[num] NP[noun]) || <y,l1,<<e,t>,t>,[ l1:[ y,c | count(y,c), equal(c,x) ] ],[(l2,y,noun,<e,t>),(l3,x,num,e)],[l2=l1,l3=l1],[ SLOT_arg/RESOURCE/y ]> ;; <y,l1,<<e,t>,t>,[l1:[ y | equal(y,x) ]],[(l2,y,noun,<e,t>),(l3,x,num,e)],[ l1=l2, l2=l3 ],[ SLOT_arg/LITERAL/y ]> + equal to || (DP DET:'equal' DET:'to' NUM[num] NP[noun]) || <y,l1,<<e,t>,t>,[ l1:[ y,c | count(y,c), equal(c,x) ] ],[(l2,y,noun,<e,t>),(l3,x,num,e)],[l2=l1,l3=l1],[ SLOT_arg/RESOURCE/y ]> ;; <y,l1,<<e,t>,t>,[l1:[ y | equal(y,x) ]],[(l2,y,noun,<e,t>),(l3,x,num,e)],[ l1=l2, l2=l3 ],[ SLOT_arg/LITERAL/y ]> + other || (NP ADJ:'other' NP*) || <x,l1,<e,t>,[ l1:[ | ] ], [],[],[]> total || (NP ADJ:'total' NP[np]) || <s,l1,<e,t>,[ l1:[ ?s | sum(a,x,s) ] ], [ (l2,x,np,<e,t>) ],[ l2=l1 ],[]> Modified: trunk/components-ext/src/main/resources/tbsl/lexicon/english_oxford.lex =================================================================== --- trunk/components-ext/src/main/resources/tbsl/lexicon/english_oxford.lex 2012-07-11 18:10:57 UTC (rev 3779) +++ trunk/components-ext/src/main/resources/tbsl/lexicon/english_oxford.lex 2012-07-12 10:14:30 UTC (rev 3780) @@ -34,7 +34,7 @@ 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 ]> - square meters || (DP N:'square' N:'meters') || <x,l1,<<e,t>,t>>, [l1:[ | SLOT_size(x,y) ]], [],[],[SLOT_size/DATATYPEPROPERTY/size ]> + square meters || (NP N:'square' N:'meters') || <x,l1,<e,t>, [l1:[ | SLOT_size(x,y) ]], [],[],[SLOT_size/DATATYPEPROPERTY/size ]> // MONTHS This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2012-08-27 12:13:51
|
Revision: 3838 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=3838&view=rev Author: christinaunger Date: 2012-08-27 12:13:42 +0000 (Mon, 27 Aug 2012) Log Message: ----------- extension of the final filtering process that throws out those templates that don't make sense Modified Paths: -------------- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/sem/dudes/reader/DUDE_Parser.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/sparql/SlotType.java trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/sparql/Template.java trunk/components-ext/src/main/resources/tbsl/lexicon/english_oxford.lex Modified: trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/sem/dudes/reader/DUDE_Parser.java =================================================================== --- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/sem/dudes/reader/DUDE_Parser.java 2012-08-26 12:24:54 UTC (rev 3837) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/sem/dudes/reader/DUDE_Parser.java 2012-08-27 12:13:42 UTC (rev 3838) @@ -504,6 +504,9 @@ else if (type.toString().equals("PROPERTY")) { slottype = SlotType.PROPERTY; } else if (type.toString().equals("SYMPROPERTY")) { slottype = SlotType.SYMPROPERTY; } else if (type.toString().equals("LITERAL")) { slottype = SlotType.LITERAL; } + else if (type.toString().equals("STRING")) { slottype = SlotType.STRING; } + else if (type.toString().equals("INTEGER")) { slottype = SlotType.INTEGER; } + else if (type.toString().equals("BOOLEAN")) { slottype = SlotType.BOOLEAN; } else { slottype = SlotType.UNSPEC; } {if (true) return new Slot(ref.toString(),slottype,words);} @@ -884,13 +887,18 @@ return false; } + private boolean jj_3_42() { + if (jj_scan_token(B)) return true; + return false; + } + private boolean jj_3_3() { if (jj_3R_3()) return true; return false; } - private boolean jj_3_42() { - if (jj_scan_token(B)) return true; + private boolean jj_3_40() { + if (jj_scan_token(C)) return true; return false; } @@ -910,11 +918,21 @@ return false; } - private boolean jj_3_40() { - if (jj_scan_token(C)) return true; + private boolean jj_3_41() { + if (jj_scan_token(A)) return true; return false; } + private boolean jj_3R_7() { + Token xsp; + xsp = jj_scanpos; + if (jj_3_41()) { + jj_scanpos = xsp; + if (jj_3_42()) return true; + } + return false; + } + private boolean jj_3R_16() { if (jj_3R_7()) return true; if (jj_scan_token(14)) return true; @@ -927,21 +945,6 @@ return false; } - private boolean jj_3_41() { - if (jj_scan_token(A)) return true; - return false; - } - - private boolean jj_3R_7() { - Token xsp; - xsp = jj_scanpos; - if (jj_3_41()) { - jj_scanpos = xsp; - if (jj_3_42()) return true; - } - return false; - } - private boolean jj_3_39() { if (jj_scan_token(A)) return true; return false; @@ -1131,18 +1134,18 @@ return false; } + private boolean jj_3_38() { + if (jj_scan_token(15)) return true; + if (jj_3R_13()) return true; + return false; + } + private boolean jj_3_7() { if (jj_3R_5()) return true; if (jj_scan_token(6)) return true; return false; } - private boolean jj_3_38() { - if (jj_scan_token(15)) return true; - if (jj_3R_13()) return true; - return false; - } - private boolean jj_3_37() { if (jj_3R_13()) return true; return false; 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-08-26 12:24:54 UTC (rev 3837) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/sem/dudes/reader/DUDE_Parser.jj 2012-08-27 12:13:42 UTC (rev 3838) @@ -458,6 +458,9 @@ else if (type.toString().equals("PROPERTY")) { slottype = SlotType.PROPERTY; } else if (type.toString().equals("SYMPROPERTY")) { slottype = SlotType.SYMPROPERTY; } else if (type.toString().equals("LITERAL")) { slottype = SlotType.LITERAL; } + else if (type.toString().equals("STRING")) { slottype = SlotType.STRING; } + else if (type.toString().equals("INTEGER")) { slottype = SlotType.INTEGER; } + else if (type.toString().equals("BOOLEAN")) { slottype = SlotType.BOOLEAN; } else { slottype = SlotType.UNSPEC; } return new Slot(ref.toString(),slottype,words); Modified: trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/sparql/SlotType.java =================================================================== --- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/sparql/SlotType.java 2012-08-26 12:24:54 UTC (rev 3837) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/sparql/SlotType.java 2012-08-27 12:13:42 UTC (rev 3838) @@ -1,6 +1,6 @@ package org.dllearner.algorithm.tbsl.sparql; public enum SlotType { - RESOURCE, CLASS, OBJECTPROPERTY, DATATYPEPROPERTY, PROPERTY, LITERAL, UNSPEC, + RESOURCE, CLASS, OBJECTPROPERTY, DATATYPEPROPERTY, PROPERTY, LITERAL, STRING, INTEGER, BOOLEAN, UNSPEC, SYMPROPERTY // TODO don't use them anymore } Modified: trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/sparql/Template.java =================================================================== --- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/sparql/Template.java 2012-08-26 12:24:54 UTC (rev 3837) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/sparql/Template.java 2012-08-27 12:13:42 UTC (rev 3838) @@ -40,12 +40,12 @@ // check for clash (v=LITERAL && v=RESOURCE) for (Slot s : slots) { if ((s.words.get(0).equals(slot.words.get(0)) || s.anchor.equals(slot.words.get(0))) - && !s.type.equals(slot.type)) + && ((slot.type.equals(SlotType.RESOURCE) && isLiteral(s.type)) || (s.type.equals(SlotType.RESOURCE) && isLiteral(slot.type)))) // !s.type.equals(slot.type)) return null; } // check for clash (v=LITERAL && p(...,v)=OBJECTPROPERTY) || (v=RESOURCE && p(...,v)=DATATYPEPROPERTY) SlotType clashing = null; - if (slot.type.equals(SlotType.LITERAL)) clashing = SlotType.OBJECTPROPERTY; + if (isLiteral(slot.type)) clashing = SlotType.OBJECTPROPERTY; else if (slot.type.equals(SlotType.RESOURCE)) clashing = SlotType.DATATYPEPROPERTY; for (Slot s : slots) { if (clashing != null && s.type.equals(clashing)) { @@ -57,6 +57,27 @@ } } } + // check for clashes with FILTERS + for (SPARQL_Filter filter : query.filter) { + for (SPARQL_Pair ts : filter.getTerms()) { + if (ts.a.getName().equals(var) && (isIntegerType(ts.type) || ts.type.equals(SPARQL_PairType.REGEX))) { + // clash 1: counting a literal + for (SPARQL_Term sel : query.selTerms) { + if (sel.name.equals(var) && sel.aggregate.equals(SPARQL_Aggregate.COUNT)) + return null; + } + // clash 2: FILTER regex(?var,...) and FILTER (?var > ...) + for (SPARQL_Filter f : query.filter) { + if (!f.equals(filter)) { + for (SPARQL_Pair p : f.getTerms()) { + if (p.a.name.equals(var) && (p.type.equals(SPARQL_PairType.REGEX) && isIntegerType(ts.type)) || (ts.type.equals(SPARQL_PairType.REGEX) && isIntegerType(p.type))) + return null; + } + } + } + } + } + } } for (Slot slot : slots) { @@ -65,7 +86,7 @@ for (SPARQL_Triple triple : query.conditions) { if (triple.property.toString().equals("rdf:type") && triple.value.toString().equals("?"+slot.anchor)) { for (Slot s : argslots) { - if (s.words.contains(triple.variable.toString().replace("?","")) && s.type.equals(SlotType.LITERAL)) + if (s.words.contains(triple.variable.toString().replace("?","")) && isLiteral(s.type)) return null; } } @@ -81,7 +102,7 @@ for (String arg : args) { for (Slot s : argslots) { if (s.words.contains(arg.replace("?",""))) { - if (s.type.equals(SlotType.LITERAL)) slot.type = SlotType.DATATYPEPROPERTY; + if (isLiteral(s.type)) slot.type = SlotType.DATATYPEPROPERTY; else if (s.type.equals(SlotType.RESOURCE)) slot.type = SlotType.OBJECTPROPERTY; } } @@ -111,8 +132,29 @@ } slots = keep; + // additionally, filter out those templates that count a var that does not occur in the triples + // (these templates should not be built in the first place, but they are...) + for (SPARQL_Term t : query.selTerms) { + if (t.aggregate.equals(SPARQL_Aggregate.COUNT)) { + String v = t.name; + boolean fine = false; + for (SPARQL_Triple triple : query.conditions) { + if ((triple.variable.name.equals(v) || triple.value.name.equals(v))) { + fine = true; break; + } + } + if (!fine) return null; + } + } + return this; } + private boolean isLiteral(SlotType st) { + return st.equals(SlotType.STRING) || st.equals(SlotType.INTEGER) || st.equals(SlotType.LITERAL); + } + private boolean isIntegerType(SPARQL_PairType p) { + return p.equals(SPARQL_PairType.GT) || p.equals(SPARQL_PairType.LT) || p.equals(SPARQL_PairType.GTEQ) || p.equals(SPARQL_PairType.LTEQ); + } public String toString() { Modified: trunk/components-ext/src/main/resources/tbsl/lexicon/english_oxford.lex =================================================================== --- trunk/components-ext/src/main/resources/tbsl/lexicon/english_oxford.lex 2012-08-26 12:24:54 UTC (rev 3837) +++ trunk/components-ext/src/main/resources/tbsl/lexicon/english_oxford.lex 2012-08-27 12:13:42 UTC (rev 3838) @@ -31,7 +31,7 @@ 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/prices ]> + 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 ]> 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:[ z | 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:[ z | SLOT_description(x,z), regextoken(z,y) ] ], [ (l2,y,dp,<<e,t>,t>) ], [ l2=l1 ],[ SLOT_description/DATATYPEPROPERTY/description, SLOT_arg/LITERAL/z ]> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |