From: <seb...@us...> - 2012-04-13 08:30:53
|
Revision: 3635 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=3635&view=rev Author: sebastianwtr Date: 2012-04-13 08:30:41 +0000 (Fri, 13 Apr 2012) Log Message: ----------- [tbsl exploration] startet with DebugOutputs Modified Paths: -------------- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/Index/Index_utils.java trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/Sparql/Elements.java trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/Sparql/TemplateBuilder.java trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/Utils/LinearSort.java trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/exploration_main/MainInterface.java trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/exploration_main/exploration_main.java trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/modules/IterationModule.java trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/modules/WordnetModule.java Added Paths: ----------- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/Utils/DebugMode.java trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/exploration_main/Setting.java Modified: trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/Index/Index_utils.java =================================================================== --- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/Index/Index_utils.java 2012-04-11 15:07:53 UTC (rev 3634) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/Index/Index_utils.java 2012-04-13 08:30:41 UTC (rev 3635) @@ -5,7 +5,10 @@ import java.util.HashMap; import java.util.Map; +import org.dllearner.algorithm.tbsl.exploration.Utils.DebugMode; +import org.dllearner.algorithm.tbsl.exploration.exploration_main.Setting; + public class Index_utils { /** @@ -78,15 +81,13 @@ } - return result_List; } public static ArrayList<String> searchIndexForProperty(String string, SQLiteIndex myindex) throws SQLException{ HashMap<String,Float> hm = new HashMap<String,Float>(); - System.err.println("########"); - System.err.println("In search Index for Property"); + if(Setting.isDebugModus())DebugMode.debugPrint("######\n In search Index for Property"); // adding or set elements in Map by put method key and value pair /* @@ -102,19 +103,20 @@ String result=null; ArrayList<String> result_List = new ArrayList<String>(); result=myindex.getPropertyURI(string.toLowerCase()); - System.err.println("Result: "+result); + if(Setting.isDebugModus())DebugMode.debugPrint("Result: "+result); if(result!=null){ result_List.add(result); hm.put(result, 1.0f); - System.err.println("Found uri for: "+string.toLowerCase()); + if(Setting.isDebugModus())DebugMode.debugPrint("Found uri for: "+string.toLowerCase()); } else{ - System.err.println("Didnt find uri for: "+string.toLowerCase()); + if(Setting.isDebugModus())DebugMode.debugErrorPrint("Didnt find uri for: "+string.toLowerCase()); + result_List.add("http://dbpedia.org/ontology/"+string.toLowerCase().replace(" ", "_")); hm.put(result, 0.0f); } - System.err.println("########"); + if(Setting.isDebugModus())DebugMode.debugPrint("######\n"); return result_List; Modified: trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/Sparql/Elements.java =================================================================== --- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/Sparql/Elements.java 2012-04-11 15:07:53 UTC (rev 3634) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/Sparql/Elements.java 2012-04-13 08:30:41 UTC (rev 3635) @@ -3,7 +3,9 @@ import java.io.IOException; import java.util.ArrayList; +import org.dllearner.algorithm.tbsl.exploration.Utils.DebugMode; import org.dllearner.algorithm.tbsl.exploration.Utils.ServerUtil; +import org.dllearner.algorithm.tbsl.exploration.exploration_main.Setting; /** * Creates Set of Classes and Resources with their properties @@ -48,7 +50,7 @@ e.printStackTrace(); } - System.out.println("Created Elements"); + if(Setting.isDebugModus())DebugMode.debugPrint("Created Elements"); } private void createElementsOfClasses(ArrayList<ArrayList<Hypothesis>> hypothesenList) throws IOException{ @@ -65,7 +67,7 @@ /* * TODO: improver performance, using geschicktes zwischenspeichern */ - System.out.println("Class Name: "+h.getName()+" Uri: "+h.getUri()); + if(Setting.isDebugModus())DebugMode.debugPrint("Create Elements for Class: "+h.getName()+" Uri: "+h.getUri()); ElementList el = new ElementList(h.getName(),h.getUri(),ServerUtil.getElementsForGivenClass(h.getUri())); //classes.add(el); this.addElements(el); @@ -84,7 +86,7 @@ for(ArrayList<Hypothesis> hl : hypothesenList){ for(Hypothesis h : hl){ if(h.getType().contains("RESOURCE")&&h.getUri().contains("http")){ - System.out.println("Resource Name: "+h.getName()+" Uri: "+h.getUri()); + if(Setting.isDebugModus())DebugMode.debugPrint("Create Elements for Resource: "+h.getName()+" Uri: "+h.getUri()); for(ArrayList<String> cl : conditionList){ if(h.getVariable().equals(cl.get(0))) { Modified: trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/Sparql/TemplateBuilder.java =================================================================== --- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/Sparql/TemplateBuilder.java 2012-04-11 15:07:53 UTC (rev 3634) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/Sparql/TemplateBuilder.java 2012-04-13 08:30:41 UTC (rev 3635) @@ -17,6 +17,8 @@ import org.dllearner.algorithm.tbsl.exploration.Index.SQLiteIndex; import org.dllearner.algorithm.tbsl.exploration.Index.Index_utils; +import org.dllearner.algorithm.tbsl.exploration.Utils.DebugMode; +import org.dllearner.algorithm.tbsl.exploration.exploration_main.Setting; import org.dllearner.algorithm.tbsl.sparql.BasicQueryTemplate; import org.dllearner.algorithm.tbsl.sparql.Path; import org.dllearner.algorithm.tbsl.sparql.SPARQL_Filter; @@ -49,33 +51,38 @@ /* * check if templates were build, if not, safe the question and delete it for next time from the xml file. + * Only in Debug Mode */ - if(querytemps.contains("could not be parsed") || querytemps.isEmpty()){ - String dateiname="/home/swalter/Dokumente/Auswertung/NotParsed.txt"; - String result_string =""; - //Open the file for reading - try { - BufferedReader br = new BufferedReader(new FileReader(dateiname)); - String thisLine; - while ((thisLine = br.readLine()) != null) { // while loop begins here - result_string+=thisLine+"\n"; - } // end while - } // end try - catch (IOException e) { - System.err.println("Error: " + e); - } - - File file = new File(dateiname); - BufferedWriter bw = new BufferedWriter(new FileWriter(file)); + if(Setting.isDebugModus()){ + if(querytemps.contains("could not be parsed") || querytemps.isEmpty()){ + String dateiname="/home/swalter/Dokumente/Auswertung/NotParsed.txt"; + String result_string =""; + //Open the file for reading + try { + BufferedReader br = new BufferedReader(new FileReader(dateiname)); + String thisLine; + while ((thisLine = br.readLine()) != null) { // while loop begins here + result_string+=thisLine+"\n"; + } // end while + } // end try + catch (IOException e) { + System.err.println("Error: " + e); + } + + File file = new File(dateiname); + BufferedWriter bw = new BufferedWriter(new FileWriter(file)); - bw.write(result_string+"\n"+question); - bw.flush(); - bw.close(); - - + bw.write(result_string+"\n"+question); + bw.flush(); + bw.close(); + + + } } + long stop_template = System.currentTimeMillis(); + if(Setting.isDebugModus())DebugMode.waitForButton(); for (BasicQueryTemplate bqt : querytemps) { long start_part1= System.currentTimeMillis(); @@ -172,7 +179,7 @@ for(String s : al){ con_temp+=" " + s; } - System.out.println("Condition: "+con_temp); + if(Setting.isDebugModus())DebugMode.debugPrint("Condition: "+con_temp); } template.setTime_part1(stop_part1-start_part1); @@ -225,15 +232,12 @@ } } ArrayList<ArrayList<Hypothesis>> final_list_set_hypothesis = new ArrayList<ArrayList<Hypothesis>>(); - //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - /* System.out.println("Alle Hypothesen VOR der Verarbeitung"); + if(Setting.isDebugModus())DebugMode.printHypothesen(list_of_hypothesis,"Alle Hypothesen VOR der Verarbeitung"); + + for(Hypothesis x : list_of_hypothesis){ - x.printAll(); - } - System.out.println("Alle Hypothesen VOR der Verarbeitung - Done \n\n"); - */ - for(Hypothesis x : list_of_hypothesis){ /* * TODO: Change if ISA only ask classes, else resource */ @@ -279,14 +283,9 @@ } } - /* System.out.println("Alle Hypothesen nach der ERSTEN Verarbeitung"); - for(ArrayList<Hypothesis> lh : final_list_set_hypothesis){ - for(Hypothesis x : lh){ - x.printAll(); - } - } - System.out.println("Alle Hypothesen nach der ERSTEN Verarbeitung - Done \n\n"); - */ + + if(Setting.isDebugModus())DebugMode.printHypothesenSet(final_list_set_hypothesis,"Alle Hypothesen nach der ERSTEN Verarbeitung"); + //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /* @@ -356,17 +355,8 @@ } } - /*System.out.println("Alle Hypothesen nach der ZWEITEN Verarbeitung"); - for(ArrayList<Hypothesis> lh : final_list_set_hypothesis){ - for(Hypothesis x : lh){ - x.printAll(); - } - } + if(Setting.isDebugModus())DebugMode.printHypothesenSet(final_list_set_hypothesis,"Alle Hypothesen nach der ZWEITEN Verarbeitung"); - System.out.println("Alle Hypothesen nach der ZWEITEN Verarbeitung - Done \n\n"); - */ - - template.setHypothesen(final_list_set_hypothesis); @@ -430,12 +420,10 @@ } } - /*System.out.println("Nach allen Verarbeitungsschritten:"); - for(Template temp : resultArrayList){ - temp.printAll(); - } - System.out.println("Nach allen Verarbeitungsschritten - DONE");*/ + if(Setting.isDebugModus())DebugMode.printTemplateList(resultArrayList, "Templates nach allen Verarbeitungsschritten"); + + return resultArrayList; } } Added: trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/Utils/DebugMode.java =================================================================== --- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/Utils/DebugMode.java (rev 0) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/Utils/DebugMode.java 2012-04-13 08:30:41 UTC (rev 3635) @@ -0,0 +1,99 @@ +package org.dllearner.algorithm.tbsl.exploration.Utils; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.ArrayList; + +import org.dllearner.algorithm.tbsl.exploration.Sparql.Hypothesis; +import org.dllearner.algorithm.tbsl.exploration.Sparql.Template; + +public class DebugMode { + + public static void waitForButton() throws IOException { + BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); + String line; + System.out.println("\n\n"); + System.out.println("Press Any Key to continue"); + line = in.readLine(); + } + + + public static void printHypothesen(ArrayList<Hypothesis> list_of_hypothesis, String string){ + System.out.println(string); + for(Hypothesis x : list_of_hypothesis){ + x.printAll(); + } + System.out.println(string +" Done \n\n"); + try { + waitForButton(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + + public static void printHypothesenSet(ArrayList<ArrayList<Hypothesis>> set_hypothesis, String string){ + System.out.println(string); + for(ArrayList<Hypothesis> lh : set_hypothesis){ + for(Hypothesis x : lh){ + x.printAll(); + } + } + System.out.println(string +" Done \n\n"); + try { + waitForButton(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + + public static void printTemplateList(ArrayList<Template> templateList, String string){ + System.out.println(string); + for(Template t : templateList) t.printAll(); + System.out.println(string +" Done \n\n"); + try { + waitForButton(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + + public static void debugPrint(String string){ + System.out.println(string); + } + + public static void debugErrorPrint(String string){ + System.err.println(string); + try { + waitForButton(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + public static void printQueryPair(ArrayList<QueryPair> qp){ + System.out.println("All constructed Queries with Rank"); + for(QueryPair p : qp){ + p.printAll(); + } + + try { + waitForButton(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + + + + +} Modified: trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/Utils/LinearSort.java =================================================================== --- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/Utils/LinearSort.java 2012-04-11 15:07:53 UTC (rev 3634) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/Utils/LinearSort.java 2012-04-13 08:30:41 UTC (rev 3635) @@ -2,6 +2,8 @@ import java.util.ArrayList; +import org.dllearner.algorithm.tbsl.exploration.exploration_main.Setting; + public class LinearSort { public static void doSort(ArrayList<QueryPair> qp){ @@ -20,9 +22,7 @@ } } - /*for(QueryPair p : qp){ - p.printAll(); - }*/ + if(Setting.isDebugModus())DebugMode.printQueryPair(qp); } Modified: trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/exploration_main/MainInterface.java =================================================================== --- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/exploration_main/MainInterface.java 2012-04-11 15:07:53 UTC (rev 3634) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/exploration_main/MainInterface.java 2012-04-13 08:30:41 UTC (rev 3635) @@ -11,6 +11,7 @@ import org.dllearner.algorithm.tbsl.exploration.Sparql.Hypothesis; import org.dllearner.algorithm.tbsl.exploration.Sparql.Template; import org.dllearner.algorithm.tbsl.exploration.Sparql.TemplateBuilder; +import org.dllearner.algorithm.tbsl.exploration.Utils.DebugMode; import org.dllearner.algorithm.tbsl.exploration.Utils.LinearSort; import org.dllearner.algorithm.tbsl.exploration.Utils.Query; import org.dllearner.algorithm.tbsl.exploration.Utils.QueryPair; @@ -26,6 +27,14 @@ public static ArrayList<String> startQuestioning(String question,BasicTemplator btemplator,SQLiteIndex myindex, WordNet wordnet,StanfordLemmatizer lemmatiser) throws ClassNotFoundException, SQLException, IOException{ + /* + * true, if you have to push a button to get to the next module + * false, goes through all + */ + boolean wait = false; + + if(Setting.isWaitModus())wait=true; + TemplateBuilder templateObject = new TemplateBuilder(btemplator, myindex); ArrayList<Template> template_list = new ArrayList<Template>(); @@ -69,20 +78,35 @@ for(QueryPair q : qp){ if(anzahl<anzahlAbgeschickterQueries&go_on){ ArrayList<String> answer_tmp = new ArrayList<String>(); - System.out.println(q.getQuery()); + System.out.println("Sending Query to Server: "+q.getQuery()); answer_tmp=ServerUtil.requestAnswerFromServer(q.getQuery()); if(answer_tmp.isEmpty()) go_on=true; else{ - //else go_on=false; - go_on=true; + go_on=false; + System.out.println("Got Answer from Server with this Query: "+ q.getQuery()); + //go_on=true; + boolean contains_uri=false; for(String s : answer_tmp){ + if(s.contains("http")){ + contains_uri=true; + break; + } + } + for(String s : answer_tmp){ if(checkAnswer(s)){ - boolean test = false; + boolean double_result = false; for(String s_t : answers){ - if(s_t.contains(s)) test=true; + if(s_t.contains(s)) double_result=true; } - if(!test)answers.add(s); + //TODO Test!!!!!! + //if in one answer is an http, only add uri's + if(!double_result){ + if(contains_uri){ + if(s.contains("http"))answers.add(s); + } + else answers.add(s); + } } } //if(checkAnswer(answer_tmp))answers.addAll(answer_tmp); @@ -91,14 +115,11 @@ anzahl+=1; } + System.out.println("\n Answer from Server: \n"); for(String answer:answers){ System.out.println(answer); } - BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); - String line; - System.out.println("\n\n"); - System.out.println("Press Any Key to continue"); - line = in.readLine(); + if(wait)DebugMode.waitForButton(); /* @@ -108,9 +129,7 @@ answers.clear(); answers.addAll(doStart(myindex, wordnet, lemmatiser, template_list,"LEVENSTHEIN")); - System.out.println("\n\n"); - System.out.println("Press Any Key to continue"); - line = in.readLine(); + if(wait)DebugMode.waitForButton(); } /* @@ -121,17 +140,15 @@ answers.clear(); answers.addAll(doStart(myindex, wordnet, lemmatiser, template_list,"WORDNET")); - System.out.println("\n\n"); - System.out.println("Press Any Key to continue"); - line = in.readLine(); + if(wait)DebugMode.waitForButton(); } - /*if(answers.isEmpty()){ - System.out.println("No answers were found with the three Modules"); + if(answers.isEmpty()){ + System.out.println(""); //answers.add("No answers were found with the three Modules"); - }*/ + } /* @@ -142,9 +159,16 @@ } + + + + + + + private static ArrayList<String> doStart(SQLiteIndex myindex, WordNet wordnet, StanfordLemmatizer lemmatiser, ArrayList<Template> template_list, String type) { @@ -193,20 +217,35 @@ if(anzahl<anzahlAbgeschickterQueries&go_on){ ArrayList<String> answer_tmp = new ArrayList<String>(); answer_tmp=ServerUtil.requestAnswerFromServer(q.getQuery()); - System.out.println(q.getQuery() + " Rank: "+q.getRank()); + System.out.println("Sending Query to Server: "+q.getQuery()); if(answer_tmp.isEmpty()) go_on=true; else{ //else go_on=false; - go_on=true; - //go_on=false; + //go_on=true; + go_on=false; + System.out.println("Got Answer from Server with this Query: "+ q.getQuery()); + boolean contains_uri=false; for(String s : answer_tmp){ + if(s.contains("http")){ + contains_uri=true; + break; + } + } + for(String s : answer_tmp){ if(checkAnswer(s)){ - boolean test = false; + boolean double_result = false; for(String s_t : answers){ - if(s_t.contains(s)) test=true; + if(s_t.contains(s)) double_result=true; } - if(!test)answers.add(s); + //TODO Test!!!!!! + //if in one answer is an http, only add uri's + if(!double_result){ + if(contains_uri){ + if(s.contains("http"))answers.add(s); + } + else answers.add(s); + } } } //if(checkAnswer(answer_tmp))answers.addAll(answer_tmp); @@ -214,6 +253,7 @@ } anzahl+=1; } + System.out.println("\n Answer from Server: \n"); for(String answer:answers){ System.out.println(answer); } @@ -231,7 +271,7 @@ } private static boolean checkQuery(String query){ - if(query.contains("wikiPageWiki")||query.contains("wikiPageExternal")||query.contains("wikiPageRedirects")|| query.contains("thumbnail")) return false; + if(query.contains("wikiPageWiki")||query.contains("wikiPageExternal")||query.contains("wikiPageRedirects")|| query.contains("thumbnail")||query.contains("wikiPage")) return false; else return true; } Added: trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/exploration_main/Setting.java =================================================================== --- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/exploration_main/Setting.java (rev 0) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/exploration_main/Setting.java 2012-04-13 08:30:41 UTC (rev 3635) @@ -0,0 +1,21 @@ +package org.dllearner.algorithm.tbsl.exploration.exploration_main; + +public class Setting { + + private static boolean waitModus; + private static boolean debugModus; + public static boolean isWaitModus() { + return waitModus; + } + public static void setWaitModus(boolean waitModus) { + Setting.waitModus = waitModus; + } + public static boolean isDebugModus() { + return debugModus; + } + public static void setDebugModus(boolean debugModus) { + Setting.debugModus = debugModus; + } + + +} Modified: trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/exploration_main/exploration_main.java =================================================================== --- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/exploration_main/exploration_main.java 2012-04-11 15:07:53 UTC (rev 3634) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/exploration_main/exploration_main.java 2012-04-13 08:30:41 UTC (rev 3635) @@ -40,7 +40,6 @@ public class exploration_main { - /** * @param args @@ -59,21 +58,26 @@ * Initial Index and Templator */ BasicTemplator btemplator = new BasicTemplator(); - //btemplator.UNTAGGED_INPUT = false; + btemplator.UNTAGGED_INPUT = false; + SQLiteIndex myindex = new SQLiteIndex(); WordNet wordnet = new WordNet(); StanfordLemmatizer lemmatiser = new StanfordLemmatizer(); long stopInitTime = System.currentTimeMillis(); + + Setting.setWaitModus(false); + Setting.setDebugModus(false); + System.out.println("Time for Initialising "+(stopInitTime-startInitTime)+" ms"); boolean schleife=true; - boolean doing = true; + boolean startQuestioning = true; while(schleife==true){ BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); String line; - doing = true; + startQuestioning = true; try { System.out.println("\n\n"); System.out.println("Please enter a Question:"); @@ -83,6 +87,33 @@ System.out.println("Bye!"); System.exit(0); } + + if(line.contains(":wait on")){ + Setting.setWaitModus(true); + startQuestioning=false; + if(Setting.isWaitModus()) System.out.println("WaitModus is now online"); + else System.out.println("Wait Modus is now offline"); + } + if(line.contains(":wait off")){ + Setting.setWaitModus(false); + startQuestioning=false; + if(Setting.isWaitModus()) System.out.println("WaitModus is now online"); + else System.out.println("Wait Modus is now offline"); + } + if(line.contains(":debug on")){ + Setting.setDebugModus(true); + startQuestioning=false; + if(Setting.isDebugModus()) System.out.println("DebugModus is now online"); + else System.out.println("DebugModus is now offline"); + } + if(line.contains(":debug off")){ + Setting.setDebugModus(false); + startQuestioning=false; + if(Setting.isDebugModus()) System.out.println("DebugModus is now online"); + else System.out.println("DebugModus is now offline"); + } + + if(line.contains(":xml")&& schleife==true){ TimeZone.setDefault(TimeZone.getTimeZone("GMT")); @@ -90,12 +121,14 @@ /*System.out.println("Please enter Path of xml File:"); line=in.readLine();*/ - line="/home/swalter/Dokumente/Auswertung/XMLDateien/dbpedia-train.xml"; - line="/home/swalter/Dokumente/Auswertung/XMLDateien/dbpedia-train-withoutnonparsed.xml"; + //line="/home/swalter/Dokumente/Auswertung/XMLDateien/dbpedia-train.xml"; + //line="/home/swalter/Dokumente/Auswertung/XMLDateien/dbpedia-train-withoutnonparsed.xml"; //line="/home/swalter/Dokumente/Auswertung/XMLDateien/very_small.xml"; //line="/home/swalter/Dokumente/Auswertung/XMLDateien/berlin.xml"; //line="/home/swalter/Dokumente/Auswertung/XMLDateien/vortragfragen.xml"; //line="/home/swalter/Dokumente/Auswertung/XMLDateien/iteration-test.xml"; + line="/home/swalter/Dokumente/Auswertung/XMLDateien/dbpedia-train-tagged.xml"; + line="/home/swalter/Dokumente/Auswertung/XMLDateien/dbpedia-train-tagged-withoutNotparsed.xml"; //create Structs ArrayList<queryInformation> list_of_structs = new ArrayList<queryInformation>(); @@ -145,7 +178,7 @@ } - else if(schleife==true && doing ==true){ + else if(schleife==true && startQuestioning ==true){ long startTime = System.currentTimeMillis(); queryInformation result = new queryInformation(line,"0","",false,false,false,"non",false); MainInterface.startQuestioning(line,btemplator,myindex,wordnet,lemmatiser); @@ -241,7 +274,8 @@ int counter=0; System.out.println("Anzahl queryInformations: "+list.size()); for (queryInformation s : list){ - if(!s.getResult().isEmpty()){ + //why doing this? try that it doesnt matter if there is an answer or not.... + //if(!s.getResult().isEmpty()){ String tmp; if(counter==0){ counter=counter+1; @@ -266,7 +300,7 @@ } tmp+="</answers></question>\n"; xmlDocument+=tmp; - } + //} } xmlDocument+="</dataset>"; Modified: trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/modules/IterationModule.java =================================================================== --- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/modules/IterationModule.java 2012-04-11 15:07:53 UTC (rev 3634) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/modules/IterationModule.java 2012-04-13 08:30:41 UTC (rev 3635) @@ -9,6 +9,8 @@ import org.dllearner.algorithm.tbsl.exploration.Sparql.ElementList; import org.dllearner.algorithm.tbsl.exploration.Sparql.Elements; import org.dllearner.algorithm.tbsl.exploration.Sparql.Hypothesis; +import org.dllearner.algorithm.tbsl.exploration.Utils.DebugMode; +import org.dllearner.algorithm.tbsl.exploration.exploration_main.Setting; import org.dllearner.algorithm.tbsl.nlp.StanfordLemmatizer; import org.dllearner.algorithm.tbsl.nlp.WordNet; @@ -37,7 +39,7 @@ } catch (Exception e){ gotResource=false; - System.out.println("Didnt get any Resource"); + if(Setting.isDebugModus())DebugMode.debugErrorPrint("Didnt get any Resource"); } //System.out.println("Anzahl der Resource Listen: "+resources.size()); @@ -81,7 +83,7 @@ String variable = h.getVariable(); String name = h.getName(); RL.add(h); - System.out.println("Found Resource"); + if(Setting.isDebugModus())DebugMode.debugPrint("Found Resource "+h.getName() +" "+h.getUri()); /* @@ -121,11 +123,6 @@ for(String s : propertyNameList){ String[] array = s.split("::"); - System.out.println("String: "+s); - /*System.out.println("Array:"); - for(String t : array){ - System.out.println(t); - }*/ /* * array[0] contains name of Property @@ -173,7 +170,7 @@ * TODO:Add special case, if we have only one condition but with an isA in it. */ RL.add(h); - System.out.println("Found Class"); + if(Setting.isDebugModus())DebugMode.debugPrint("Found Class "+h.getName() +" "+h.getUri()); for(ElementList el:resources){ /* Modified: trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/modules/WordnetModule.java =================================================================== --- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/modules/WordnetModule.java 2012-04-11 15:07:53 UTC (rev 3634) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/modules/WordnetModule.java 2012-04-13 08:30:41 UTC (rev 3635) @@ -95,9 +95,16 @@ if(key.contains(b.toLowerCase())||key.contains(lemmatiser.stem(b.toLowerCase()))||b.toLowerCase().contains(lemmatiser.stem(key))){ if(!result_SemanticsMatchProperties.contains(key)){ result_SemanticsMatchProperties.add(key); - double nld=Levenshtein.nld(property_to_compare_with.toLowerCase(), key); - Hypothesis h = new Hypothesis(variable, key, value, "PROPERTY", nld); - listOfNewHypothesen.add(h); + if(key.toLowerCase().contains(property_to_compare_with.toLowerCase())){ + Hypothesis h = new Hypothesis(variable, key, value, "PROPERTY", 1.5); + listOfNewHypothesen.add(h); + } + else{ + double nld=Levenshtein.nld(property_to_compare_with.toLowerCase(), key); + Hypothesis h = new Hypothesis(variable, key, value, "PROPERTY", nld); + listOfNewHypothesen.add(h); + } + } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |