From e3e5e05ec2b6633a1ec9e537686e31a9d2c5511c Mon Sep 17 00:00:00 2001 From: orbiter Date: Wed, 17 Feb 2010 21:31:08 +0000 Subject: [PATCH] fix for problem in ranking setting which was caused by the introduction of a toString() method in serverObjects see also: http://forum.yacy-websuche.de/viewtopic.php?p=19310#p19310 git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@6678 6c8d7289-2bf4-0310-a012-ef5d649a1542 --- source/de/anomic/search/RankingProfile.java | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/source/de/anomic/search/RankingProfile.java b/source/de/anomic/search/RankingProfile.java index fae6700ed..3ed6e9705 100644 --- a/source/de/anomic/search/RankingProfile.java +++ b/source/de/anomic/search/RankingProfile.java @@ -30,6 +30,8 @@ import java.util.HashMap; import java.util.Iterator; import java.util.Map; +import net.yacy.kelondro.logging.Log; + public class RankingProfile { // pre-sort attributes @@ -117,12 +119,17 @@ public class RankingProfile { coeff_language = 13; } - public RankingProfile(final String prefix, final String profile) { + public RankingProfile(final String prefix, String profile) { this(ContentDomain.TEXT); // set defaults if ((profile != null) && (profile.length() > 0)) { //parse external form final HashMap coeff = new HashMap(40); - final String[] elts = ((profile.length() > 0 && profile.charAt(0) == '{' && profile.endsWith("}")) ? profile.substring(1, profile.length() - 1) : profile).split(","); + final String[] elts; + if (profile.length() > 0 && profile.charAt(0) == '{' && profile.endsWith("}")) { + profile = profile.substring(1, profile.length() - 1); + } + profile = profile.trim(); + if (profile.indexOf('&') > 0) elts = profile.split("&"); else elts = profile.split(","); int p; final int s = (prefix == null) ? 0 : prefix.length(); String e; @@ -132,7 +139,12 @@ public class RankingProfile { if ((s == 0) || (e.startsWith(prefix))) { p = e.indexOf('='); if (p < 0) System.out.println("DEBUG: bug in plasmaSearchRankingProfile: e = " + e); - if ((p > 0) && (e.length() > p + 1)) coeff.put(e.substring(s, p), Integer.valueOf(Integer.parseInt(e.substring(p + 1)))); + if ((p > 0) && (e.length() > p + 1)) try { + coeff.put(e.substring(s, p), Integer.valueOf(Integer.parseInt(e.substring(p + 1)))); + } catch (NumberFormatException e1) { + System.out.println("wrong parameter: " + e.substring(s, p) + "=" + e.substring(p + 1)); + Log.logException(e1); + } } } coeff_domlength = parseMap(coeff, DOMLENGTH, coeff_domlength);