Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance
Java decentralizedintranet-searchintranet-search-enginep2pp2p-networkprivacyprivacy-protectionsearch-enginesearchenginewebweb-search-enginewebsearchwebseearch-engine
fixed bug with snippets
orbiter7f7cbc5019dc
diff --git a/source/de/anomic/plasma/plasmaSnippetCache.java b/source/de/anomic/plasma/plasmaSnippetCache.javaindex d5a80dcc3..64fa0dd16 100644--- a/source/de/anomic/plasma/plasmaSnippetCache.java+++ b/source/de/anomic/plasma/plasmaSnippetCache.java@@ -238,11 +238,14 @@ public class plasmaSnippetCache {hs = hashSentence(result);j = queryhashes.iterator();Integer pos;+ Set remaininghashes = new HashSet();int p, minpos = result.length(), maxpos = -1;while (j.hasNext()) {- pos = (Integer) hs.get((String) j.next());- if (pos != null) {- j.remove();+ hash = (String) j.next();+ pos = (Integer) hs.get(hash);+ if (pos == null) {+ remaininghashes.add(hash);+ } else {p = pos.intValue();if (p > maxpos) maxpos = p;if (p < minpos) minpos = p;@@ -267,7 +270,7 @@ public class plasmaSnippetCache {// so cut it here at both ends at onceint newlen = maxpos - minpos + 10;int around = (maxLength - newlen) / 2;- result = "[..] " + result.substring(minpos - around, maxpos + around).trim() + " [..]";+ result = "[..] " + result.substring(minpos - around, ((maxpos + around) > result.length()) ? result.length() : (maxpos + around)).trim() + " [..]";minpos = around;maxpos = result.length() - around - 5;}@@ -289,7 +292,7 @@ public class plasmaSnippetCache {// and find recursively more sentencesmaxLength = maxLength - result.length();if (maxLength < 20) maxLength = 20;- String nextSnippet = computeSnippet(sentences, queryhashes, minLength, maxLength);+ String nextSnippet = computeSnippet(sentences, remaininghashes, minLength, maxLength);return result + ((nextSnippet == null) ? "" : (" / " + nextSnippet));}