From: <jen...@us...> - 2010-03-25 16:25:34
|
Revision: 2138 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=2138&view=rev Author: jenslehmann Date: 2010-03-25 16:25:28 +0000 (Thu, 25 Mar 2010) Log Message: ----------- hasValue support for KB syntax parser Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/core/owl/ObjectValueRestriction.java trunk/src/dl-learner/org/dllearner/parser/KBParser.java trunk/src/dl-learner/org/dllearner/parser/KBParserConstants.java trunk/src/dl-learner/org/dllearner/parser/KBParserTokenManager.java trunk/src/dl-learner/org/dllearner/parser/kb.jj trunk/src/dl-learner/org/dllearner/test/junit/ParserTest.java Modified: trunk/src/dl-learner/org/dllearner/core/owl/ObjectValueRestriction.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/ObjectValueRestriction.java 2010-03-25 08:41:30 UTC (rev 2137) +++ trunk/src/dl-learner/org/dllearner/core/owl/ObjectValueRestriction.java 2010-03-25 16:25:28 UTC (rev 2138) @@ -73,7 +73,7 @@ } public String toKBSyntaxString(String baseURI, Map<String, String> prefixes) { - return restrictedPropertyExpression.toKBSyntaxString(baseURI, prefixes) + " hasValue " + value.toKBSyntaxString(baseURI, prefixes); + return "(" + restrictedPropertyExpression.toKBSyntaxString(baseURI, prefixes) + " HASVALUE " + value.toKBSyntaxString(baseURI, prefixes) + ")"; } public Individual getIndividual() { Modified: trunk/src/dl-learner/org/dllearner/parser/KBParser.java =================================================================== --- trunk/src/dl-learner/org/dllearner/parser/KBParser.java 2010-03-25 08:41:30 UTC (rev 2137) +++ trunk/src/dl-learner/org/dllearner/parser/KBParser.java 2010-03-25 16:25:28 UTC (rev 2138) @@ -418,7 +418,9 @@ NamedClass ac; ObjectProperty ar; DatatypeProperty dp; + ObjectProperty op; String s; + Individual ind; int i; switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case TOP: @@ -501,12 +503,19 @@ jj_consume_token(49); jj_consume_token(23); {if (true) return new BooleanValueRestriction(dp, false);} + } else if (jj_2_10(4)) { + jj_consume_token(22); + op = ObjectProperty(); + jj_consume_token(50); + ind = Individual(); + jj_consume_token(23); + {if (true) return new ObjectValueRestriction(op, ind);} } else { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case 22: jj_consume_token(22); dp = DatatypeProperty(); - jj_consume_token(50); + jj_consume_token(51); s = String(); jj_consume_token(23); {if (true) return new StringValueRestriction(dp, s);} @@ -730,24 +739,13 @@ finally { jj_save(8, xla); } } - private boolean jj_3_7() { - if (jj_scan_token(22)) return true; - if (jj_3R_2()) return true; - if (jj_scan_token(15)) return true; - return false; + private boolean jj_2_10(int xla) { + jj_la = xla; jj_lastpos = jj_scanpos = token; + try { return !jj_3_10(); } + catch(LookaheadSuccess ls) { return true; } + finally { jj_save(9, xla); } } - private boolean jj_3R_13() { - if (jj_scan_token(18)) return true; - if (jj_3R_2()) return true; - return false; - } - - private boolean jj_3R_25() { - if (jj_scan_token(NUMBER)) return true; - return false; - } - private boolean jj_3_6() { if (jj_scan_token(22)) return true; if (jj_3R_2()) return true; @@ -780,6 +778,15 @@ return false; } + private boolean jj_3R_9() { + if (jj_scan_token(22)) return true; + if (jj_3R_2()) return true; + if (jj_scan_token(14)) return true; + if (jj_3R_2()) return true; + if (jj_scan_token(23)) return true; + return false; + } + private boolean jj_3_4() { if (jj_3R_2()) return true; Token xsp; @@ -791,12 +798,8 @@ return false; } - private boolean jj_3R_9() { - if (jj_scan_token(22)) return true; - if (jj_3R_2()) return true; - if (jj_scan_token(14)) return true; - if (jj_3R_2()) return true; - if (jj_scan_token(23)) return true; + private boolean jj_3R_18() { + if (jj_3R_26()) return true; return false; } @@ -806,11 +809,6 @@ return false; } - private boolean jj_3R_18() { - if (jj_3R_26()) return true; - return false; - } - private boolean jj_3_5() { if (jj_3R_5()) return true; return false; @@ -853,6 +851,8 @@ jj_scanpos = xsp; if (jj_3_9()) { jj_scanpos = xsp; + if (jj_3_10()) { + jj_scanpos = xsp; if (jj_3R_16()) return true; } } @@ -866,6 +866,7 @@ } } } + } return false; } @@ -894,6 +895,11 @@ return false; } + private boolean jj_3R_24() { + if (jj_3R_26()) return true; + return false; + } + private boolean jj_3_2() { Token xsp; xsp = jj_scanpos; @@ -905,20 +911,6 @@ return false; } - private boolean jj_3_1() { - if (jj_3R_2()) return true; - if (jj_scan_token(22)) return true; - if (jj_3R_3()) return true; - if (jj_scan_token(23)) return true; - if (jj_scan_token(COMMAND_END)) return true; - return false; - } - - private boolean jj_3R_24() { - if (jj_3R_26()) return true; - return false; - } - private boolean jj_3R_19() { if (jj_3R_27()) return true; return false; @@ -934,6 +926,15 @@ return false; } + private boolean jj_3_1() { + if (jj_3R_2()) return true; + if (jj_scan_token(22)) return true; + if (jj_3R_3()) return true; + if (jj_scan_token(23)) return true; + if (jj_scan_token(COMMAND_END)) return true; + return false; + } + private boolean jj_3R_22() { if (jj_3R_26()) return true; return false; @@ -977,12 +978,21 @@ private boolean jj_3R_16() { if (jj_scan_token(22)) return true; if (jj_3R_6()) return true; - if (jj_scan_token(50)) return true; + if (jj_scan_token(51)) return true; if (jj_3R_26()) return true; if (jj_scan_token(23)) return true; return false; } + private boolean jj_3_10() { + if (jj_scan_token(22)) return true; + if (jj_3R_4()) return true; + if (jj_scan_token(50)) return true; + if (jj_3R_3()) return true; + if (jj_scan_token(23)) return true; + return false; + } + private boolean jj_3_9() { if (jj_scan_token(22)) return true; if (jj_3R_6()) return true; @@ -1019,6 +1029,24 @@ return false; } + private boolean jj_3R_25() { + if (jj_scan_token(NUMBER)) return true; + return false; + } + + private boolean jj_3_7() { + if (jj_scan_token(22)) return true; + if (jj_3R_2()) return true; + if (jj_scan_token(15)) return true; + return false; + } + + private boolean jj_3R_13() { + if (jj_scan_token(18)) return true; + if (jj_3R_2()) return true; + return false; + } + /** Generated Token Manager. */ public KBParserTokenManager token_source; SimpleCharStream jj_input_stream; @@ -1043,7 +1071,7 @@ private static void jj_la1_init_1() { jj_la1_1 = new int[] {0xffd,0xffd,0x0,0x2,0x1c,0x60,0x380,0xc00,0x7000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,}; } - final private JJCalls[] jj_2_rtns = new JJCalls[9]; + final private JJCalls[] jj_2_rtns = new JJCalls[10]; private boolean jj_rescan = false; private int jj_gc = 0; @@ -1227,7 +1255,7 @@ /** Generate ParseException. */ public ParseException generateParseException() { jj_expentries.clear(); - boolean[] la1tokens = new boolean[51]; + boolean[] la1tokens = new boolean[52]; if (jj_kind >= 0) { la1tokens[jj_kind] = true; jj_kind = -1; @@ -1244,7 +1272,7 @@ } } } - for (int i = 0; i < 51; i++) { + for (int i = 0; i < 52; i++) { if (la1tokens[i]) { jj_expentry = new int[1]; jj_expentry[0] = i; @@ -1271,7 +1299,7 @@ private void jj_rescan_token() { jj_rescan = true; - for (int i = 0; i < 9; i++) { + for (int i = 0; i < 10; i++) { try { JJCalls p = jj_2_rtns[i]; do { @@ -1287,6 +1315,7 @@ case 6: jj_3_7(); break; case 7: jj_3_8(); break; case 8: jj_3_9(); break; + case 9: jj_3_10(); break; } } p = p.next; Modified: trunk/src/dl-learner/org/dllearner/parser/KBParserConstants.java =================================================================== --- trunk/src/dl-learner/org/dllearner/parser/KBParserConstants.java 2010-03-25 08:41:30 UTC (rev 2137) +++ trunk/src/dl-learner/org/dllearner/parser/KBParserConstants.java 2010-03-25 16:25:28 UTC (rev 2138) @@ -101,6 +101,7 @@ "\"IS\"", "\"TRUE\"", "\"FALSE\"", + "\"HASVALUE\"", "\"STRINGVALUE\"", }; Modified: trunk/src/dl-learner/org/dllearner/parser/KBParserTokenManager.java =================================================================== --- trunk/src/dl-learner/org/dllearner/parser/KBParserTokenManager.java 2010-03-25 08:41:30 UTC (rev 2137) +++ trunk/src/dl-learner/org/dllearner/parser/KBParserTokenManager.java 2010-03-25 16:25:28 UTC (rev 2138) @@ -18,7 +18,7 @@ switch (pos) { case 0: - if ((active0 & 0x400034c000000L) != 0L) + if ((active0 & 0x800034c000000L) != 0L) return 10; if ((active0 & 0x2000020000000L) != 0L) return 18; @@ -65,6 +65,8 @@ return jjMoveStringLiteralDfa1_0(0x1c6400000000L); case 70: return jjMoveStringLiteralDfa1_0(0x2000020000000L); + case 72: + return jjMoveStringLiteralDfa1_0(0x4000000000000L); case 73: return jjMoveStringLiteralDfa1_0(0xc00080000000L); case 79: @@ -72,7 +74,7 @@ case 82: return jjMoveStringLiteralDfa1_0(0x8000000000L); case 83: - return jjMoveStringLiteralDfa1_0(0x400034c000000L); + return jjMoveStringLiteralDfa1_0(0x800034c000000L); case 84: return jjMoveStringLiteralDfa1_0(0x1000010001000L); default : @@ -95,7 +97,7 @@ return jjStopAtPos(1, 20); break; case 65: - return jjMoveStringLiteralDfa2_0(active0, 0x208c000000000L); + return jjMoveStringLiteralDfa2_0(active0, 0x608c000000000L); case 66: return jjMoveStringLiteralDfa2_0(active0, 0x21000000000L); case 78: @@ -113,7 +115,7 @@ return jjStopAtPos(1, 47); break; case 84: - return jjMoveStringLiteralDfa2_0(active0, 0x4000000000000L); + return jjMoveStringLiteralDfa2_0(active0, 0x8000000000000L); case 85: return jjMoveStringLiteralDfa2_0(active0, 0x20c000000L); case 110: @@ -166,7 +168,9 @@ return jjStopAtPos(2, 12); break; case 82: - return jjMoveStringLiteralDfa3_0(active0, 0x4050000000000L); + return jjMoveStringLiteralDfa3_0(active0, 0x8050000000000L); + case 83: + return jjMoveStringLiteralDfa3_0(active0, 0x4000000000000L); case 84: return jjMoveStringLiteralDfa3_0(active0, 0x484000002000L); case 85: @@ -210,7 +214,7 @@ case 71: return jjMoveStringLiteralDfa4_0(active0, 0x8000000000L); case 73: - return jjMoveStringLiteralDfa4_0(active0, 0x4000000000000L); + return jjMoveStringLiteralDfa4_0(active0, 0x8000000000000L); case 76: return jjMoveStringLiteralDfa4_0(active0, 0x200000000000L); case 79: @@ -219,6 +223,8 @@ return jjMoveStringLiteralDfa4_0(active0, 0x2000000000000L); case 84: return jjMoveStringLiteralDfa4_0(active0, 0x2000L); + case 86: + return jjMoveStringLiteralDfa4_0(active0, 0x4000000000000L); case 99: return jjMoveStringLiteralDfa4_0(active0, 0x20000000L); case 101: @@ -245,6 +251,8 @@ } switch(curChar) { + case 65: + return jjMoveStringLiteralDfa5_0(active0, 0x4000000000000L); case 67: return jjMoveStringLiteralDfa5_0(active0, 0x21000000000L); case 69: @@ -262,7 +270,7 @@ case 77: return jjMoveStringLiteralDfa5_0(active0, 0x2800000000L); case 78: - return jjMoveStringLiteralDfa5_0(active0, 0x4050000000000L); + return jjMoveStringLiteralDfa5_0(active0, 0x8050000000000L); case 79: return jjMoveStringLiteralDfa5_0(active0, 0x200002000L); case 84: @@ -300,7 +308,9 @@ return jjStopAtPos(5, 44); return jjMoveStringLiteralDfa6_0(active0, 0x400000000000L); case 71: - return jjMoveStringLiteralDfa6_0(active0, 0x4050000000000L); + return jjMoveStringLiteralDfa6_0(active0, 0x8050000000000L); + case 76: + return jjMoveStringLiteralDfa6_0(active0, 0x4000000000000L); case 77: if ((active0 & 0x2000L) != 0L) return jjStopAtPos(5, 13); @@ -359,8 +369,10 @@ break; case 83: return jjMoveStringLiteralDfa7_0(active0, 0x4000000L); + case 85: + return jjMoveStringLiteralDfa7_0(active0, 0x4000000000000L); case 86: - return jjMoveStringLiteralDfa7_0(active0, 0x4000000000000L); + return jjMoveStringLiteralDfa7_0(active0, 0x8000000000000L); case 101: if ((active0 & 0x80000000L) != 0L) return jjStopAtPos(6, 31); @@ -390,8 +402,10 @@ switch(curChar) { case 65: - return jjMoveStringLiteralDfa8_0(active0, 0x4000000000000L); + return jjMoveStringLiteralDfa8_0(active0, 0x8000000000000L); case 69: + if ((active0 & 0x4000000000000L) != 0L) + return jjStopAtPos(7, 50); return jjMoveStringLiteralDfa8_0(active0, 0x84200000000L); case 78: if ((active0 & 0x800000000L) != 0L) @@ -424,7 +438,7 @@ switch(curChar) { case 76: - return jjMoveStringLiteralDfa9_0(active0, 0x4000000000000L); + return jjMoveStringLiteralDfa9_0(active0, 0x8000000000000L); case 79: return jjMoveStringLiteralDfa9_0(active0, 0x21004000000L); case 80: @@ -464,7 +478,7 @@ case 84: return jjMoveStringLiteralDfa10_0(active0, 0x200000000L); case 85: - return jjMoveStringLiteralDfa10_0(active0, 0x4000000000000L); + return jjMoveStringLiteralDfa10_0(active0, 0x8000000000000L); case 101: if ((active0 & 0x10000000L) != 0L) return jjStopAtPos(9, 28); @@ -490,8 +504,8 @@ switch(curChar) { case 69: - if ((active0 & 0x4000000000000L) != 0L) - return jjStopAtPos(10, 50); + if ((active0 & 0x8000000000000L) != 0L) + return jjStopAtPos(10, 51); return jjMoveStringLiteralDfa11_0(active0, 0x21000000000L); case 79: return jjMoveStringLiteralDfa11_0(active0, 0x84200000000L); @@ -1139,14 +1153,14 @@ "\117\102\112\105\103\124\120\122\117\120\105\122\124\131\122\101\116\107\105", "\104\120\122\101\116\107\105", "\104\101\124\101\124\131\120\105\120\122\117\120\105\122\124\131\122\101\116\107\105", "\104\117\125\102\114\105", "\102\117\117\114\105\101\116", "\111\116\124\105\107\105\122", "\111\123", "\124\122\125\105", "\106\101\114\123\105", -"\123\124\122\111\116\107\126\101\114\125\105", }; +"\110\101\123\126\101\114\125\105", "\123\124\122\111\116\107\126\101\114\125\105", }; /** Lexer state names. */ public static final String[] lexStateNames = { "DEFAULT", }; static final long[] jjtoToken = { - 0x7ffffffffff01L, + 0xfffffffffff01L, }; static final long[] jjtoSkip = { 0xfeL, Modified: trunk/src/dl-learner/org/dllearner/parser/kb.jj =================================================================== --- trunk/src/dl-learner/org/dllearner/parser/kb.jj 2010-03-25 08:41:30 UTC (rev 2137) +++ trunk/src/dl-learner/org/dllearner/parser/kb.jj 2010-03-25 16:25:28 UTC (rev 2138) @@ -253,7 +253,9 @@ NamedClass ac; ObjectProperty ar; DatatypeProperty dp; + ObjectProperty op; String s; + Individual ind; int i; } { @@ -288,6 +290,7 @@ {return new ObjectMaxCardinalityRestriction(i,ar,c);} | LOOKAHEAD(4) "(" dp=DatatypeProperty() "IS" "TRUE" ")" { return new BooleanValueRestriction(dp, true); } | LOOKAHEAD(4) "(" dp=DatatypeProperty() "IS" "FALSE" ")" { return new BooleanValueRestriction(dp, false); } + | LOOKAHEAD(4) "(" op=ObjectProperty() "HASVALUE" ind=Individual() ")" { return new ObjectValueRestriction(op, ind); } | "(" dp=DatatypeProperty() "STRINGVALUE" s=String() ")" { return new StringValueRestriction(dp, s); } } Modified: trunk/src/dl-learner/org/dllearner/test/junit/ParserTest.java =================================================================== --- trunk/src/dl-learner/org/dllearner/test/junit/ParserTest.java 2010-03-25 08:41:30 UTC (rev 2137) +++ trunk/src/dl-learner/org/dllearner/test/junit/ParserTest.java 2010-03-25 16:25:28 UTC (rev 2138) @@ -35,7 +35,8 @@ @Test public void KBParserTest() throws ParseException { - String test = "(\"Sentence\" AND (EXISTS \"syntaxTreeHasPart\".\"VVPP\" AND EXISTS \"syntaxTreeHasPart\".(\"stts:AuxilliaryVerb\" AND (\"hasLemma\" STRINGVALUE \"werden\"))))"; +// String test = "(\"Sentence\" AND (EXISTS \"syntaxTreeHasPart\".\"VVPP\" AND EXISTS \"syntaxTreeHasPart\".(\"stts:AuxilliaryVerb\" AND (\"hasLemma\" STRINGVALUE \"werden\"))))"; + String test = "(someproperty HASVALUE someindividual)"; Description d = KBParser.parseConcept(test); System.out.println(d.toKBSyntaxString("http://localhost/foo#", null)); Description d2 = KBParser.parseConcept(d.toKBSyntaxString()); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |