From: <jen...@us...> - 2011-11-17 17:39:52
|
Revision: 3415 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=3415&view=rev Author: jenslehmann Date: 2011-11-17 17:39:45 +0000 (Thu, 17 Nov 2011) Log Message: ----------- modified parser to be able to set fuzzy examples directly Modified Paths: -------------- trunk/components-core/src/main/java/org/dllearner/learningproblems/FuzzyPosNegLP.java trunk/interfaces/src/main/java/org/dllearner/confparser3/ConfParser.java trunk/interfaces/src/main/java/org/dllearner/confparser3/conf3.jj trunk/test/fuzzydll/fuzzytrains.conf Modified: trunk/components-core/src/main/java/org/dllearner/learningproblems/FuzzyPosNegLP.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/learningproblems/FuzzyPosNegLP.java 2011-11-17 17:00:28 UTC (rev 3414) +++ trunk/components-core/src/main/java/org/dllearner/learningproblems/FuzzyPosNegLP.java 2011-11-17 17:39:45 UTC (rev 3415) @@ -21,6 +21,7 @@ import java.util.Collection; import java.util.LinkedList; +import java.util.Map; import java.util.Set; import java.util.SortedSet; @@ -53,7 +54,16 @@ protected SortedSet<FuzzyIndividual> fuzzyExamples; + protected Map<Individual,Double> fuzzyEx; + public Map<Individual, Double> getFuzzyEx() { + return fuzzyEx; + } + + public void setFuzzyEx(Map<Individual, Double> fuzzyEx) { + this.fuzzyEx = fuzzyEx; + } + protected boolean useRetrievalForClassification = false; protected UseMultiInstanceChecks useMultiInstanceChecks = UseMultiInstanceChecks.TWOCHECKS; protected double percentPerLengthUnit = 0.05; Modified: trunk/interfaces/src/main/java/org/dllearner/confparser3/ConfParser.java =================================================================== --- trunk/interfaces/src/main/java/org/dllearner/confparser3/ConfParser.java 2011-11-17 17:00:28 UTC (rev 3414) +++ trunk/interfaces/src/main/java/org/dllearner/confparser3/ConfParser.java 2011-11-17 17:39:45 UTC (rev 3415) @@ -93,6 +93,7 @@ String value="", value1="", value2="", tmp="", tmp2=""; Set<String> values = new HashSet<String>(); Map<String,String> tuples = new HashMap<String,String>(); + Map<String,Double> tuplesD = new HashMap<String,Double>(); ConfFileOption2 option = new ConfFileOption2(); boolean isBeanRef = false; @@ -102,6 +103,7 @@ String propertyValue = ""; Class<?> propertyType; Object val = null; + Double d; beanName = Id(); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case COMMAND_END: @@ -140,11 +142,11 @@ break; default: jj_la1[2] = jj_gen; - if (jj_2_4(2147483647)) { + if (jj_2_5(2147483647)) { jj_consume_token(14); jj_consume_token(15); val = new HashSet(); propertyType = Set.class; propertyValue = "{}"; - } else if (jj_2_5(4)) { + } else if (jj_2_6(4)) { jj_consume_token(14); label_2: while (true) { @@ -187,37 +189,62 @@ break; default: jj_la1[3] = jj_gen; - if (jj_2_6(2147483647)) { + if (jj_2_7(2147483647)) { jj_consume_token(18); jj_consume_token(19); val = new LinkedList(); propertyType = List.class; propertyValue = "[]"; + } else if (jj_2_8(2147483647)) { + jj_consume_token(18); + label_4: + while (true) { + if (jj_2_3(6)) { + ; + } else { + break label_4; + } + jj_consume_token(20); + tmp = String(); + jj_consume_token(16); + tmp2 = String(); + jj_consume_token(21); + tuples.put(tmp,tmp2); propertyValue += "(\u005c""+ tmp + "\u005c",\u005c"" + tmp2 + "\u005c"), "; + jj_consume_token(16); + } + jj_consume_token(20); + tmp = String(); + jj_consume_token(16); + tmp2 = String(); + jj_consume_token(21); + tuples.put(tmp,tmp2); propertyValue += "(\u005c""+ tmp + "\u005c",\u005c"" + tmp2 + "\u005c")"; + jj_consume_token(19); + val = tuples; propertyType = List.class; propertyValue = "["+ propertyValue + "]"; } else { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case 18: jj_consume_token(18); - label_4: + label_5: while (true) { - if (jj_2_3(6)) { + if (jj_2_4(6)) { ; } else { - break label_4; + break label_5; } jj_consume_token(20); tmp = String(); jj_consume_token(16); - tmp2 = String(); + d = Double(); jj_consume_token(21); - tuples.put(tmp,tmp2); propertyValue += "(\u005c""+ tmp + "\u005c",\u005c"" + tmp2 + "\u005c"), "; + tuplesD.put(tmp,d); propertyValue += "(\u005c""+ tmp + "\u005c",\u005c"" + d.toString() + "\u005c"), "; jj_consume_token(16); } jj_consume_token(20); tmp = String(); jj_consume_token(16); - tmp2 = String(); + d = Double(); jj_consume_token(21); - tuples.put(tmp,tmp2); propertyValue += "(\u005c""+ tmp + "\u005c",\u005c"" + tmp2 + "\u005c")"; + tuplesD.put(tmp,d); propertyValue += "(\u005c""+ tmp + "\u005c",\u005c"" + d.toString() + "\u005c")"; jj_consume_token(19); - val = tuples; propertyType = List.class; propertyValue = "["+ propertyValue + "]"; + val = tuplesD; propertyType = List.class; propertyValue = "["+ propertyValue + "]"; break; default: jj_la1[4] = jj_gen; @@ -261,7 +288,7 @@ final public String ComplexId() throws ParseException { Token t1,t2; - if (jj_2_7(2)) { + if (jj_2_9(2)) { t1 = jj_consume_token(ID); jj_consume_token(22); t2 = jj_consume_token(ID); @@ -362,68 +389,106 @@ finally { jj_save(6, xla); } } - private boolean jj_3_5() { - if (jj_scan_token(14)) return true; - Token xsp; - while (true) { - xsp = jj_scanpos; - if (jj_3_1()) { jj_scanpos = xsp; break; } - } - if (jj_3R_5()) return true; - if (jj_scan_token(15)) return true; - return false; + private boolean jj_2_8(int xla) { + jj_la = xla; jj_lastpos = jj_scanpos = token; + try { return !jj_3_8(); } + catch(LookaheadSuccess ls) { return true; } + finally { jj_save(7, xla); } } + private boolean jj_2_9(int xla) { + jj_la = xla; jj_lastpos = jj_scanpos = token; + try { return !jj_3_9(); } + catch(LookaheadSuccess ls) { return true; } + finally { jj_save(8, xla); } + } + private boolean jj_3_1() { - if (jj_3R_5()) return true; + if (jj_3R_6()) return true; if (jj_scan_token(16)) return true; return false; } - private boolean jj_3_6() { + private boolean jj_3_7() { if (jj_scan_token(18)) return true; if (jj_scan_token(19)) return true; return false; } - private boolean jj_3_7() { - if (jj_scan_token(ID)) return true; - if (jj_scan_token(22)) return true; - return false; - } - private boolean jj_3_3() { if (jj_scan_token(20)) return true; - if (jj_3R_5()) return true; + if (jj_3R_6()) return true; if (jj_scan_token(16)) return true; - if (jj_3R_5()) return true; + if (jj_3R_6()) return true; if (jj_scan_token(21)) return true; if (jj_scan_token(16)) return true; return false; } - private boolean jj_3R_5() { - if (jj_scan_token(STRING)) return true; + private boolean jj_3R_7() { + if (jj_scan_token(ID)) return true; return false; } private boolean jj_3_2() { - if (jj_3R_6()) return true; + if (jj_3R_7()) return true; if (jj_scan_token(16)) return true; return false; } - private boolean jj_3_4() { + private boolean jj_3_5() { if (jj_scan_token(14)) return true; if (jj_scan_token(15)) return true; return false; } - private boolean jj_3R_6() { + private boolean jj_3_9() { if (jj_scan_token(ID)) return true; + if (jj_scan_token(22)) return true; return false; } + private boolean jj_3R_8() { + if (jj_scan_token(DOUBLE)) return true; + return false; + } + + private boolean jj_3R_6() { + if (jj_scan_token(STRING)) return true; + return false; + } + + private boolean jj_3_4() { + if (jj_scan_token(20)) return true; + if (jj_3R_6()) return true; + if (jj_scan_token(16)) return true; + if (jj_3R_8()) return true; + if (jj_scan_token(21)) return true; + if (jj_scan_token(16)) return true; + return false; + } + + private boolean jj_3_8() { + if (jj_scan_token(18)) return true; + if (jj_scan_token(20)) return true; + if (jj_3R_6()) return true; + if (jj_scan_token(16)) return true; + if (jj_3R_6()) return true; + return false; + } + + private boolean jj_3_6() { + if (jj_scan_token(14)) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3_1()) { jj_scanpos = xsp; break; } + } + if (jj_3R_6()) return true; + if (jj_scan_token(15)) return true; + return false; + } + /** Generated Token Manager. */ public ConfParserTokenManager token_source; SimpleCharStream jj_input_stream; @@ -443,7 +508,7 @@ private static void jj_la1_init_0() { jj_la1_0 = new int[] {0x200,0x100,0x1e00,0x24000,0x40000,0x1200,0x200,}; } - final private JJCalls[] jj_2_rtns = new JJCalls[7]; + final private JJCalls[] jj_2_rtns = new JJCalls[9]; private boolean jj_rescan = false; private int jj_gc = 0; @@ -668,7 +733,7 @@ private void jj_rescan_token() { jj_rescan = true; - for (int i = 0; i < 7; i++) { + for (int i = 0; i < 9; i++) { try { JJCalls p = jj_2_rtns[i]; do { @@ -682,6 +747,8 @@ case 4: jj_3_5(); break; case 5: jj_3_6(); break; case 6: jj_3_7(); break; + case 7: jj_3_8(); break; + case 8: jj_3_9(); break; } } p = p.next; Modified: trunk/interfaces/src/main/java/org/dllearner/confparser3/conf3.jj =================================================================== --- trunk/interfaces/src/main/java/org/dllearner/confparser3/conf3.jj 2011-11-17 17:00:28 UTC (rev 3414) +++ trunk/interfaces/src/main/java/org/dllearner/confparser3/conf3.jj 2011-11-17 17:39:45 UTC (rev 3415) @@ -141,6 +141,7 @@ String value="", value1="", value2="", tmp="", tmp2=""; Set<String> values = new HashSet<String>(); Map<String,String> tuples = new HashMap<String,String>(); + Map<String,Double> tuplesD = new HashMap<String,Double>(); ConfFileOption2 option = new ConfFileOption2(); boolean isBeanRef = false; @@ -150,6 +151,7 @@ String propertyValue = ""; Class<?> propertyType; Object val = null; + Double d; } { beanName=Id() [ "." propertyName = Id() {containsSubOption=true;} ] @@ -180,15 +182,24 @@ { val = values; propertyType = Set.class; propertyValue = "{"+ propertyValue + "}"; isBeanCollection = true;} // empty list | LOOKAHEAD("[" "]") "[" "]" { val = new LinkedList(); propertyType = List.class; propertyValue = "[]";} - // a list with several elements, which tuples + // a list with several elements with tuples // e.g. [("a","b"),("c","d")] - | "[" + | LOOKAHEAD( "[" "(" String() "," String()) + "[" ( LOOKAHEAD(6) "(" tmp=String() "," tmp2=String() ")" { tuples.put(tmp,tmp2); propertyValue += "(\""+ tmp + "\",\"" + tmp2 + "\"), "; } "," )* "(" tmp=String() "," tmp2=String() ")" { tuples.put(tmp,tmp2); propertyValue += "(\""+ tmp + "\",\"" + tmp2 + "\")";} - "]" { val = tuples; propertyType = List.class; propertyValue = "["+ propertyValue + "]";} - ) + "]" { val = tuples; propertyType = List.class; propertyValue = "["+ propertyValue + "]";} + // a list with several elements with doubles + // e.g. [("a",1.0),("c",0.7)] + | "[" + ( LOOKAHEAD(6) "(" tmp=String() "," d=Double() ")" + { tuplesD.put(tmp,d); propertyValue += "(\""+ tmp + "\",\"" + d.toString() + "\"), "; } "," )* + "(" tmp=String() "," d=Double() ")" + { tuplesD.put(tmp,d); propertyValue += "(\""+ tmp + "\",\"" + d.toString() + "\")";} + "]" { val = tuplesD; propertyType = List.class; propertyValue = "["+ propertyValue + "]";} + ) // <CONF_END> { option.setBeanRef(isBeanRef); Modified: trunk/test/fuzzydll/fuzzytrains.conf =================================================================== --- trunk/test/fuzzydll/fuzzytrains.conf 2011-11-17 17:00:28 UTC (rev 3414) +++ trunk/test/fuzzydll/fuzzytrains.conf 2011-11-17 17:39:45 UTC (rev 3415) @@ -19,6 +19,7 @@ lp.type = "fuzzyPosNeg" lp.positiveExamples = { "ex:east1", "ex:east2" } lp.negativeExamples = { "ex:west6", "ex:west7" } +lp.fuzzyEx = [("ex:east1",0.6)] // create learning algorithm to run alg.type = "Fuzzy CELOE" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |