From: <and...@us...> - 2013-09-05 08:52:51
|
Revision: 4086 http://sourceforge.net/p/dl-learner/code/4086 Author: andremelo Date: 2013-09-05 08:52:49 +0000 (Thu, 05 Sep 2013) Log Message: ----------- Fixing getLongestMatch method and adding toString to SimpleEntityCandidatesTrie Modified Paths: -------------- trunk/components-core/src/main/java/org/dllearner/algorithms/isle/index/SimpleEntityCandidatesTrie.java trunk/components-core/src/main/java/org/dllearner/utilities/datastructures/PrefixTrie.java Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/isle/index/SimpleEntityCandidatesTrie.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/isle/index/SimpleEntityCandidatesTrie.java 2013-09-05 08:42:59 UTC (rev 4085) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/isle/index/SimpleEntityCandidatesTrie.java 2013-09-05 08:52:49 UTC (rev 4086) @@ -63,17 +63,23 @@ return (match!=null) ? trie.getLongestMatch(s).toString() : null; } - public void printTrie() { - System.out.println("Printing tree content:"); + public String toString() { + String output = ""; Map<String,Set<Entity>> trieMap = trie.toMap(); List<String> termsList = new ArrayList(trieMap.keySet()); Collections.sort(termsList); for (String key : termsList) { - System.out.println(key); + output += key + ": ("; for (Entity candidate: trieMap.get(key)) { - System.out.println("\t"+candidate); + output += "\t"+candidate+"\n"; } } + return output; } + + public void printTrie() { + System.out.println(this.toString()); + + } } Modified: trunk/components-core/src/main/java/org/dllearner/utilities/datastructures/PrefixTrie.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/utilities/datastructures/PrefixTrie.java 2013-09-05 08:42:59 UTC (rev 4085) +++ trunk/components-core/src/main/java/org/dllearner/utilities/datastructures/PrefixTrie.java 2013-09-05 08:52:49 UTC (rev 4086) @@ -104,6 +104,7 @@ } public CharSequence getLongestMatch(CharSequence s) { + Node<T> deepestWithValue = root; Node<T> current = root; int i; for (i = 0; i < s.length(); i++) { @@ -115,8 +116,11 @@ if (current == null) { break; } + if (current.value != null) { + deepestWithValue = current; + } } - if (i<=1) + if (i<=1 || deepestWithValue==root) return null; else return s.subSequence(1, i); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |