Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance
Java decentralizedintranet-searchintranet-search-enginep2pp2p-networkprivacyprivacy-protectionsearch-enginesearchenginewebweb-search-enginewebsearchwebseearch-engine
*) Better snippets: words like GNU/Linux will not prevent Linux or GNU from being marked if they are searchword (see http://www.yacy-forum.de/viewtopic.php?t=2891)
low012586add4c6cc1
diff --git a/source/de/anomic/plasma/plasmaSnippetCache.java b/source/de/anomic/plasma/plasmaSnippetCache.javaindex 6f2e912bc..d8ac10654 100644--- a/source/de/anomic/plasma/plasmaSnippetCache.java+++ b/source/de/anomic/plasma/plasmaSnippetCache.java@@ -52,6 +52,9 @@ import java.util.HashMap;import java.util.HashSet;import java.util.Iterator;import java.util.Map;+import java.util.regex.Pattern;+import java.util.regex.Matcher;+import java.util.regex.PatternSyntaxException;import java.util.Set;import java.util.TreeMap;@@ -148,19 +151,35 @@ public class plasmaSnippetCache {prefix = "";postfix = "";- while((w[j].matches("\\A[^\\p{L}\\p{N}].+"))) {+ //cut off prefix if it contains of non-characters or non-numbers+ while(w[j].matches("\\A[^\\p{L}\\p{N}].+")) {prefix = w[j].substring(0,1) + prefix;w[j] = w[j].substring(1);}- while((w[j].matches(".+[^\\p{L}\\p{N}]\\Z"))) {+ //cut off postfix if it contains of non-characters or non-numbers+ while(w[j].matches(".+[^\\p{L}\\p{N}]\\Z")) {len = w[j].length();postfix = w[j].substring(len-1,len) + postfix;w[j] = w[j].substring(0,len-1);}+ //recursion if there are non-characters or non-numbers in the middle of the string+ Pattern p = Pattern.compile("\\A([\\p{L}\\p{N}]+)([^\\p{L}\\p{N}])([\\p{L}\\p{N}]+)\\Z");+ Matcher m = p.matcher(w[j]);+ if(m.find()) {+ String left = m.group(1);+ String pattern = m.group(2);+ String right = m.group(3);+ Snippet snip = new Snippet(left,-1,null);+ w[j] = snip.getLineMarked(queryHashes);+ w[j] = w[j] + pattern;+ snip = new Snippet(right,-1,null);+ w[j] = w[j] + snip.getLineMarked(queryHashes);+ }+//end contrib [MN]- if (plasmaCondenser.word2hash(w[j]).equals(h)) w[j] = "<b>" + w[j] + "</b>";+ else if (plasmaCondenser.word2hash(w[j]).equals(h)) w[j] = "<b>" + w[j] + "</b>";w[j] = prefix + w[j] + postfix;}}