From: <jen...@us...> - 2008-11-30 15:09:45
|
Revision: 1537 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1537&view=rev Author: jenslehmann Date: 2008-11-30 15:09:42 +0000 (Sun, 30 Nov 2008) Log Message: ----------- extended learning algorithm options wrt. ontology engineering Modified Paths: -------------- trunk/examples/swore/swore.conf trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLComponent.java trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java trunk/src/dl-learner/org/dllearner/algorithms/refexamples/MultiHeuristic.java trunk/src/dl-learner/org/dllearner/core/configurators/ExampleBasedROLComponentConfigurator.java trunk/src/dl-learner/org/dllearner/core/options/CommonConfigOptions.java trunk/src/dl-learner/org/dllearner/parser/ConfParserTokenManager.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/PrologParser.java trunk/src/dl-learner/org/dllearner/parser/PrologParserConstants.java trunk/src/dl-learner/org/dllearner/parser/PrologParserTokenManager.java trunk/src/dl-learner/org/dllearner/parser/SimpleCharStream.java trunk/src/dl-learner/org/dllearner/parser/Token.java trunk/src/dl-learner/org/dllearner/parser/TokenMgrError.java trunk/src/dl-learner/org/dllearner/tools/protege/ProtegePlugin.java Modified: trunk/examples/swore/swore.conf =================================================================== --- trunk/examples/swore/swore.conf 2008-11-30 13:24:18 UTC (rev 1536) +++ trunk/examples/swore/swore.conf 2008-11-30 15:09:42 UTC (rev 1537) @@ -1,8 +1,32 @@ +/** + * Example file for typical ontology engineering setup. + * + * SWORE is the SoftWiki ontology for requirements engineering. + * + * Desired Solution: + * CustomerRequirement = Requirement AND EXISTS createdBy Customer + */ + import("swore.rdf"); +// ignore class for which we want to learn a definition refexamples.ignoredConcepts = { "http://ns.softwiki.de/req/CustomerRequirement" }; -refexamples.ignoredRoles = { "http://ns.softwiki.de/req/broader" }; +// we usually have a configurable minimum accuracy and should set noise to 100 - (min. accuracy)/2 +// because min. accuracy is recommended to be 90%, we set the noise value to 5% +refexamples.noisePercentage = 5; + +// we do not want to terminate when the noise level is reached +refexamples.terminateOnNoiseReached = false; + +// maximum execution time should be sufficiently low value (because the user has to wait for the result) +refexamples.maxExecutionTimeInSeconds = 3; + +// negations are penalised, because they are often not desired, e.g. +// $superclass AND NOT $neighbourclass1 AND NOT $neighbourclass2 is +// one of the patterns which is learned but only sometimes/rarely useful +refexamples.negationPenalty = 2; + +"http://ns.softwiki.de/req/BuildAFastSoftware" +"http://ns.softwiki.de/req/BuildASoftwareThatRuns24hADay" +"http://ns.softwiki.de/req/CreateModernGUIDesign" Modified: trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLComponent.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLComponent.java 2008-11-30 13:24:18 UTC (rev 1536) +++ trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLComponent.java 2008-11-30 15:09:42 UTC (rev 1537) @@ -92,7 +92,7 @@ // actual algorithm private ExampleBasedROLearner algorithm; private static Logger logger = Logger - .getLogger(ExampleBasedROLearner.class); + .getLogger(ExampleBasedROLComponent.class); private String logLevel = CommonConfigOptions.logLevelDefault; // configuration options @@ -208,14 +208,13 @@ options.add(new BooleanConfigOption("usePropernessChecks", "specifies whether to check for equivalence (i.e. discard equivalent refinements)",usePropernessChecksDefault)); options.add(new IntegerConfigOption("maxPosOnlyExpansion", "specifies how often a node in the search tree of a posonly learning problem needs to be expanded before it is" + " considered as solution candidate",maxPosOnlyExpansionDefault)); - DoubleConfigOption noisePercentage = new DoubleConfigOption("noisePercentage", "the (approximated) percentage of noise within the examples",noisePercentageDefault); - noisePercentage.setLowerLimit(0); - noisePercentage.setUpperLimit(100); - options.add(noisePercentage); + options.add(CommonConfigOptions.getNoisePercentage()); + options.add(CommonConfigOptions.getTerminateOnNoiseReached()); options.add(new StringConfigOption("startClass", "the named class which should be used to start the algorithm (GUI: needs a widget for selecting a class)")); options.add(new BooleanConfigOption("forceRefinementLengthIncrease", "specifies whether nodes should be expanded until only longer refinements are reached")); options.add(new DoubleConfigOption("negativeWeight", "Used to penalise errors on negative examples different from those of positive examples (lower = less importance for negatives).",1.0)); options.add(new DoubleConfigOption("startNodeBonus", "You can use this to give a heuristic bonus on the start node (= initially broader exploration of search space).",0.0)); + options.add(new IntegerConfigOption("negationPenalty", "Penalty on negations (TODO: better explanation).", 0)); return options; } Modified: trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java 2008-11-30 13:24:18 UTC (rev 1536) +++ trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java 2008-11-30 15:09:42 UTC (rev 1537) @@ -413,9 +413,9 @@ long traversalInterval = 300l * 1000000000l; long reductionInterval = 300l * 1000000000l; long currentTime; + + while ((!solutionFound || !configurator.getTerminateOnNoiseReached() ) && !stop) { - while (!solutionFound && !stop) { - // print statistics at most once a second currentTime = System.nanoTime(); if (currentTime - lastPrintTime > 3000000000l) { Modified: trunk/src/dl-learner/org/dllearner/algorithms/refexamples/MultiHeuristic.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/refexamples/MultiHeuristic.java 2008-11-30 13:24:18 UTC (rev 1536) +++ trunk/src/dl-learner/org/dllearner/algorithms/refexamples/MultiHeuristic.java 2008-11-30 15:09:42 UTC (rev 1537) @@ -24,6 +24,7 @@ import org.dllearner.core.configurators.ExampleBasedROLComponentConfigurator; import org.dllearner.core.owl.DatatypeSomeRestriction; import org.dllearner.core.owl.Description; +import org.dllearner.core.owl.Negation; import org.dllearner.core.owl.Thing; import org.dllearner.utilities.owl.ConceptComparator; @@ -69,7 +70,7 @@ public class MultiHeuristic implements ExampleBasedHeuristic { private ConceptComparator conceptComparator = new ConceptComparator(); -// private ExampleBasedROLComponentConfigurator configurator; + private ExampleBasedROLComponentConfigurator configurator; // heuristic parameters private double expansionPenaltyFactor = 0.02; @@ -94,7 +95,7 @@ public MultiHeuristic(int nrOfPositiveExamples, int nrOfNegativeExamples, ExampleBasedROLComponentConfigurator configurator) { this.nrOfNegativeExamples = nrOfNegativeExamples; nrOfExamples = nrOfPositiveExamples + nrOfNegativeExamples; -// this.configurator = configurator; + this.configurator = configurator; negativeWeight = configurator.getNegativeWeight(); startNodeBonus = configurator.getStartNodeBonus(); } @@ -149,7 +150,7 @@ // this function can be used to give some constructs a length bonus // compared to their syntactic length - private static int getHeuristicLengthBonus(Description description) { + private int getHeuristicLengthBonus(Description description) { int bonus = 0; // do not count TOP symbols (in particular in ALL r.TOP and EXISTS r.TOP) @@ -157,11 +158,17 @@ if(description instanceof Thing) bonus = 1; //2; + // we put a penalty on negations, because they often overfit + // (TODO: make configurable) + else if(description instanceof Negation) { + bonus = -configurator.getNegationPenalty(); + } + // if(description instanceof BooleanValueRestriction) // bonus = -1; // some bonus for doubles because they are already penalised by length 3 - if(description instanceof DatatypeSomeRestriction) { + else if(description instanceof DatatypeSomeRestriction) { // System.out.println(description); bonus = 3; //2; } Modified: trunk/src/dl-learner/org/dllearner/core/configurators/ExampleBasedROLComponentConfigurator.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/configurators/ExampleBasedROLComponentConfigurator.java 2008-11-30 13:24:18 UTC (rev 1536) +++ trunk/src/dl-learner/org/dllearner/core/configurators/ExampleBasedROLComponentConfigurator.java 2008-11-30 15:09:42 UTC (rev 1537) @@ -349,6 +349,15 @@ return (Double) ComponentManager.getInstance().getConfigOptionValue(exampleBasedROLComponent, "noisePercentage") ; } /** +* terminateOnNoiseReached specifies whether to terminate when noise criterion is met. +* mandatory: false| reinit necessary: true +* default value: true +* @return boolean +**/ +public boolean getTerminateOnNoiseReached() { +return (Boolean) ComponentManager.getInstance().getConfigOptionValue(exampleBasedROLComponent, "terminateOnNoiseReached") ; +} +/** * startClass the named class which should be used to start the algorithm (GUI: needs a widget for selecting a class). * mandatory: false| reinit necessary: true * default value: null @@ -384,6 +393,15 @@ public double getStartNodeBonus() { return (Double) ComponentManager.getInstance().getConfigOptionValue(exampleBasedROLComponent, "startNodeBonus") ; } +/** +* negationPenalty Penalty on negations (TODO: better explanation).. +* mandatory: false| reinit necessary: true +* default value: 0 +* @return int +**/ +public int getNegationPenalty() { +return (Integer) ComponentManager.getInstance().getConfigOptionValue(exampleBasedROLComponent, "negationPenalty") ; +} /** * @param writeSearchTree specifies whether to write a search tree. @@ -674,6 +692,15 @@ reinitNecessary = true; } /** +* @param terminateOnNoiseReached specifies whether to terminate when noise criterion is met. +* mandatory: false| reinit necessary: true +* default value: true +**/ +public void setTerminateOnNoiseReached(boolean terminateOnNoiseReached) { +ComponentManager.getInstance().applyConfigEntry(exampleBasedROLComponent, "terminateOnNoiseReached", terminateOnNoiseReached); +reinitNecessary = true; +} +/** * @param startClass the named class which should be used to start the algorithm (GUI: needs a widget for selecting a class). * mandatory: false| reinit necessary: true * default value: null @@ -709,6 +736,15 @@ ComponentManager.getInstance().applyConfigEntry(exampleBasedROLComponent, "startNodeBonus", startNodeBonus); reinitNecessary = true; } +/** +* @param negationPenalty Penalty on negations (TODO: better explanation).. +* mandatory: false| reinit necessary: true +* default value: 0 +**/ +public void setNegationPenalty(int negationPenalty) { +ComponentManager.getInstance().applyConfigEntry(exampleBasedROLComponent, "negationPenalty", negationPenalty); +reinitNecessary = true; +} /** * true, if this component needs reinitializsation. Modified: trunk/src/dl-learner/org/dllearner/core/options/CommonConfigOptions.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/options/CommonConfigOptions.java 2008-11-30 13:24:18 UTC (rev 1536) +++ trunk/src/dl-learner/org/dllearner/core/options/CommonConfigOptions.java 2008-11-30 15:09:42 UTC (rev 1537) @@ -52,7 +52,8 @@ public static int guaranteeXgoodDescriptionsDefault = 1; public static int maxClassDescriptionTestsDefault = 0; public static String logLevelDefault = "DEBUG"; - //public static double noisePercentageDefault = 0.0; + public static double noisePercentageDefault = 0.0; + public static boolean terminateOnNoiseReachedDefault = true; public static StringConfigOption getVerbosityOption() { StringConfigOption verbosityOption = new StringConfigOption("verbosity", "control verbosity of output for this component", "warning"); @@ -61,6 +62,17 @@ return verbosityOption; } + public static DoubleConfigOption getNoisePercentage() { + DoubleConfigOption noisePercentage = new DoubleConfigOption("noisePercentage", "the (approximated) percentage of noise within the examples",noisePercentageDefault); + noisePercentage.setLowerLimit(0); + noisePercentage.setUpperLimit(100); + return noisePercentage; + } + + public static BooleanConfigOption getTerminateOnNoiseReached() { + return new BooleanConfigOption("terminateOnNoiseReached", "specifies whether to terminate when noise criterion is met", terminateOnNoiseReachedDefault); + } + public static DoubleConfigOption getPercentPerLenghtUnitOption(double defaultValue) { DoubleConfigOption option = new DoubleConfigOption("percentPerLenghtUnit", "describes the reduction in classification accuracy in percent one is willing to accept for reducing the length of the concept by one", defaultValue); option.setLowerLimit(0.0); Modified: trunk/src/dl-learner/org/dllearner/parser/ConfParserTokenManager.java =================================================================== --- trunk/src/dl-learner/org/dllearner/parser/ConfParserTokenManager.java 2008-11-30 13:24:18 UTC (rev 1536) +++ trunk/src/dl-learner/org/dllearner/parser/ConfParserTokenManager.java 2008-11-30 15:09:42 UTC (rev 1537) @@ -16,8 +16,8 @@ import org.dllearner.cli.*; import org.dllearner.utilities.datastructures.*; +@SuppressWarnings("all") /** Token Manager. */ -@SuppressWarnings("all") public class ConfParserTokenManager implements ConfParserConstants { Modified: trunk/src/dl-learner/org/dllearner/parser/KBParser.java =================================================================== --- trunk/src/dl-learner/org/dllearner/parser/KBParser.java 2008-11-30 13:24:18 UTC (rev 1536) +++ trunk/src/dl-learner/org/dllearner/parser/KBParser.java 2008-11-30 15:09:42 UTC (rev 1537) @@ -5,7 +5,8 @@ import java.io.*; import java.net.URL; -public @SuppressWarnings("all") class KBParser implements KBParserConstants { +@SuppressWarnings("all") +public class KBParser implements KBParserConstants { public static String internalNamespace = "http://localhost/foo#"; @@ -659,88 +660,88 @@ throw new Error("Missing return statement in function"); } - final private boolean jj_2_1(int xla) { + private boolean jj_2_1(int xla) { jj_la = xla; jj_lastpos = jj_scanpos = token; try { return !jj_3_1(); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(0, xla); } } - final private boolean jj_2_2(int xla) { + private boolean jj_2_2(int xla) { jj_la = xla; jj_lastpos = jj_scanpos = token; try { return !jj_3_2(); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(1, xla); } } - final private boolean jj_2_3(int xla) { + private boolean jj_2_3(int xla) { jj_la = xla; jj_lastpos = jj_scanpos = token; try { return !jj_3_3(); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(2, xla); } } - final private boolean jj_2_4(int xla) { + private boolean jj_2_4(int xla) { jj_la = xla; jj_lastpos = jj_scanpos = token; try { return !jj_3_4(); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(3, xla); } } - final private boolean jj_2_5(int xla) { + private boolean jj_2_5(int xla) { jj_la = xla; jj_lastpos = jj_scanpos = token; try { return !jj_3_5(); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(4, xla); } } - final private boolean jj_2_6(int xla) { + private boolean jj_2_6(int xla) { jj_la = xla; jj_lastpos = jj_scanpos = token; try { return !jj_3_6(); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(5, xla); } } - final private boolean jj_2_7(int xla) { + private boolean jj_2_7(int xla) { jj_la = xla; jj_lastpos = jj_scanpos = token; try { return !jj_3_7(); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(6, xla); } } - final private boolean jj_2_8(int xla) { + 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); } } - final private boolean jj_3_7() { + 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; } - final private boolean jj_3R_13() { + private boolean jj_3R_13() { if (jj_scan_token(18)) return true; if (jj_3R_2()) return true; return false; } - final private boolean jj_3R_25() { + private boolean jj_3R_25() { if (jj_scan_token(NUMBER)) return true; return false; } - final private boolean jj_3_6() { + private boolean jj_3_6() { if (jj_scan_token(22)) return true; if (jj_3R_2()) return true; if (jj_scan_token(14)) return true; return false; } - final private boolean jj_3R_12() { + private boolean jj_3R_12() { if (jj_scan_token(17)) return true; if (jj_3R_4()) return true; if (jj_scan_token(COMMAND_END)) return true; @@ -748,7 +749,7 @@ return false; } - final private boolean jj_3R_11() { + private boolean jj_3R_11() { if (jj_scan_token(16)) return true; if (jj_3R_4()) return true; if (jj_scan_token(COMMAND_END)) return true; @@ -756,7 +757,7 @@ return false; } - final private boolean jj_3R_10() { + private boolean jj_3R_10() { if (jj_scan_token(22)) return true; if (jj_3R_2()) return true; if (jj_scan_token(15)) return true; @@ -765,7 +766,7 @@ return false; } - final private boolean jj_3_4() { + private boolean jj_3_4() { if (jj_3R_2()) return true; Token xsp; xsp = jj_scanpos; @@ -776,7 +777,7 @@ return false; } - final private boolean jj_3R_9() { + 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; @@ -785,33 +786,33 @@ return false; } - final private boolean jj_3_3() { + private boolean jj_3_3() { if (jj_3R_2()) return true; if (jj_scan_token(25)) return true; return false; } - final private boolean jj_3R_18() { + private boolean jj_3R_18() { if (jj_3R_27()) return true; return false; } - final private boolean jj_3_5() { + private boolean jj_3_5() { if (jj_3R_5()) return true; return false; } - final private boolean jj_3R_8() { + private boolean jj_3R_8() { if (jj_scan_token(13)) return true; return false; } - final private boolean jj_3R_7() { + private boolean jj_3R_7() { if (jj_scan_token(12)) return true; return false; } - final private boolean jj_3R_2() { + private boolean jj_3R_2() { Token xsp; xsp = jj_scanpos; if (jj_3R_7()) { @@ -851,22 +852,22 @@ return false; } - final private boolean jj_3R_26() { + private boolean jj_3R_26() { if (jj_scan_token(ID)) return true; return false; } - final private boolean jj_3R_20() { + private boolean jj_3R_20() { if (jj_3R_27()) return true; return false; } - final private boolean jj_3R_17() { + private boolean jj_3R_17() { if (jj_3R_26()) return true; return false; } - final private boolean jj_3R_3() { + private boolean jj_3R_3() { Token xsp; xsp = jj_scanpos; if (jj_3R_17()) { @@ -876,7 +877,7 @@ return false; } - final private boolean jj_3_2() { + private boolean jj_3_2() { Token xsp; xsp = jj_scanpos; if (jj_scan_token(18)) jj_scanpos = xsp; @@ -887,7 +888,7 @@ return false; } - final private boolean jj_3_1() { + private boolean jj_3_1() { if (jj_3R_2()) return true; if (jj_scan_token(22)) return true; if (jj_3R_3()) return true; @@ -896,17 +897,17 @@ return false; } - final private boolean jj_3R_24() { + private boolean jj_3R_24() { if (jj_3R_27()) return true; return false; } - final private boolean jj_3R_19() { + private boolean jj_3R_19() { if (jj_3R_26()) return true; return false; } - final private boolean jj_3R_4() { + private boolean jj_3R_4() { Token xsp; xsp = jj_scanpos; if (jj_3R_19()) { @@ -916,17 +917,17 @@ return false; } - final private boolean jj_3R_22() { + private boolean jj_3R_22() { if (jj_3R_27()) return true; return false; } - final private boolean jj_3R_23() { + private boolean jj_3R_23() { if (jj_3R_26()) return true; return false; } - final private boolean jj_3R_6() { + private boolean jj_3R_6() { Token xsp; xsp = jj_scanpos; if (jj_3R_23()) { @@ -936,12 +937,12 @@ return false; } - final private boolean jj_3R_21() { + private boolean jj_3R_21() { if (jj_3R_26()) return true; return false; } - final private boolean jj_3R_5() { + private boolean jj_3R_5() { Token xsp; xsp = jj_scanpos; if (jj_3R_21()) { @@ -951,12 +952,12 @@ return false; } - final private boolean jj_3R_27() { + private boolean jj_3R_27() { if (jj_scan_token(STRING)) return true; return false; } - final private boolean jj_3R_16() { + private boolean jj_3R_16() { if (jj_scan_token(22)) return true; if (jj_3R_6()) return true; if (jj_scan_token(47)) return true; @@ -965,7 +966,7 @@ return false; } - final private boolean jj_3_8() { + private boolean jj_3_8() { if (jj_scan_token(22)) return true; if (jj_3R_6()) return true; if (jj_scan_token(47)) return true; @@ -974,7 +975,7 @@ return false; } - final private boolean jj_3R_15() { + private boolean jj_3R_15() { if (jj_scan_token(20)) return true; if (jj_3R_25()) return true; if (jj_3R_4()) return true; @@ -983,7 +984,7 @@ return false; } - final private boolean jj_3R_14() { + private boolean jj_3R_14() { if (jj_scan_token(19)) return true; if (jj_3R_25()) return true; if (jj_3R_4()) return true; @@ -992,35 +993,39 @@ return false; } + /** Generated Token Manager. */ public KBParserTokenManager token_source; SimpleCharStream jj_input_stream; - public Token token, jj_nt; + /** Current token. */ + public Token token; + /** Next token. */ + public Token jj_nt; private int jj_ntk; private Token jj_scanpos, jj_lastpos; private int jj_la; - public boolean lookingAhead = false; - private boolean jj_semLA; private int jj_gen; final private int[] jj_la1 = new int[16]; static private int[] jj_la1_0; static private int[] jj_la1_1; static { - jj_la1_0(); - jj_la1_1(); + jj_la1_init_0(); + jj_la1_init_1(); } - private static void jj_la1_0() { + private static void jj_la1_init_0() { jj_la1_0 = new int[] {0xf07f3200,0xf0000000,0x40000,0xc000000,0x0,0x0,0x0,0x0,0x0,0x3000,0x1f0000,0x400000,0x200200,0x200200,0x200200,0x200200,}; } - private static void jj_la1_1() { + 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[8]; private boolean jj_rescan = false; private int jj_gc = 0; + /** Constructor with InputStream. */ public KBParser(java.io.InputStream stream) { this(stream, null); } + /** Constructor with InputStream and supplied encoding */ public KBParser(java.io.InputStream stream, String encoding) { try { jj_input_stream = new SimpleCharStream(stream, encoding, 1, 1); } catch(java.io.UnsupportedEncodingException e) { throw new RuntimeException(e); } token_source = new KBParserTokenManager(jj_input_stream); @@ -1031,9 +1036,11 @@ for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); } + /** Reinitialise. */ public void ReInit(java.io.InputStream stream) { ReInit(stream, null); } + /** Reinitialise. */ public void ReInit(java.io.InputStream stream, String encoding) { try { jj_input_stream.ReInit(stream, encoding, 1, 1); } catch(java.io.UnsupportedEncodingException e) { throw new RuntimeException(e); } token_source.ReInit(jj_input_stream); @@ -1044,6 +1051,7 @@ for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); } + /** Constructor. */ public KBParser(java.io.Reader stream) { jj_input_stream = new SimpleCharStream(stream, 1, 1); token_source = new KBParserTokenManager(jj_input_stream); @@ -1054,6 +1062,7 @@ for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); } + /** Reinitialise. */ public void ReInit(java.io.Reader stream) { jj_input_stream.ReInit(stream, 1, 1); token_source.ReInit(jj_input_stream); @@ -1064,6 +1073,7 @@ for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); } + /** Constructor with generated Token Manager. */ public KBParser(KBParserTokenManager tm) { token_source = tm; token = new Token(); @@ -1073,6 +1083,7 @@ for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); } + /** Reinitialise. */ public void ReInit(KBParserTokenManager tm) { token_source = tm; token = new Token(); @@ -1082,7 +1093,7 @@ for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); } - final private Token jj_consume_token(int kind) throws ParseException { + private Token jj_consume_token(int kind) throws ParseException { Token oldToken; if ((oldToken = token).next != null) token = token.next; else token = token.next = token_source.getNextToken(); @@ -1108,7 +1119,7 @@ static private final class LookaheadSuccess extends java.lang.Error { } final private LookaheadSuccess jj_ls = new LookaheadSuccess(); - final private boolean jj_scan_token(int kind) { + private boolean jj_scan_token(int kind) { if (jj_scanpos == jj_lastpos) { jj_la--; if (jj_scanpos.next == null) { @@ -1129,6 +1140,8 @@ return false; } + +/** Get the next Token. */ final public Token getNextToken() { if (token.next != null) token = token.next; else token = token.next = token_source.getNextToken(); @@ -1137,8 +1150,9 @@ return token; } +/** Get the specific Token. */ final public Token getToken(int index) { - Token t = lookingAhead ? jj_scanpos : token; + Token t = token; for (int i = 0; i < index; i++) { if (t.next != null) t = t.next; else t = t.next = token_source.getNextToken(); @@ -1146,14 +1160,14 @@ return t; } - final private int jj_ntk() { + private int jj_ntk() { if ((jj_nt=token.next) == null) return (jj_ntk = (token.next=token_source.getNextToken()).kind); else return (jj_ntk = jj_nt.kind); } - private java.util.Vector<int[]> jj_expentries = new java.util.Vector<int[]>(); + private java.util.List<int[]> jj_expentries = new java.util.ArrayList<int[]>(); private int[] jj_expentry; private int jj_kind = -1; private int[] jj_lasttokens = new int[100]; @@ -1168,27 +1182,25 @@ for (int i = 0; i < jj_endpos; i++) { jj_expentry[i] = jj_lasttokens[i]; } - boolean exists = false; - for (java.util.Enumeration e = jj_expentries.elements(); e.hasMoreElements();) { - int[] oldentry = (int[])(e.nextElement()); + jj_entries_loop: for (java.util.Iterator it = jj_expentries.iterator(); it.hasNext();) { + int[] oldentry = (int[])(it.next()); if (oldentry.length == jj_expentry.length) { - exists = true; for (int i = 0; i < jj_expentry.length; i++) { if (oldentry[i] != jj_expentry[i]) { - exists = false; - break; + continue jj_entries_loop; } } - if (exists) break; + jj_expentries.add(jj_expentry); + break jj_entries_loop; } } - if (!exists) jj_expentries.addElement(jj_expentry); if (pos != 0) jj_lasttokens[(jj_endpos = pos) - 1] = kind; } } + /** Generate ParseException. */ public ParseException generateParseException() { - jj_expentries.removeAllElements(); + jj_expentries.clear(); boolean[] la1tokens = new boolean[50]; if (jj_kind >= 0) { la1tokens[jj_kind] = true; @@ -1210,7 +1222,7 @@ if (la1tokens[i]) { jj_expentry = new int[1]; jj_expentry[0] = i; - jj_expentries.addElement(jj_expentry); + jj_expentries.add(jj_expentry); } } jj_endpos = 0; @@ -1218,18 +1230,20 @@ jj_add_error_token(0, 0); int[][] exptokseq = new int[jj_expentries.size()][]; for (int i = 0; i < jj_expentries.size(); i++) { - exptokseq[i] = jj_expentries.elementAt(i); + exptokseq[i] = jj_expentries.get(i); } return new ParseException(token, exptokseq, tokenImage); } + /** Enable tracing. */ final public void enable_tracing() { } + /** Disable tracing. */ final public void disable_tracing() { } - final private void jj_rescan_token() { + private void jj_rescan_token() { jj_rescan = true; for (int i = 0; i < 8; i++) { try { @@ -1255,7 +1269,7 @@ jj_rescan = false; } - final private void jj_save(int index, int xla) { + private void jj_save(int index, int xla) { JJCalls p = jj_2_rtns[index]; while (p.gen > jj_gen) { if (p.next == null) { p = p.next = new JJCalls(); break; } Modified: trunk/src/dl-learner/org/dllearner/parser/KBParserConstants.java =================================================================== --- trunk/src/dl-learner/org/dllearner/parser/KBParserConstants.java 2008-11-30 13:24:18 UTC (rev 1536) +++ trunk/src/dl-learner/org/dllearner/parser/KBParserConstants.java 2008-11-30 15:09:42 UTC (rev 1537) @@ -1,29 +1,54 @@ /* Generated By:JavaCC: Do not edit this line. KBParserConstants.java */ package org.dllearner.parser; -public @SuppressWarnings("all") interface KBParserConstants { +/** + * Token literal values and constants. + * Generated by org.javacc.parser.OtherFilesGen#start() + */ +public interface KBParserConstants { + + /** End of File. */ int EOF = 0; + /** RegularExpression Id. */ int SINGLE_LINE_COMMENT = 5; + /** RegularExpression Id. */ int FORMAL_COMMENT = 6; + /** RegularExpression Id. */ int MULTI_LINE_COMMENT = 7; + /** RegularExpression Id. */ int COMMAND_END = 8; + /** RegularExpression Id. */ int ID = 9; + /** RegularExpression Id. */ int NUMBER = 10; + /** RegularExpression Id. */ int DOUBLE = 11; + /** RegularExpression Id. */ int TOP = 12; + /** RegularExpression Id. */ int BOTTOM = 13; + /** RegularExpression Id. */ int AND = 14; + /** RegularExpression Id. */ int OR = 15; + /** RegularExpression Id. */ int EXISTS = 16; + /** RegularExpression Id. */ int ALL = 17; + /** RegularExpression Id. */ int NOT = 18; + /** RegularExpression Id. */ int GE = 19; + /** RegularExpression Id. */ int LE = 20; + /** RegularExpression Id. */ int STRING = 21; + /** Lexical state. */ int DEFAULT = 0; + /** Literal token values. */ String[] tokenImage = { "<EOF>", "\" \"", Modified: trunk/src/dl-learner/org/dllearner/parser/KBParserTokenManager.java =================================================================== --- trunk/src/dl-learner/org/dllearner/parser/KBParserTokenManager.java 2008-11-30 13:24:18 UTC (rev 1536) +++ trunk/src/dl-learner/org/dllearner/parser/KBParserTokenManager.java 2008-11-30 15:09:42 UTC (rev 1537) @@ -4,9 +4,14 @@ import java.io.*; import java.net.URL; -public @SuppressWarnings("all") class KBParserTokenManager implements KBParserConstants +@SuppressWarnings("all") +/** Token Manager. */ +public class KBParserTokenManager implements KBParserConstants { + + /** Debug output. */ public java.io.PrintStream debugStream = System.out; + /** Set debug output. */ public void setDebugStream(java.io.PrintStream ds) { debugStream = ds; } private final int jjStopStringLiteralDfa_0(int pos, long active0) { @@ -28,22 +33,14 @@ { return jjMoveNfa_0(jjStopStringLiteralDfa_0(pos, active0), pos + 1); } -private final int jjStopAtPos(int pos, int kind) +private int jjStopAtPos(int pos, int kind) { jjmatchedKind = kind; jjmatchedPos = pos; return pos + 1; } -private final int jjStartNfaWithStates_0(int pos, int kind, int state) +private int jjMoveStringLiteralDfa0_0() { - jjmatchedKind = kind; - jjmatchedPos = pos; - try { curChar = input_stream.readChar(); } - catch(java.io.IOException e) { return pos + 1; } - return jjMoveNfa_0(state, pos + 1); -} -private final int jjMoveStringLiteralDfa0_0() -{ switch(curChar) { case 40: @@ -82,7 +79,7 @@ return jjMoveNfa_0(0, 0); } } -private final int jjMoveStringLiteralDfa1_0(long active0) +private int jjMoveStringLiteralDfa1_0(long active0) { try { curChar = input_stream.readChar(); } catch(java.io.IOException e) { @@ -130,7 +127,7 @@ } return jjStartNfa_0(0, active0); } -private final int jjMoveStringLiteralDfa2_0(long old0, long active0) +private int jjMoveStringLiteralDfa2_0(long old0, long active0) { if (((active0 &= old0)) == 0L) return jjStartNfa_0(0, old0); @@ -187,7 +184,7 @@ } return jjStartNfa_0(1, active0); } -private final int jjMoveStringLiteralDfa3_0(long old0, long active0) +private int jjMoveStringLiteralDfa3_0(long old0, long active0) { if (((active0 &= old0)) == 0L) return jjStartNfa_0(1, old0); @@ -233,7 +230,7 @@ } return jjStartNfa_0(2, active0); } -private final int jjMoveStringLiteralDfa4_0(long old0, long active0) +private int jjMoveStringLiteralDfa4_0(long old0, long active0) { if (((active0 &= old0)) == 0L) return jjStartNfa_0(2, old0); @@ -281,7 +278,7 @@ } return jjStartNfa_0(3, active0); } -private final int jjMoveStringLiteralDfa5_0(long old0, long active0) +private int jjMoveStringLiteralDfa5_0(long old0, long active0) { if (((active0 &= old0)) == 0L) return jjStartNfa_0(3, old0); @@ -325,7 +322,7 @@ } return jjStartNfa_0(4, active0); } -private final int jjMoveStringLiteralDfa6_0(long old0, long active0) +private int jjMoveStringLiteralDfa6_0(long old0, long active0) { if (((active0 &= old0)) == 0L) return jjStartNfa_0(4, old0); @@ -375,7 +372,7 @@ } return jjStartNfa_0(5, active0); } -private final int jjMoveStringLiteralDfa7_0(long old0, long active0) +private int jjMoveStringLiteralDfa7_0(long old0, long active0) { if (((active0 &= old0)) == 0L) return jjStartNfa_0(5, old0); @@ -407,7 +404,7 @@ } return jjStartNfa_0(6, active0); } -private final int jjMoveStringLiteralDfa8_0(long old0, long active0) +private int jjMoveStringLiteralDfa8_0(long old0, long active0) { if (((active0 &= old0)) == 0L) return jjStartNfa_0(6, old0); @@ -435,7 +432,7 @@ } return jjStartNfa_0(7, active0); } -private final int jjMoveStringLiteralDfa9_0(long old0, long active0) +private int jjMoveStringLiteralDfa9_0(long old0, long active0) { if (((active0 &= old0)) == 0L) return jjStartNfa_0(7, old0); @@ -469,7 +466,7 @@ } return jjStartNfa_0(8, active0); } -private final int jjMoveStringLiteralDfa10_0(long old0, long active0) +private int jjMoveStringLiteralDfa10_0(long old0, long active0) { if (((active0 &= old0)) == 0L) return jjStartNfa_0(8, old0); @@ -489,7 +486,7 @@ } return jjStartNfa_0(9, active0); } -private final int jjMoveStringLiteralDfa11_0(long old0, long active0) +private int jjMoveStringLiteralDfa11_0(long old0, long active0) { if (((active0 &= old0)) == 0L) return jjStartNfa_0(9, old0); @@ -513,7 +510,7 @@ } return jjStartNfa_0(10, active0); } -private final int jjMoveStringLiteralDfa12_0(long old0, long active0) +private int jjMoveStringLiteralDfa12_0(long old0, long active0) { if (((active0 &= old0)) == 0L) return jjStartNfa_0(10, old0); @@ -533,7 +530,7 @@ } return jjStartNfa_0(11, active0); } -private final int jjMoveStringLiteralDfa13_0(long old0, long active0) +private int jjMoveStringLiteralDfa13_0(long old0, long active0) { if (((active0 &= old0)) == 0L) return jjStartNfa_0(11, old0); @@ -553,7 +550,7 @@ } return jjStartNfa_0(12, active0); } -private final int jjMoveStringLiteralDfa14_0(long old0, long active0) +private int jjMoveStringLiteralDfa14_0(long old0, long active0) { if (((active0 &= old0)) == 0L) return jjStartNfa_0(12, old0); @@ -575,7 +572,7 @@ } return jjStartNfa_0(13, active0); } -private final int jjMoveStringLiteralDfa15_0(long old0, long active0) +private int jjMoveStringLiteralDfa15_0(long old0, long active0) { if (((active0 &= old0)) == 0L) return jjStartNfa_0(13, old0); @@ -597,7 +594,7 @@ } return jjStartNfa_0(14, active0); } -private final int jjMoveStringLiteralDfa16_0(long old0, long active0) +private int jjMoveStringLiteralDfa16_0(long old0, long active0) { if (((active0 &= old0)) == 0L) return jjStartNfa_0(14, old0); @@ -621,7 +618,7 @@ } return jjStartNfa_0(15, active0); } -private final int jjMoveStringLiteralDfa17_0(long old0, long active0) +private int jjMoveStringLiteralDfa17_0(long old0, long active0) { if (((active0 &= old0)) == 0L) return jjStartNfa_0(15, old0); @@ -643,7 +640,7 @@ } return jjStartNfa_0(16, active0); } -private final int jjMoveStringLiteralDfa18_0(long old0, long active0) +private int jjMoveStringLiteralDfa18_0(long old0, long active0) { if (((active0 &= old0)) == 0L) return jjStartNfa_0(16, old0); @@ -669,7 +666,7 @@ } return jjStartNfa_0(17, active0); } -private final int jjMoveStringLiteralDfa19_0(long old0, long active0) +private int jjMoveStringLiteralDfa19_0(long old0, long active0) { if (((active0 &= old0)) == 0L) return jjStartNfa_0(17, old0); @@ -693,7 +690,7 @@ } return jjStartNfa_0(18, active0); } -private final int jjMoveStringLiteralDfa20_0(long old0, long active0) +private int jjMoveStringLiteralDfa20_0(long old0, long active0) { if (((active0 &= old0)) == 0L) return jjStartNfa_0(18, old0); @@ -715,7 +712,7 @@ } return jjStartNfa_0(19, active0); } -private final int jjMoveStringLiteralDfa21_0(long old0, long active0) +private int jjMoveStringLiteralDfa21_0(long old0, long active0) { if (((active0 &= old0)) == 0L) return jjStartNfa_0(19, old0); @@ -735,47 +732,16 @@ } return jjStartNfa_0(20, active0); } -private final void jjCheckNAdd(int state) -{ - if (jjrounds[state] != jjround) - { - jjstateSet[jjnewStateCnt++] = state; - jjrounds[state] = jjround; - } -} -private final void jjAddStates(int start, int end) -{ - do { - jjstateSet[jjnewStateCnt++] = jjnextStates[start]; - } while (start++ != end); -} -private final void jjCheckNAddTwoStates(int state1, int state2) -{ - jjCheckNAdd(state1); - jjCheckNAdd(state2); -} -private final void jjCheckNAddStates(int start, int end) -{ - do { - jjCheckNAdd(jjnextStates[start]); - } while (start++ != end); -} -private final void jjCheckNAddStates(int start) -{ - jjCheckNAdd(jjnextStates[start]); - jjCheckNAdd(jjnextStates[start + 1]); -} static final long[] jjbitVec0 = { 0x0L, 0x0L, 0xffffffffffffffffL, 0xffffffffffffffffL }; -private final int jjMoveNfa_0(int startState, int curPos) +private int jjMoveNfa_0(int startState, int curPos) { - int[] nextStates; int startsAt = 0; jjnewStateCnt = 53; int i = 1; jjstateSet[0] = startState; - int j, kind = 0x7fffffff; + int kind = 0x7fffffff; for (;;) { if (++jjround == 0x7fffffff) @@ -783,7 +749,7 @@ if (curChar < 64) { long l = 1L << curChar; - MatchLoop: do + do { switch(jjstateSet[--i]) { @@ -946,7 +912,7 @@ else if (curChar < 128) { long l = 1L << (curChar & 077); - MatchLoop: do + do { switch(jjstateSet[--i]) { @@ -1093,7 +1059,7 @@ { int i2 = (curChar & 0xff) >> 6; long l2 = 1L << (curChar & 077); - MatchLoop: do + do { switch(jjstateSet[--i]) { @@ -1144,6 +1110,8 @@ 48, 49, 50, 29, 40, 41, 30, 31, 33, 36, 37, 39, 43, 44, 46, 25, 27, 21, 22, }; + +/** Token literal values. */ public static final String[] jjstrLiteralImages = { "", null, null, null, null, null, null, null, "\56", null, null, null, "\124\117\120", "\102\117\124\124\117\115", "\101\116\104", "\117\122", null, null, null, @@ -1157,6 +1125,8 @@ "\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", }; + +/** Lexer state names. */ public static final String[] lexStateNames = { "DEFAULT", }; @@ -1170,15 +1140,20 @@ private final int[] jjrounds = new int[53]; private final int[] jjstateSet = new int[106]; protected char curChar; +/** Constructor. */ public KBParserTokenManager(SimpleCharStream stream){ if (SimpleCharStream.staticFlag) throw new Error("ERROR: Cannot use a static CharStream class with a non-static lexical analyzer."); input_stream = stream; } + +/** Constructor. */ public KBParserTokenManager(SimpleCharStream stream, int lexState){ this(stream); SwitchTo(lexState); } + +/** Reinitialise parser. */ public void ReInit(SimpleCharStream stream) { jjmatchedPos = jjnewStateCnt = 0; @@ -1186,18 +1161,22 @@ input_stream = stream; ReInitRounds(); } -private final void ReInitRounds() +private void ReInitRounds() { int i; jjround = 0x80000001; for (i = 53; i-- > 0;) jjrounds[i] = 0x80000000; } + +/** Reinitialise parser. */ public void ReInit(SimpleCharStream stream, int lexState) { ReInit(stream); SwitchTo(lexState); } + +/** Switch to specified lex state. */ public void SwitchTo(int lexState) { if (lexState >= 1 || lexState < 0) @@ -1208,14 +1187,25 @@ protected Token jjFillToken() { - Token t = Token.newToken(jjmatchedKind); - t.kind = jjmatchedKind; + final Token t; + final String curTokenImage; + final int beginLine; + final int endLine; + final int beginColumn; + final int endColumn; String im = jjstrLiteralImages[jjmatchedKind]; - t.image = (im == null) ? input_stream.GetImage() : im; - t.beginLine = input_stream.getBeginLine(); - t.beginColumn = input_stream.getBeginColumn(); - t.endLine = input_stream.getEndLine(); - t.endColumn = input_stream.getEndColumn(); + curTokenImage = (im == null) ? input_stream.GetImage() : im; + beginLine = input_stream.getBeginLine(); + beginColumn = input_stream.getBeginColumn(); + endLine = input_stream.getEndLine(); + endColumn = input_stream.getEndColumn(); + t = Token.newToken(jjmatchedKind, curTokenImage); + + t.beginLine = beginLine; + t.endLine = endLine; + t.beginColumn = beginColumn; + t.endColumn = endColumn; + return t; } @@ -1226,10 +1216,9 @@ int jjmatchedPos; int jjmatchedKind; +/** Get the next Token. */ public Token getNextToken() { - int kind; - Token specialToken = null; Token matchedToken; int curPos = 0; @@ -1292,4 +1281,31 @@ } } +private void jjCheckNAdd(int state) +{ + if (jjrounds[state] != jjround) + { + jjstateSet[jjnewStateCnt++] = state; + jjrounds[state] = jjround; + } } +private void jjAddStates(int start, int end) +{ + do { + jjstateSet[jjnewStateCnt++] = jjnextStates[start]; + } while (start++ != end); +} +private void jjCheckNAddTwoStates(int state1, int state2) +{ + jjCheckNAdd(state1); + jjCheckNAdd(state2); +} + +private void jjCheckNAddStates(int start, int end) +{ + do { + jjCheckNAdd(jjnextStates[start]); + } while (start++ != end); +} + +} Modified: trunk/src/dl-learner/org/dllearner/parser/PrologParser.java =================================================================== --- trunk/src/dl-learner/org/dllearner/parser/PrologParser.java 2008-11-30 13:24:18 UTC (rev 1536) +++ trunk/src/dl-learner/org/dllearner/parser/PrologParser.java 2008-11-30 15:09:42 UTC (rev 1537) @@ -1,7 +1,8 @@ /* Generated By:JavaCC: Do not edit this line. PrologParser.java */ package org.dllearner.parser; -public @SuppressWarnings("all") class PrologParser implements PrologParserConstants { +@SuppressWarnings("all") +public class PrologParser implements PrologParserConstants { public PrologParser() { this(new java.io.StringReader("")); } @@ -307,106 +308,106 @@ throw new Error("Missing return statement in function"); } - final private boolean jj_2_1(int xla) { + private boolean jj_2_1(int xla) { jj_la = xla; jj_lastpos = jj_scanpos = token; try { return !jj_3_1(); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(0, xla); } } - final private boolean jj_2_2(int xla) { + private boolean jj_2_2(int xla) { jj_la = xla; jj_lastpos = jj_scanpos = token; try { return !jj_3_2(); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(1, xla); } } - final private boolean jj_2_3(int xla) { + private boolean jj_2_3(int xla) { jj_la = xla; jj_lastpos = jj_scanpos = token; try { return !jj_3_3(); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(2, xla); } } - final private boolean jj_2_4(int xla) { + private boolean jj_2_4(int xla) { jj_la = xla; jj_lastpos = jj_scanpos = token; try { return !jj_3_4(); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(3, xla); } } - final private boolean jj_2_5(int xla) { + private boolean jj_2_5(int xla) { jj_la = xla; jj_lastpos = jj_scanpos = token; try { return !jj_3_5(); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(4, xla); } } - final private boolean jj_2_6(int xla) { + private boolean jj_2_6(int xla) { jj_la = xla; jj_lastpos = jj_scanpos = token; try { return !jj_3_6(); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(5, xla); } } - final private boolean jj_2_7(int xla) { + private boolean jj_2_7(int xla) { jj_la = xla; jj_lastpos = jj_scanpos = token; try { return !jj_3_7(); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(6, xla); } } - final private boolean jj_2_8(int xla) { + 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); } } - final private boolean jj_2_9(int 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); } } - final private boolean jj_3R_5() { + private boolean jj_3R_5() { if (jj_scan_token(OPERATOR)) return true; return false; } - final private boolean jj_3_7() { + private boolean jj_3_7() { if (jj_3R_9()) return true; if (jj_scan_token(21)) return true; return false; } - final private boolean jj_3R_13() { + private boolean jj_3R_13() { if (jj_3R_15()) return true; return false; } - final private boolean jj_3R_12() { + private boolean jj_3R_12() { if (jj_scan_token(STRINGCONSTANT)) return true; return false; } - final private boolean jj_3R_11() { + private boolean jj_3R_11() { if (jj_scan_token(DOUBLE)) return true; return false; } - final private boolean jj_3R_10() { + private boolean jj_3R_10() { if (jj_scan_token(VAR)) return true; return false; } - final private boolean jj_3_6() { + private boolean jj_3_6() { if (jj_scan_token(IDENTIFIER)) return true; return false; } - final private boolean jj_3R_18() { + private boolean jj_3R_18() { if (jj_scan_token(25)) return true; Token xsp; while (true) { @@ -418,7 +419,7 @@ return false; } - final private boolean jj_3_5() { + private boolean jj_3_5() { if (jj_scan_token(IDENTIFIER)) return true; if (jj_scan_token(22)) return true; if (jj_3R_14()) return true; @@ -426,7 +427,7 @@ return false; } - final private boolean jj_3R_6() { + private boolean jj_3R_6() { Token xsp; xsp = jj_scanpos; if (jj_3_5()) { @@ -448,7 +449,7 @@ return false; } - final private boolean jj_3_9() { + private boolean jj_3_9() { if (jj_scan_token(25)) return true; if (jj_3R_9()) return true; if (jj_scan_token(27)) return true; @@ -457,19 +458,19 @@ return false; } - final private boolean jj_3_8() { + private boolean jj_3_8() { if (jj_scan_token(25)) return true; if (jj_3R_9()) return true; if (jj_scan_token(26)) return true; return false; } - final private boolean jj_3R_17() { + private boolean jj_3R_17() { if (jj_scan_token(24)) return true; return false; } - final private boolean jj_3R_15() { + private boolean jj_3R_15() { Token xsp; xsp = jj_scanpos; if (jj_3R_17()) { @@ -485,31 +486,31 @@ return false; } - final private boolean jj_3_4() { + private boolean jj_3_4() { if (jj_3R_6()) return true; return false; } - final private boolean jj_3R_16() { + private boolean jj_3R_16() { if (jj_scan_token(21)) return true; if (jj_3R_9()) return true; return false; } - final private boolean jj_3_3() { + private boolean jj_3_3() { if (jj_3R_6()) return true; if (jj_3R_8()) return true; return false; } - final private boolean jj_3_2() { + private boolean jj_3_2() { if (jj_3R_6()) return true; if (jj_3R_7()) return true; if (jj_3R_6()) return true; return false; } - final private boolean jj_3R_14() { + private boolean jj_3R_14() { if (jj_3R_9()) return true; Token xsp; while (true) { @@ -519,13 +520,13 @@ return false; } - final private boolean jj_3_1() { + private boolean jj_3_1() { if (jj_3R_5()) return true; if (jj_3R_6()) return true; return false; } - final private boolean jj_3R_9() { + private boolean jj_3R_9() { Token xsp; xsp = jj_scanpos; if (jj_3_1()) { @@ -541,40 +542,44 @@ return false; } - final private boolean jj_3R_8() { + private boolean jj_3R_8() { if (jj_scan_token(OPERATOR)) return true; return false; } - final private boolean jj_3R_7() { + private boolean jj_3R_7() { if (jj_scan_token(OPERATOR)) return true; return false; } + /** Generated Token Manager. */ public PrologParserTokenManager token_source; SimpleCharStream jj_input_stream; - public Token token, jj_nt; + /** Current token. */ + public Token token; + /** Next token. */ + public Token jj_nt; private int jj_ntk; private Token jj_scanpos, jj_lastpos; private int jj_la; - public boolean lookingAhead = false; - private boolean jj_semLA; private int jj_gen; final private int[] jj_la1 = new int[9]; static private int[] jj_la1_0; static { - jj_la1_0(); + jj_la1_init_0(); } - private static void jj_la1_0() { + private static void jj_la1_init_0() { jj_la1_0 = new int[] {0x2000,0x80000,0x200000,0x400000,0x2080,0x3001900,0x200000,0x1000000,0x2000000,}; } final private JJCalls[] jj_2_rtns = new JJCalls[9]; private boolean jj_rescan = false; private int jj_gc = 0; + /** Constructor with InputStream. */ public PrologParser(java.io.InputStream stream) { this(stream, null); } + /** Constructor with InputStream and supplied encoding */ public PrologParser(java.io.InputStream stream, String encoding) { try { jj_input_stream = new SimpleCharStream(stream, encoding, 1, 1); } catch(java.io.UnsupportedEncodingException e) { throw new RuntimeException(e); } token_source = new PrologParserTokenManager(jj_input_stream); @@ -585,9 +590,11 @@ for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); } + /** Reinitialise. */ public void ReInit(java.io.InputStream stream) { ReInit(stream, null); } + /** Reinitialise. */ public void ReInit(java.io.InputStream stream, String encoding) { try { jj_input_stream.ReInit(stream, encoding, 1, 1); } catch(java.io.UnsupportedEncodingException e) { throw new RuntimeException(e); } token_source.ReInit(jj_input_stream); @@ -598,6 +605,7 @@ for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); } + /** Constructor. */ public PrologParser(java.io.Reader stream) { jj_input_stream = new SimpleCharStream(stream, 1, 1); token_source = new PrologParserTokenManager(jj_input_stream); @@ -608,6 +616,7 @@ for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); } + /** Reinitialise. */ public void ReInit(java.io.Reader stream) { jj_input_stream.ReInit(stream, 1, 1); token_source.ReInit(jj_input_stream); @@ -618,6 +627,7 @@ for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); } + /** Constructor with generated Token Manager. */ public PrologParser(PrologParserTokenManager tm) { token_source = tm; token = new Token(); @@ -627,6 +637,7 @@ for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); } + /** Reinitialise. */ public void ReInit(PrologParserTokenManager tm) { token_source = tm; token = new Token(); @@ -636,7 +647,7 @@ for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); } - final private Token jj_consume_token(int kind) throws ParseException { + private Token jj_consume_token(int kind) throws ParseException { Token oldToken; if ((oldToken = token).next != null) token = token.next; else token = token.next = token_source.getNextToken(); @@ -662,7 +673,7 @@ static private final class LookaheadSuccess extends java.lang.Error { } final private LookaheadSuccess jj_ls = new LookaheadSuccess(); - final private boolean jj_scan_token(int kind) { + private boolean jj_scan_token(int kind) { if (jj_scanpos == jj_lastpos) { jj_la--; if (jj_scanpos.next == null) { @@ -683,6 +694,8 @@ return false; } + +/** Get the next Token. */ final public Token getNextToken() { if (token.next != null) token = token.next; else token = token.next = token_source.getNextToken(); @@ -691,8 +704,9 @@ return token; } +/** Get the specific Token. */ final public Token getToken(int index) { - Token t = lookingAhead ? jj_scanpos : token; + Token t = token; for (int i = 0; i < index; i++) { if (t.next != null) t = t.next; else t = t.next = token_source.getNextToken(); @@ -700,14 +714,14 @@ return t; } - final private int jj_ntk() { + private int jj_ntk() { if ((jj_nt=token.next) == null) return (jj_ntk = (token.next=token_source.getNextToken()).kind); else return (jj_ntk = jj_nt.kind); } - private java.util.Vector<int[]> jj_expentries = new java.util.Vector<int[]>(); + private java.util.List<int[]> jj_expentries = new java.util.ArrayList<int[]>(); private int[] jj_expentry; private int jj_kind = -1; private int[] jj_lasttokens = new int[100]; @@ -722,27 +736,25 @@ for (int i = 0; i < jj_endpos; i++) { jj_expentry[i] = jj_lasttokens[i]; } - boolean exists = false; - for (java.util.Enumeration e = jj_expentries.elements(); e.hasMoreElements();) { - int[] oldentry = (int[])(e.nextElement()); + jj_entries_loop: for (java.util.Iterator it = jj_expentries.iterator(); it.hasNext();) { + int[] oldentry = (int[])(it.next()); if (oldentry.length == jj_expentry.length) { - exists = true; for (int i = 0; i < jj_expentry.length; i++) { if (oldentry[i] != jj_expentry[i]) { - exists = false; - break; + continue jj_entries_loop; } } - if (exists) break; + jj_expentries.add(jj_expentry); + break jj_entries_loop; } } - if (!exists) jj_expentries.addElement(jj_expentry); if (pos != 0) jj_lasttokens[(jj_endpos = pos) - 1] = kind; } } + /** Generate ParseException. */ public ParseException generateParseException() { - jj_expentries.removeAllElements(); + jj_expentries.clear(); boolean[] la1tokens = new boolean[28]; if (jj_kind >= 0) { la1tokens[jj_kind] = true; @@ -761,7 +773,7 @@ if (la1tokens[i]) { jj_expentry = new int[1]; jj_expentry[0] = i; - jj_expentries.addElement(jj_expentry); + jj_expentries.add(jj_expentry); } } jj_endpos = 0; @@ -769,18 +781,20 @@ jj_add_error_token(0, 0); int[][] exptokseq = new int[jj_expentries.size()][]; for (int i = 0; i < jj_expentries.size(); i++) { - exptokseq[i] = jj_expentries.elementAt(i); + exptokseq[i] = jj_expentries.get(i); } return new ParseException(token, exptokseq, tokenImage); } + /** Enable tracing. */ final public void enable_tracing() { } + /** Disable tracing. */ final public void disable_tracing() { } - final private void jj_rescan_token() { + private void jj_rescan_token() { jj_rescan = true; for (int i = 0; i < 9; i++) { try { @@ -807,7 +821,7 @@ jj_rescan = false; } - final private void jj_save(int index, int xla) { + private void jj_save(int index, int xla) { JJCalls p = jj_2_rtns[index]; while (p.gen > jj_gen) { if (p.next == null) { p = p.next = new JJCalls(); break; } Modified: trunk/src/dl-learner/org/dllearner/parser/PrologParserConstants.java =================================================================== --- trunk/src/dl-learner/org/dllearner/parser/PrologParserConstants.java 2008-11-30 13:24:18 UTC (rev 1536) +++ trunk/src/dl-learner/org/dllearner/parser/PrologParserConstants.java 2008-11-30 15:09:42 UTC (rev 1537) @@ -1,25 +1,46 @@ /* Generated By:JavaCC: Do not edit this line. PrologParserConstants.java */ package org.dllearner.parser; -public @SuppressWarnings("all") interface PrologParserConstants { +/** + * Token literal values and constants. + * Generated by org.javacc.parser.OtherFilesGen#start() + */ +public interface PrologParserConstants { + + /** End of File. */ int EOF = 0; + /** RegularExpression Id. */ int SINGLE_LINE_COMMENT = 6; + /** RegularExpression Id. */ int NOT = 7; + /** RegularExpression Id. */ int DOUBLE = 8; + /** RegularExpression Id. */ int NUMBER = 9; + /** RegularExpression Id. */ int DIGIT = 10; + /** RegularExpression Id. */ int STRINGCONSTANT = 11; + /** RegularExpression Id. */ int VAR = 12; + /** RegularExpression Id. */ int IDENTIFIER = 13; + /** RegularExpression Id. */ int OPERATOR = 14; + /** RegularExpression Id. */ int ANYCHAR = 15; + /** RegularExpression Id. */ int LOCASE = 16; + /** RegularExpression Id. */ int HICASE = 17; + /** RegularExpression Id. */ int SPECIALCHAR... [truncated message content] |