From: <seb...@us...> - 2012-02-09 16:15:38
|
Revision: 3579 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=3579&view=rev Author: sebastianwtr Date: 2012-02-09 16:15:27 +0000 (Thu, 09 Feb 2012) Log Message: ----------- [tbsl-exploration] some minor changes Modified Paths: -------------- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/Sparql/GetRessourcePropertys.java trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/Sparql/SparqlObject.java trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/Sparql/queryInformation.java trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/exploration_main/exploration_main.java Modified: trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/Sparql/GetRessourcePropertys.java =================================================================== --- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/Sparql/GetRessourcePropertys.java 2012-02-08 13:48:02 UTC (rev 3578) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/Sparql/GetRessourcePropertys.java 2012-02-09 16:15:27 UTC (rev 3579) @@ -20,7 +20,8 @@ //String Prefix="http://greententacle.techfak.uni-bielefeld.de:5171/sparql"; String Prefix="http://dbpedia.org/sparql"; - //String Prefix="http://purpurtentacle.techfak.uni-bielefeld.de:8892/sparql"; + //String Prefix="http://purpurtentacle.techfak.uni-bielefeld.de:8890/sparql"; + //String Prefix="http://greententacle.techfak.uni-bielefeld.de:5171/sparql"; public HashMap<String,String> getPropertys(String element, String side, int timeToTimeoutOnServer) throws IOException{ Modified: trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/Sparql/SparqlObject.java =================================================================== --- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/Sparql/SparqlObject.java 2012-02-08 13:48:02 UTC (rev 3578) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/Sparql/SparqlObject.java 2012-02-09 16:15:27 UTC (rev 3579) @@ -58,7 +58,7 @@ static int explorationdepthwordnet=2; static int iterationdepth =0; static int numberofanswers=1; - static double LevenstheinMin = 0.9; + static double LevenstheinMin = 0.8; static WordNet wordnet; BasicTemplator btemplator; Templator templator; @@ -71,7 +71,8 @@ //change here and in getRessourcePropertys //String Prefix="http://greententacle.techfak.uni-bielefeld.de:5171/sparql"; String Prefix="http://dbpedia.org/sparql"; - //String Prefix="http://purpurtentacle.techfak.uni-bielefeld.de:8892/sparql"; + //String Prefix="http://greententacle.techfak.uni-bielefeld.de:5171/sparql"; + //String Prefix="http://purpurtentacle.techfak.uni-bielefeld.de:8890/sparql"; //Konstruktor @@ -650,11 +651,20 @@ // TODO Auto-generated catch block e.printStackTrace(); }*/ + System.out.println(property_to_compare_with + " : "+property_to_compare_with_uri +" : "+uri_isA_Resource); if(fall.contains("WORDNET")) new_queries=doWordnet(query,property_to_compare_with,property_to_compare_with_uri,list_of_properties); if(fall.contains("LEVENSTHEIN")) new_queries=doLevensthein(query,property_to_compare_with_uri,property_to_compare_with_uri,list_of_properties); - + /* BufferedReader in1 = new BufferedReader(new InputStreamReader(System.in)); + String line; + + try { + line = in1.readLine(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + }*/ return new_queries; } @@ -703,6 +713,9 @@ //System.out.println("URI from Resource "+ resource +": "+getUriFromIndex(resource.toLowerCase(),0)); System.out.println("URI from Resource "+ resource +": "+queryObject.getHashValue(resource.toLowerCase())); + HashMap<String, String> bla = queryObject.getHashMap(); + System.out.println("INhalt Hasmap QueryObject:"); + for (String z: bla.keySet()) System.out.println(z); //gets Propertys left or right from the resource! try { @@ -756,7 +769,7 @@ double nld=Levenshtein.nld(property_to_compare_with.toLowerCase(), key); //check if nld is greater than Levensthein - if(nld>=LevenstheinMin){ + if(nld>=LevenstheinMin||key.contains(lemmatiser.stem(property_to_compare_with))||property_to_compare_with.contains(lemmatiser.stem(key))){ //if its so, replace old uri with the new one String querynew=query; //String replacement = getUriFromIndex(property_to_compare_with.toLowerCase(),1); @@ -913,19 +926,31 @@ ArrayList<String> semantics=new ArrayList<String>(); ArrayList<String> tmp_semantics=new ArrayList<String>(); ArrayList<String> result_SemanticsMatchProperties=new ArrayList<String>(); - semantics.add(property); + if(property.contains("_")){ + String[] fix = property.split("_"); + //here add also lemmatiser + for(String s: fix) semantics.add(s); + } + else semantics.add(property); System.out.println("Semantics: "+ semantics); - //first check, if there is a singular form in the wordnet dictionary.. eg children -> child - String _temp_=myindex.getWordnetHelp(property); - if(_temp_==null){ - tmp_semantics=semantics; + for(String s: semantics){ + //first check, if there is a singular form in the wordnet dictionary.. eg children -> child + //String _temp_=myindex.getWordnetHelp(property); + String _temp_=myindex.getWordnetHelp(s); + if(_temp_!=null){ + //tmp_semantics=semantics; + tmp_semantics.add(_temp_); + tmp_semantics.add(s); + } + else tmp_semantics.add(s); + /* + else{ + semantics.clear(); + semantics.add(_temp_); + tmp_semantics=semantics; + }*/ } - else{ - semantics.clear(); - semantics.add(_temp_); - tmp_semantics=semantics; - } System.out.println("tmp_semantics: "+ tmp_semantics); Boolean goOnAfterWordnet = true; @@ -965,11 +990,12 @@ key=key.replace("@en",""); for(String b : semantics){ - if(key.contains(b.toLowerCase())){ + 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); String query_tmp=query; //String replacement = getUriFromIndex(property_to_compare_with.toLowerCase(),1); + System.out.println("URI of property: "+uri_of_property); String replacement = uri_of_property; if(!query_tmp.contains(replacement)){ replacement=replacement.replace("ontology", "property"); @@ -1765,6 +1791,21 @@ } else{ result="NONE"; + String tmp11=originalString; + String hotfix ="http://dbpedia.org/resource/"+tmp11; + if(tmp11.contains("_")){ + String[] newarraytmp=tmp11.split("_"); + String tmpneu=""; + for(String s :newarraytmp){ + tmpneu+= "_"+ Character.toUpperCase(s.charAt(0)) + s.substring(1); + } + tmpneu=tmpneu.replaceFirst("_", ""); + hotfix ="http://dbpedia.org/resource/"+tmpneu; + hotfix=hotfix.replace("/__", "/"); + System.out.println("Hotfix: "+hotfix); + } + result=hotfix; + } } catch(Exception e){ Modified: trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/Sparql/queryInformation.java =================================================================== --- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/Sparql/queryInformation.java 2012-02-08 13:48:02 UTC (rev 3578) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/Sparql/queryInformation.java 2012-02-09 16:15:27 UTC (rev 3579) @@ -39,6 +39,8 @@ public String getHashValue(String key) { key=key.toLowerCase(); + key=key.replace(" ", ""); + key=key.replace("_", " "); String result ="NONE"; try{ result=this.hashMap.get(key); @@ -51,6 +53,9 @@ } public void setHashValue(String key, String value) { + key=key.replace(" ", ""); + key=key.replace("_", " "); + value=value.replace("__", ""); this.hashMap.put(key.toLowerCase(), value); } 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-02-08 13:48:02 UTC (rev 3578) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/exploration_main/exploration_main.java 2012-02-09 16:15:27 UTC (rev 3579) @@ -165,17 +165,17 @@ //queryInformation tmpquery; //only question, which are not yago files if(s.isYago()==true)yago_querys=yago_querys+1; - if(s.isYago()==false){ + //if(s.isYago()==false){ queryInformation tmpquery=sparql.create_Sparql_query(s); if(!tmpquery.getResult().isEmpty()) { list_of_resultstructs.add(sparql.create_Sparql_query(s)); anzahl_query_with_answers=anzahl_query_with_answers+1; } - } + //} } - /* - //Print to Console + + /* //Print to Console System.out.println("\n#############\n Result:"); for(queryInformation s : list_of_resultstructs){ System.out.println(s.getResult()); @@ -221,9 +221,15 @@ queryInformation result = new queryInformation(line,"0","",false,false,false,"non",false); result= sparql.create_Sparql_query(newQuery); ArrayList<String> ergebnis = result.getResult(); + //get eacht result only once! + Set<String> setString = new HashSet<String>(); for(String i: ergebnis){ - System.out.println(i); + setString.add(i); + //System.out.println(i); } + for(String z: setString){ + System.out.println(z); + } long endTime= System.currentTimeMillis(); System.out.println("\n The complete answering of the Question took "+(endTime-startTime)+" ms"); } @@ -311,7 +317,13 @@ xmlDocument="<?xml version=\"1.0\" ?><dataset id=\""+s.getXMLtype()+"\">"; } tmp="<question id=\""+s.getId()+"\"><string>"+s.getQuery()+"</string>\n<answers>"; - for(String i : s.getResult()){ + + //to get all answers only once! + Set<String> setString = new HashSet<String>(); + for(String z: s.getResult()){ + setString.add(z); + } + for(String i : setString){ String input=""; if(i.contains("http")) input="<uri>"+i+"</uri>\n"; else if (i.contains("true")||i.contains("false")) input="<boolean>"+i+"</boolean>\n"; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |