From: <seb...@us...> - 2012-04-20 14:41:02
|
Revision: 3650 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=3650&view=rev Author: sebastianwtr Date: 2012-04-20 14:40:53 +0000 (Fri, 20 Apr 2012) Log Message: ----------- [tbsl exploration] improved settings 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/TemplateBuilder.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/LevenstheinModule.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-20 09:07:54 UTC (rev 3649) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/Index/Index_utils.java 2012-04-20 14:40:53 UTC (rev 3650) @@ -101,10 +101,17 @@ string=string.replace("-", " "); string=string.replace(".", " "); String result=null; + String result2 = null; ArrayList<String> result_List = new ArrayList<String>(); result=myindex.getPropertyURI(string.toLowerCase()); + result2=myindex.getontologyURI(string.toLowerCase()); if(Setting.isDebugModus())DebugMode.debugPrint("Result: "+result); - if(result!=null){ + if(result2!=null){ + result_List.add(result2); + hm.put(result, 1.0f); + if(Setting.isDebugModus())DebugMode.debugPrint("Found uri for: "+string.toLowerCase()); + } + else if(result!=null){ result_List.add(result); hm.put(result, 1.0f); if(Setting.isDebugModus())DebugMode.debugPrint("Found uri for: "+string.toLowerCase()); @@ -173,6 +180,38 @@ } + /* + * also add String without the plural s at the end. + */ + if(string.substring(string.length()-1).contains("s")){ + String neuer_string = string.substring(0, string.length() -1); + tmp1=myindex.getontologyClassURI(neuer_string.toLowerCase()); + tmp2=myindex.getYagoURI(neuer_string.toLowerCase()); + if(tmp1!=null){ + result_List.add(tmp1); + } + if(tmp2!=null){ + result_List.add(tmp1); + } + } + + if(string.length()>3){ + if(string.substring(string.length()-3).contains("ies")){ + String neuer_string = string.substring(0, string.length() -3); + neuer_string+="y"; + tmp1=myindex.getontologyClassURI(neuer_string.toLowerCase()); + tmp2=myindex.getYagoURI(neuer_string.toLowerCase()); + if(tmp1!=null){ + result_List.add(tmp1); + } + if(tmp2!=null){ + result_List.add(tmp1); + } + + } + } + + return result_List; 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-20 09:07:54 UTC (rev 3649) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/Sparql/TemplateBuilder.java 2012-04-20 14:40:53 UTC (rev 3650) @@ -48,12 +48,13 @@ ArrayList<Template> resultArrayList = new ArrayList<Template>(); Set<BasicQueryTemplate> querytemps =null; querytemps = btemplator.buildBasicQueries(question); + /* * 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(Setting.isDebugModus()){ + //if(Setting.isDebugModus()){ if(querytemps.contains("could not be parsed") || querytemps.isEmpty()){ String dateiname="/home/swalter/Dokumente/Auswertung/NotParsed.txt"; String result_string =""; @@ -78,7 +79,7 @@ } - } + //} long stop_template = System.currentTimeMillis(); 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-20 09:07:54 UTC (rev 3649) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/exploration_main/MainInterface.java 2012-04-20 14:40:53 UTC (rev 3650) @@ -24,9 +24,10 @@ import org.dllearner.algorithm.tbsl.nlp.StanfordLemmatizer; import org.dllearner.algorithm.tbsl.nlp.WordNet; import org.dllearner.algorithm.tbsl.templator.BasicTemplator; +import org.dllearner.algorithms.gp.GP; public class MainInterface { - private static int anzahlAbgeschickterQueries = 100; + private static int anzahlAbgeschickterQueries = 10; public static ArrayList<String> startQuestioning(String question,BasicTemplator btemplator,SQLiteIndex myindex, WordNet wordnet,StanfordLemmatizer lemmatiser) throws ClassNotFoundException, SQLException, IOException{ @@ -93,6 +94,7 @@ else{ go_on=false; + if(qp.size()<3)go_on=true; System.out.println("Got Answer from Server with this Query: "+ q.getQuery()); //go_on=true; boolean contains_uri=false; @@ -249,6 +251,7 @@ printQueries(qp, type, Question); anzahl=1; go_on = true; + int id=0; for(QueryPair q : qp){ if(anzahl<anzahlAbgeschickterQueries&go_on){ ArrayList<String> answer_tmp = new ArrayList<String>(); @@ -261,6 +264,13 @@ //go_on=true; go_on=false; System.out.println("Got Answer from Server with this Query: "+ q.getQuery()); + if(qp.size()>(id+1)){ + if(q.getRank()==qp.get(id+1).getRank()){ + go_on=true; + } + } + + boolean contains_uri=false; for(String s : answer_tmp){ if(s.contains("http")){ @@ -288,6 +298,7 @@ } } anzahl+=1; + id+=1; } System.out.println("\n Answer from Server: \n"); for(String answer:answers){ 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-20 09:07:54 UTC (rev 3649) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/exploration_main/exploration_main.java 2012-04-20 14:40:53 UTC (rev 3650) @@ -130,7 +130,8 @@ //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"; + //line="/home/swalter/Dokumente/Auswertung/XMLDateien/dbpedia-train-tagged-withoutNotparsed.xml"; + //line="/home/swalter/Dokumente/Auswertung/XMLDateien/dbpedia-test-questions.xml"; //create Structs ArrayList<queryInformation> list_of_structs = new ArrayList<queryInformation>(); @@ -161,6 +162,10 @@ for(queryInformation s : list_of_resultstructs){ System.out.println(s.getResult()); }*/ + + long stopTime = System.currentTimeMillis(); + System.out.println("For "+anzahl+" Questions the QA_System took "+ ((stopTime-startTime)/1000)+"sek"); + String systemid=""; systemid=createXML(list_of_structs); String filename_for_evaluation="/home/swalter/Dokumente/Auswertung/ResultXml/result"+systemid.replace(" ", "_")+".xml"; Modified: trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/modules/LevenstheinModule.java =================================================================== --- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/modules/LevenstheinModule.java 2012-04-20 09:07:54 UTC (rev 3649) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/modules/LevenstheinModule.java 2012-04-20 14:40:53 UTC (rev 3650) @@ -21,14 +21,33 @@ String key = entry.getKey(); key=key.replace("\"",""); key=key.replace("@en",""); + key=key.toLowerCase(); String value = entry.getValue(); //compare property gotten from the resource with the property from the original query double nld=Levenshtein.nld(property_to_compare_with.toLowerCase(), key); //if(nld>=LevenstheinMin||key.contains(lemmatiser.stem(property_to_compare_with))||property_to_compare_with.contains(lemmatiser.stem(key))){ - - if(nld>=LevenstheinMin){ + + if(key.contains(property_to_compare_with)||property_to_compare_with.contains(key)){ + if(nld<0.8){ + Hypothesis h = new Hypothesis(variable, key, value, "PROPERTY", 0.85); + listOfNewHypothesen.add(h); + } + else{ + Hypothesis h = new Hypothesis(variable, key, value, "PROPERTY", nld); + listOfNewHypothesen.add(h); + } + + } + else if(key.substring(key.length()-1).contains("s")){ + String neuer_string = key.substring(0, key.length() -1); + if(neuer_string.contains(property_to_compare_with)||property_to_compare_with.contains(neuer_string)){ + Hypothesis h = new Hypothesis(variable, neuer_string, value, "PROPERTY", 1.5); + listOfNewHypothesen.add(h); + } + } + else if(nld>=LevenstheinMin){ 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. |