diff --git a/htroot/Ranking_p.java b/htroot/Ranking_p.java index dd1f55694..4f3b510dc 100644 --- a/htroot/Ranking_p.java +++ b/htroot/Ranking_p.java @@ -1,4 +1,4 @@ -// Ranking_p.java +// Ranking_p.java // -------------- // (C) 2006 by Michael Peter Christen; mc@yacy.net, Frankfurt a. M., Germany // first published 05.02.2006 on http://yacy.net @@ -10,7 +10,7 @@ // $LastChangedBy$ // // LICENSE -// +// // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or @@ -25,7 +25,7 @@ // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -import java.util.HashMap; +import java.util.LinkedHashMap; import java.util.Map; import java.util.Map.Entry; @@ -34,49 +34,49 @@ import net.yacy.search.Switchboard; import net.yacy.search.query.SearchEventCache; import net.yacy.search.ranking.RankingProfile; import net.yacy.search.snippet.ContentDomain; - import de.anomic.server.serverObjects; import de.anomic.server.serverSwitch; import de.anomic.tools.crypt; public class Ranking_p { - + private static final int maxRankingRange = 16; - - private static final HashMap rankingParameters = new HashMap(); + + private static final LinkedHashMap rankingParameters = new LinkedHashMap(); static { - rankingParameters.put(RankingProfile.APP_DC_CREATOR, "Appearance In Author;a higher ranking level prefers documents with authors that match the search word"); - rankingParameters.put(RankingProfile.APP_DC_TITLE, "Appearance In Title;a higher ranking level prefers documents with titles that match the search word"); - rankingParameters.put(RankingProfile.APPEMPH, "Appearance In Emphasized Text;a higher ranking level prefers documents where the search word is emphasized"); - rankingParameters.put(RankingProfile.APP_DC_DESCRIPTION, "Appearance In Reference/Anchor Name;a higher ranking level prefers documents where the search word matches in the description text"); - rankingParameters.put(RankingProfile.APP_DC_SUBJECT, "Appearance In Tags;a higher ranking level prefers documents where the search word is part of subject tags"); - rankingParameters.put(RankingProfile.APPURL, "Appearance In URL;a higher ranking level prefers documents with urls that match the search word"); - rankingParameters.put(RankingProfile.AUTHORITY, "Authority of Domain;a higher ranking level prefers documents from domains with a large number of matching documents"); - rankingParameters.put(RankingProfile.CATHASAPP, "Category App, Appearance;a higher ranking level prefers documents with embedded links to applications"); - rankingParameters.put(RankingProfile.CATHASAUDIO, "Category Audio Appearance;a higher ranking level prefers documents with embedded links to audio content"); - rankingParameters.put(RankingProfile.CATHASIMAGE, "Category Image Appearance;a higher ranking level prefers documents with embedded images"); - rankingParameters.put(RankingProfile.CATHASVIDEO, "Category Video Appearance;a higher ranking level prefers documents with embedded links to video files"); - rankingParameters.put(RankingProfile.CATINDEXOF, "Category Index Page;a higher ranking level prefers 'index of' (directory listings) pages"); - rankingParameters.put(RankingProfile.DATE, "Date;a higher ranking level prefers younger documents. The age of a document is measured using the date submitted by the remote server as document date"); - rankingParameters.put(RankingProfile.DESCRCOMPINTOPLIST, "Description Comp. Appears In Toplist;a higher ranking level prefers documents with words in the document description that match words in the toplist. The toplist is generated dynamically from the search results using a statistic of the most used words. The toplist is a top-10 list of the most used words in URLs and document titles."); - rankingParameters.put(RankingProfile.DOMLENGTH, "Domain Length;a higher ranking level prefers documents with a short domain name"); - rankingParameters.put(RankingProfile.HITCOUNT, "Hit Count;a higher ranking level prefers documents with a large number of matchings for the search word(s)"); - rankingParameters.put(RankingProfile.LLOCAL, "Links To Local Domain;a higher ranking level prefers documents with a high number of hyperlinks to the same domain as the matching document."); - rankingParameters.put(RankingProfile.LOTHER, "Links To Other Domain;a higher ranking level prefers documents with a high number of hyperlinks to domains other than the matching document domain"); - rankingParameters.put(RankingProfile.PHRASESINTEXT, "Phrases In Text;a higher ranking level prefers documents with a large number of phrases (sentences) in the matching document."); - rankingParameters.put(RankingProfile.POSINTEXT, "Position In Text;a higher ranking level prefers documents with a word match position high in the document. This prefers documents where the search wort is at the beginning of a text."); - rankingParameters.put(RankingProfile.POSOFPHRASE, "Position Of Phrase;a higher ranking level prefers documents with a phrase match position high in the document. The phrase match is the phrase (sentence) where the matching word appears first. This prefers documents where the search wort is at the beginning of a text."); - rankingParameters.put(RankingProfile.POSINPHRASE, "Position In Phrase;a higher ranking level prefers documents with a word match position high in the matching phrase. The phrase match is the phrase (sentence) where the matching word appears first."); - rankingParameters.put(RankingProfile.PREFER, "Application Of Prefer Pattern;a higher ranking level prefers documents where the url matches the prefer pattern given in a search request."); - rankingParameters.put(RankingProfile.TERMFREQUENCY, "Term Frequency;a higher ranking level prefers documents with a high (number of matching words)/(number of words in document) ratio. This is same ranking as used in lucene and old-age search engines as existed before the year 2000."); - rankingParameters.put(RankingProfile.URLCOMPINTOPLIST, "URL Component Appears In Toplist;a higher ranking level prefers documents with words in the url path that match words in the toplist. The toplist is generated dynamically from the search results using a statistic of the most used words. The toplist is a top-10 list of the most used words in URLs and document titles."); - rankingParameters.put(RankingProfile.URLCOMPS, "URL Components;a higher ranking level prefers documents with a short number of url components. The number of url components is the number of (sub-) domains plus the number of (sub-) path elements in the file path."); - rankingParameters.put(RankingProfile.URLLENGTH, "URL Length;a higher ranking level prefers documents with a short url (domain plus path)"); - rankingParameters.put(RankingProfile.WORDDISTANCE, "Word Distance;a higher ranking level prefers documents where the search words appear close together. This ranking parameter works like a NEAR operator in more-than-one word searches."); - rankingParameters.put(RankingProfile.WORDSINTEXT, "Words In Text;a higher ranking level prefers documents with a large number of words. Be aware that this is a compensation of the term frequency parameter."); - rankingParameters.put(RankingProfile.WORDSINTITLE, "Words In Title;a higher ranking level prefers documents with a large number of words in the document title."); - rankingParameters.put(RankingProfile.YBR, "YaCy Block Rank;a higher ranking level prefers documents with a higher, statically assigned ranking value on domains. This is like a 'moderated ranking'. The ranking on domains (blocks) was computed using a link analyses on large link graphs."); - rankingParameters.put(RankingProfile.LANGUAGE, "Preferred Language;a higher ranking level prefers documents with a language that matches the browser language."); + rankingParameters.put(RankingProfile.APPEMPH, "Appearance In Emphasized Text;a higher ranking level prefers documents where the search word is emphasized"); + rankingParameters.put(RankingProfile.APPURL, "Appearance In URL;a higher ranking level prefers documents with urls that match the search word"); + rankingParameters.put(RankingProfile.APP_DC_CREATOR, "Appearance In Author;a higher ranking level prefers documents with authors that match the search word"); + rankingParameters.put(RankingProfile.APP_DC_DESCRIPTION, "Appearance In Reference/Anchor Name;a higher ranking level prefers documents where the search word matches in the description text"); + rankingParameters.put(RankingProfile.APP_DC_SUBJECT, "Appearance In Tags;a higher ranking level prefers documents where the search word is part of subject tags"); + rankingParameters.put(RankingProfile.APP_DC_TITLE, "Appearance In Title;a higher ranking level prefers documents with titles that match the search word"); + rankingParameters.put(RankingProfile.AUTHORITY, "Authority of Domain;a higher ranking level prefers documents from domains with a large number of matching documents"); + rankingParameters.put(RankingProfile.CATHASAPP, "Category App, Appearance;a higher ranking level prefers documents with embedded links to applications"); + rankingParameters.put(RankingProfile.CATHASAUDIO, "Category Audio Appearance;a higher ranking level prefers documents with embedded links to audio content"); + rankingParameters.put(RankingProfile.CATHASIMAGE, "Category Image Appearance;a higher ranking level prefers documents with embedded images"); + rankingParameters.put(RankingProfile.CATHASVIDEO, "Category Video Appearance;a higher ranking level prefers documents with embedded links to video files"); + rankingParameters.put(RankingProfile.CATINDEXOF, "Category Index Page;a higher ranking level prefers 'index of' (directory listings) pages"); + rankingParameters.put(RankingProfile.DATE, "Date;a higher ranking level prefers younger documents. The age of a document is measured using the date submitted by the remote server as document date"); + rankingParameters.put(RankingProfile.DOMLENGTH, "Domain Length;a higher ranking level prefers documents with a short domain name"); + rankingParameters.put(RankingProfile.HITCOUNT, "Hit Count;a higher ranking level prefers documents with a large number of matchings for the search word(s)"); + rankingParameters.put(RankingProfile.LANGUAGE, "Preferred Language;a higher ranking level prefers documents with a language that matches the browser language."); + rankingParameters.put(RankingProfile.LLOCAL, "Links To Local Domain;a higher ranking level prefers documents with a high number of hyperlinks to the same domain as the matching document."); + rankingParameters.put(RankingProfile.LOTHER, "Links To Other Domain;a higher ranking level prefers documents with a high number of hyperlinks to domains other than the matching document domain"); + rankingParameters.put(RankingProfile.PHRASESINTEXT, "Phrases In Text;a higher ranking level prefers documents with a large number of phrases (sentences) in the matching document."); + rankingParameters.put(RankingProfile.POSINPHRASE, "Position In Phrase;a higher ranking level prefers documents with a word match position high in the matching phrase. The phrase match is the phrase (sentence) where the matching word appears first."); + rankingParameters.put(RankingProfile.POSINTEXT, "Position In Text;a higher ranking level prefers documents with a word match position high in the document. This prefers documents where the search wort is at the beginning of a text."); + rankingParameters.put(RankingProfile.POSOFPHRASE, "Position Of Phrase;a higher ranking level prefers documents with a phrase match position high in the document. The phrase match is the phrase (sentence) where the matching word appears first. This prefers documents where the search wort is at the beginning of a text."); + rankingParameters.put(RankingProfile.TERMFREQUENCY, "Term Frequency;a higher ranking level prefers documents with a high (number of matching words)/(number of words in document) ratio. This is same ranking as used in lucene and old-age search engines as existed before the year 2000."); + rankingParameters.put(RankingProfile.URLCOMPS, "URL Components;a higher ranking level prefers documents with a short number of url components. The number of url components is the number of (sub-) domains plus the number of (sub-) path elements in the file path."); + rankingParameters.put(RankingProfile.URLLENGTH, "URL Length;a higher ranking level prefers documents with a short url (domain plus path)"); + rankingParameters.put(RankingProfile.WORDDISTANCE, "Word Distance;a higher ranking level prefers documents where the search words appear close together. This ranking parameter works like a NEAR operator in more-than-one word searches."); + rankingParameters.put(RankingProfile.WORDSINTEXT, "Words In Text;a higher ranking level prefers documents with a large number of words. Be aware that this is a compensation of the term frequency parameter."); + rankingParameters.put(RankingProfile.WORDSINTITLE, "Words In Title;a higher ranking level prefers documents with a large number of words in the document title."); + rankingParameters.put(RankingProfile.YBR, "YaCy Block Rank;a higher ranking level prefers documents with a higher, statically assigned ranking value on domains. This is like a 'moderated ranking'. The ranking on domains (blocks) was computed using a link analyses on large link graphs."); + + rankingParameters.put(RankingProfile.URLCOMPINTOPLIST, "URL Component Appears In Toplist;a higher ranking level prefers documents with words in the url path that match words in the toplist. The toplist is generated dynamically from the search results using a statistic of the most used words. The toplist is a top-10 list of the most used words in URLs and document titles."); + rankingParameters.put(RankingProfile.DESCRCOMPINTOPLIST, "Description Comp. Appears In Toplist;a higher ranking level prefers documents with words in the document description that match words in the toplist. The toplist is generated dynamically from the search results using a statistic of the most used words. The toplist is a top-10 list of the most used words in URLs and document titles."); + rankingParameters.put(RankingProfile.PREFER, "Application Of Prefer Pattern;a higher ranking level prefers documents where the url matches the prefer pattern given in a search request."); } private static serverObjects defaultValues() { @@ -98,12 +98,12 @@ public class Ranking_p { prop.put("jumpToCursor", "1"); return prop; } - + private static void putRanking(final serverObjects prop, final RankingProfile rankingProfile, final String prefix) { putRanking(prop, rankingProfile.preToExternalMap(prefix), prefix, "Pre"); putRanking(prop, rankingProfile.postToExternalMap(prefix), prefix, "Post"); } - + private static void putRanking(final serverObjects prop, final Map map, final String prefix, final String attrExtension) { prop.put("attr" + attrExtension, map.size()); String key, description, name, info; @@ -138,24 +138,24 @@ public class Ranking_p { j++; } } - + public static serverObjects respond(final RequestHeader header, final serverObjects post, final serverSwitch env) { final Switchboard sb = (Switchboard) env; // clean up all search events SearchEventCache.cleanupEvents(true); - + // case if no values are requested - if ((post == null) || (sb == null)) { + if (post == null || sb == null) { // we create empty entries for template strings final serverObjects prop = defaultValues(); final RankingProfile ranking; - if(sb == null) ranking = new RankingProfile(ContentDomain.TEXT); + if (sb == null) ranking = new RankingProfile(ContentDomain.TEXT); else ranking = sb.getRanking(); putRanking(prop, ranking, "local"); return prop; } - + if (post.containsKey("EnterRanking")) { final RankingProfile ranking = new RankingProfile("local", post.toString()); sb.setConfig("rankingProfile", crypt.simpleEncode(ranking.toExternalString())); @@ -164,7 +164,7 @@ public class Ranking_p { putRanking(prop, ranking, "local"); return prop; } - + if (post.containsKey("ResetRanking")) { sb.setConfig("rankingProfile", ""); final RankingProfile ranking = new RankingProfile(ContentDomain.TEXT); @@ -173,7 +173,7 @@ public class Ranking_p { putRanking(prop, ranking, "local"); return prop; } - + final RankingProfile localRanking = new RankingProfile("local", post.toString()); final serverObjects prop = new serverObjects(); putRanking(prop, localRanking, "local"); diff --git a/source/net/yacy/search/ranking/RankingProfile.java b/source/net/yacy/search/ranking/RankingProfile.java index 331c2567e..12446b728 100644 --- a/source/net/yacy/search/ranking/RankingProfile.java +++ b/source/net/yacy/search/ranking/RankingProfile.java @@ -1,4 +1,4 @@ -// RankingProfile.java +// RankingProfile.java // ------------------------------- // part of YACY // (C) by Michael Peter Christen; mc@yacy.net @@ -27,6 +27,7 @@ package net.yacy.search.ranking; import java.util.HashMap; +import java.util.LinkedHashMap; import java.util.Map; import net.yacy.kelondro.logging.Log; @@ -35,35 +36,35 @@ import net.yacy.search.snippet.ContentDomain; public class RankingProfile { // pre-sort attributes - public static final String DOMLENGTH = "domlength"; - public static final String YBR = "ybr"; + public static final String APPEMPH = "appemph"; + public static final String APPURL = "appurl"; + public static final String APP_DC_CREATOR = "appauthor"; // the author field + public static final String APP_DC_DESCRIPTION = "appref"; // references to the source (content of tag) + public static final String APP_DC_SUBJECT = "apptags"; // tags + public static final String APP_DC_TITLE = "appdescr"; // title of page + public static final String AUTHORITY = "authority"; + public static final String CATHASAPP = "cathasapp"; + public static final String CATHASAUDIO = "cathasaudio"; + public static final String CATHASIMAGE = "cathasimage"; + public static final String CATHASVIDEO = "cathasvideo"; + public static final String CATINDEXOF = "catindexof"; public static final String DATE = "date"; - public static final String WORDSINTITLE = "wordsintitle"; - public static final String WORDSINTEXT = "wordsintext"; - public static final String PHRASESINTEXT = "phrasesintext"; + public static final String DOMLENGTH = "domlength"; + public static final String HITCOUNT = "hitcount"; + public static final String LANGUAGE = "language"; // ranking of preferred language public static final String LLOCAL = "llocal"; public static final String LOTHER = "lother"; - public static final String URLLENGTH = "urllength"; - public static final String URLCOMPS = "urlcomps"; - public static final String HITCOUNT = "hitcount"; + public static final String PHRASESINTEXT = "phrasesintext"; + public static final String POSINPHRASE = "posinphrase"; public static final String POSINTEXT = "posintext"; public static final String POSOFPHRASE = "posofphrase"; - public static final String POSINPHRASE = "posinphrase"; - public static final String AUTHORITY = "authority"; - public static final String WORDDISTANCE = "worddistance"; - public static final String APPURL = "appurl"; - public static final String APP_DC_TITLE = "appdescr"; // title of page - public static final String APP_DC_CREATOR = "appauthor"; // the author field - public static final String APP_DC_SUBJECT = "apptags"; // tags - public static final String APP_DC_DESCRIPTION = "appref"; // references to the source (content of tag) - public static final String APPEMPH = "appemph"; - public static final String CATINDEXOF = "catindexof"; - public static final String CATHASIMAGE = "cathasimage"; - public static final String CATHASAUDIO = "cathasaudio"; - public static final String CATHASVIDEO = "cathasvideo"; - public static final String CATHASAPP = "cathasapp"; public static final String TERMFREQUENCY = "tf"; - public static final String LANGUAGE = "language"; // ranking of preferred language + public static final String URLCOMPS = "urlcomps"; + public static final String URLLENGTH = "urllength"; + public static final String WORDDISTANCE = "worddistance"; + public static final String WORDSINTEXT = "wordsintext"; + public static final String WORDSINTITLE = "wordsintitle"; + public static final String YBR = "ybr"; // post-sort predicates public static final String URLCOMPINTOPLIST = "urlcompintoplist"; @@ -73,52 +74,53 @@ public class RankingProfile { // coefficient max/min values public static final int COEFF_MIN = 0; public static final int COEFF_MAX = 15; - + public int coeff_domlength, coeff_ybr, coeff_date, coeff_wordsintitle, coeff_wordsintext, coeff_phrasesintext, - coeff_llocal, coeff_lother, coeff_urllength, coeff_urlcomps, coeff_hitcount, + coeff_llocal, coeff_lother, coeff_urllength, coeff_urlcomps, coeff_hitcount, coeff_posintext, coeff_posofphrase, coeff_posinphrase, coeff_authority, coeff_worddistance, coeff_appurl, coeff_app_dc_title, coeff_app_dc_creator, coeff_app_dc_subject, coeff_app_dc_description, coeff_appemph, coeff_catindexof, coeff_cathasimage, coeff_cathasaudio, coeff_cathasvideo, coeff_cathasapp, coeff_urlcompintoplist, coeff_descrcompintoplist, coeff_prefer, coeff_termfrequency, coeff_language; - + public RankingProfile(final ContentDomain mediatype) { // set default-values - coeff_domlength = 11; - coeff_ybr = 15; - coeff_date = 13; - coeff_wordsintitle = 4; - coeff_wordsintext = 2; - coeff_phrasesintext = 3; - coeff_llocal = 2; - coeff_lother = 3; - coeff_urllength = 14; - coeff_urlcomps = 12; - coeff_hitcount = 9; - coeff_posintext = 10; - coeff_posofphrase = 8; - coeff_posinphrase = 1; - coeff_authority = 11; - coeff_worddistance = 12; - coeff_appurl = 14; - coeff_app_dc_title = 14; - coeff_app_dc_creator = 12; - coeff_app_dc_subject = 13; - coeff_app_dc_description = 13; - coeff_appemph = 10; - coeff_catindexof = (mediatype == ContentDomain.TEXT) ? 0 : 15; - coeff_cathasimage = (mediatype == ContentDomain.IMAGE) ? 15 : 0; - coeff_cathasaudio = (mediatype == ContentDomain.AUDIO) ? 15 : 0; - coeff_cathasvideo = (mediatype == ContentDomain.VIDEO) ? 15 : 0; - coeff_cathasapp = (mediatype == ContentDomain.APP) ? 15 : 0; - coeff_termfrequency = 14; - coeff_urlcompintoplist = 3; - coeff_descrcompintoplist = 2; - coeff_prefer = 14; - coeff_language = 13; + this.coeff_appemph = 5; + this.coeff_appurl = 11; + this.coeff_app_dc_creator = 1; + this.coeff_app_dc_description = 4; + this.coeff_app_dc_subject = 2; + this.coeff_app_dc_title = 8; + this.coeff_authority = 5; + this.coeff_cathasapp = (mediatype == ContentDomain.APP) ? 15 : 0; + this.coeff_cathasaudio = (mediatype == ContentDomain.AUDIO) ? 15 : 0; + this.coeff_cathasimage = (mediatype == ContentDomain.IMAGE) ? 15 : 0; + this.coeff_cathasvideo = (mediatype == ContentDomain.VIDEO) ? 15 : 0; + this.coeff_catindexof = (mediatype == ContentDomain.TEXT) ? 0 : 15; + this.coeff_date = 7; + this.coeff_domlength = 9; + this.coeff_hitcount = 1; + this.coeff_language = 2; + this.coeff_llocal = 0; + this.coeff_lother = 7; + this.coeff_phrasesintext = 0; + this.coeff_posinphrase = 0; + this.coeff_posintext = 4; + this.coeff_posofphrase = 0; + this.coeff_termfrequency = 6; + this.coeff_urlcomps = 7; + this.coeff_urllength = 6; + this.coeff_worddistance = 15; + this.coeff_wordsintext = 3; + this.coeff_wordsintitle = 2; + this.coeff_ybr = 8; + + this.coeff_urlcompintoplist = 15; + this.coeff_descrcompintoplist = 15; + this.coeff_prefer = 15; } - + public RankingProfile(final String prefix, String profile) { this(ContentDomain.TEXT); // set defaults if ((profile != null) && (profile.length() > 0)) { @@ -129,59 +131,59 @@ public class RankingProfile { profile = profile.substring(1, profile.length() - 1); } profile = profile.trim(); - if (profile.indexOf('&') > 0) elts = profile.split("&"); else elts = profile.split(","); + if (profile.indexOf('&') > 0) elts = profile.split("&"); else elts = profile.split(","); int p; final int s = (prefix == null) ? 0 : prefix.length(); String e; - - for (int i = 0; i < elts.length; i++) { - e = elts[i].trim(); + + for (final String elt : elts) { + e = elt.trim(); 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)) try { coeff.put(e.substring(s, p), Integer.valueOf(Integer.parseInt(e.substring(p + 1)))); - } catch (NumberFormatException e1) { + } catch (final 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); - coeff_ybr = parseMap(coeff, YBR, coeff_ybr); - coeff_date = parseMap(coeff, DATE, coeff_date); - coeff_wordsintitle = parseMap(coeff, WORDSINTITLE, coeff_wordsintitle); - coeff_wordsintext = parseMap(coeff, WORDSINTEXT, coeff_wordsintext); - coeff_phrasesintext = parseMap(coeff, PHRASESINTEXT, coeff_phrasesintext); - coeff_llocal = parseMap(coeff, LLOCAL, coeff_llocal); - coeff_lother = parseMap(coeff, LOTHER, coeff_lother); - coeff_urllength = parseMap(coeff, URLLENGTH, coeff_urllength); - coeff_urlcomps = parseMap(coeff, URLCOMPS, coeff_urlcomps); - coeff_hitcount = parseMap(coeff, HITCOUNT, coeff_hitcount); - coeff_posintext = parseMap(coeff, POSINTEXT, coeff_posintext); - coeff_posofphrase = parseMap(coeff, POSOFPHRASE, coeff_posofphrase); - coeff_posinphrase = parseMap(coeff, POSINPHRASE, coeff_posinphrase); - coeff_authority = parseMap(coeff, AUTHORITY, coeff_authority); - coeff_worddistance = parseMap(coeff, WORDDISTANCE, coeff_worddistance); - coeff_appurl = parseMap(coeff, APPURL, coeff_appurl); - coeff_app_dc_title = parseMap(coeff, APP_DC_TITLE, coeff_app_dc_title); - coeff_app_dc_creator = parseMap(coeff, APP_DC_CREATOR, coeff_app_dc_creator); - coeff_app_dc_subject = parseMap(coeff, APP_DC_SUBJECT, coeff_app_dc_subject); - coeff_app_dc_description = parseMap(coeff, APP_DC_DESCRIPTION, coeff_app_dc_description); - coeff_appemph = parseMap(coeff, APPEMPH, coeff_appemph); - coeff_catindexof = parseMap(coeff, CATINDEXOF, coeff_catindexof); - coeff_cathasimage = parseMap(coeff, CATHASIMAGE, coeff_cathasimage); - coeff_cathasaudio = parseMap(coeff, CATHASAUDIO, coeff_cathasaudio); - coeff_cathasvideo = parseMap(coeff, CATHASVIDEO, coeff_cathasvideo); - coeff_cathasapp = parseMap(coeff, CATHASAPP, coeff_cathasapp); - coeff_termfrequency = parseMap(coeff, TERMFREQUENCY, coeff_termfrequency); - coeff_urlcompintoplist = parseMap(coeff, URLCOMPINTOPLIST, coeff_urlcompintoplist); - coeff_descrcompintoplist = parseMap(coeff, DESCRCOMPINTOPLIST, coeff_descrcompintoplist); - coeff_prefer = parseMap(coeff, PREFER, coeff_prefer); - coeff_language = parseMap(coeff, LANGUAGE, coeff_language); + this.coeff_domlength = parseMap(coeff, DOMLENGTH, this.coeff_domlength); + this.coeff_ybr = parseMap(coeff, YBR, this.coeff_ybr); + this.coeff_date = parseMap(coeff, DATE, this.coeff_date); + this.coeff_wordsintitle = parseMap(coeff, WORDSINTITLE, this.coeff_wordsintitle); + this.coeff_wordsintext = parseMap(coeff, WORDSINTEXT, this.coeff_wordsintext); + this.coeff_phrasesintext = parseMap(coeff, PHRASESINTEXT, this.coeff_phrasesintext); + this.coeff_llocal = parseMap(coeff, LLOCAL, this.coeff_llocal); + this.coeff_lother = parseMap(coeff, LOTHER, this.coeff_lother); + this.coeff_urllength = parseMap(coeff, URLLENGTH, this.coeff_urllength); + this.coeff_urlcomps = parseMap(coeff, URLCOMPS, this.coeff_urlcomps); + this.coeff_hitcount = parseMap(coeff, HITCOUNT, this.coeff_hitcount); + this.coeff_posintext = parseMap(coeff, POSINTEXT, this.coeff_posintext); + this.coeff_posofphrase = parseMap(coeff, POSOFPHRASE, this.coeff_posofphrase); + this.coeff_posinphrase = parseMap(coeff, POSINPHRASE, this.coeff_posinphrase); + this.coeff_authority = parseMap(coeff, AUTHORITY, this.coeff_authority); + this.coeff_worddistance = parseMap(coeff, WORDDISTANCE, this.coeff_worddistance); + this.coeff_appurl = parseMap(coeff, APPURL, this.coeff_appurl); + this.coeff_app_dc_title = parseMap(coeff, APP_DC_TITLE, this.coeff_app_dc_title); + this.coeff_app_dc_creator = parseMap(coeff, APP_DC_CREATOR, this.coeff_app_dc_creator); + this.coeff_app_dc_subject = parseMap(coeff, APP_DC_SUBJECT, this.coeff_app_dc_subject); + this.coeff_app_dc_description = parseMap(coeff, APP_DC_DESCRIPTION, this.coeff_app_dc_description); + this.coeff_appemph = parseMap(coeff, APPEMPH, this.coeff_appemph); + this.coeff_catindexof = parseMap(coeff, CATINDEXOF, this.coeff_catindexof); + this.coeff_cathasimage = parseMap(coeff, CATHASIMAGE, this.coeff_cathasimage); + this.coeff_cathasaudio = parseMap(coeff, CATHASAUDIO, this.coeff_cathasaudio); + this.coeff_cathasvideo = parseMap(coeff, CATHASVIDEO, this.coeff_cathasvideo); + this.coeff_cathasapp = parseMap(coeff, CATHASAPP, this.coeff_cathasapp); + this.coeff_termfrequency = parseMap(coeff, TERMFREQUENCY, this.coeff_termfrequency); + this.coeff_urlcompintoplist = parseMap(coeff, URLCOMPINTOPLIST, this.coeff_urlcompintoplist); + this.coeff_descrcompintoplist = parseMap(coeff, DESCRCOMPINTOPLIST, this.coeff_descrcompintoplist); + this.coeff_prefer = parseMap(coeff, PREFER, this.coeff_prefer); + this.coeff_language = parseMap(coeff, LANGUAGE, this.coeff_language); } } - + private static int parseMap(final Map coeff, final String attr, final int dflt) { if (!coeff.containsKey(attr)) return dflt; @@ -191,59 +193,59 @@ public class RankingProfile { public String toExternalString() { return toExternalMap("").toString(); } - + public Map toExternalMap(final String prefix) { final Map ext = preToExternalMap(prefix); ext.putAll(postToExternalMap(prefix)); return ext; } - + public Map preToExternalMap(final String prefix) { - final Map ext = new HashMap(40); - ext.put(prefix + DOMLENGTH, Integer.toString(coeff_domlength)); - ext.put(prefix + YBR, Integer.toString(coeff_ybr)); - ext.put(prefix + DATE, Integer.toString(coeff_date)); - ext.put(prefix + WORDSINTITLE, Integer.toString(coeff_wordsintitle)); - ext.put(prefix + WORDSINTEXT, Integer.toString(coeff_wordsintext)); - ext.put(prefix + PHRASESINTEXT, Integer.toString(coeff_phrasesintext)); - ext.put(prefix + LLOCAL, Integer.toString(coeff_llocal)); - ext.put(prefix + LOTHER, Integer.toString(coeff_lother)); - ext.put(prefix + URLLENGTH, Integer.toString(coeff_urllength)); - ext.put(prefix + URLCOMPS, Integer.toString(coeff_urlcomps)); - ext.put(prefix + HITCOUNT, Integer.toString(coeff_hitcount)); - ext.put(prefix + POSINTEXT, Integer.toString(coeff_posintext)); - ext.put(prefix + POSOFPHRASE, Integer.toString(coeff_posofphrase)); - ext.put(prefix + POSINPHRASE, Integer.toString(coeff_posinphrase)); - ext.put(prefix + AUTHORITY, Integer.toString(coeff_authority)); - ext.put(prefix + WORDDISTANCE, Integer.toString(coeff_worddistance)); - ext.put(prefix + APPURL, Integer.toString(coeff_appurl)); - ext.put(prefix + APP_DC_TITLE, Integer.toString(coeff_app_dc_title)); - ext.put(prefix + APP_DC_CREATOR, Integer.toString(coeff_app_dc_creator)); - ext.put(prefix + APP_DC_SUBJECT, Integer.toString(coeff_app_dc_subject)); - ext.put(prefix + APP_DC_DESCRIPTION, Integer.toString(coeff_app_dc_description)); - ext.put(prefix + APPEMPH, Integer.toString(coeff_appemph)); - ext.put(prefix + CATINDEXOF, Integer.toString(coeff_catindexof)); - ext.put(prefix + CATHASIMAGE, Integer.toString(coeff_cathasimage)); - ext.put(prefix + CATHASAUDIO, Integer.toString(coeff_cathasaudio)); - ext.put(prefix + CATHASVIDEO, Integer.toString(coeff_cathasvideo)); - ext.put(prefix + CATHASAPP, Integer.toString(coeff_cathasapp)); - ext.put(prefix + TERMFREQUENCY, Integer.toString(coeff_termfrequency)); - ext.put(prefix + LANGUAGE, Integer.toString(coeff_language)); + final Map ext = new LinkedHashMap(40); + ext.put(prefix + APPEMPH, Integer.toString(this.coeff_appemph)); + ext.put(prefix + APPURL, Integer.toString(this.coeff_appurl)); + ext.put(prefix + APP_DC_CREATOR, Integer.toString(this.coeff_app_dc_creator)); + ext.put(prefix + APP_DC_DESCRIPTION, Integer.toString(this.coeff_app_dc_description)); + ext.put(prefix + APP_DC_SUBJECT, Integer.toString(this.coeff_app_dc_subject)); + ext.put(prefix + APP_DC_TITLE, Integer.toString(this.coeff_app_dc_title)); + ext.put(prefix + AUTHORITY, Integer.toString(this.coeff_authority)); + ext.put(prefix + CATHASAPP, Integer.toString(this.coeff_cathasapp)); + ext.put(prefix + CATHASAUDIO, Integer.toString(this.coeff_cathasaudio)); + ext.put(prefix + CATHASIMAGE, Integer.toString(this.coeff_cathasimage)); + ext.put(prefix + CATHASVIDEO, Integer.toString(this.coeff_cathasvideo)); + ext.put(prefix + CATINDEXOF, Integer.toString(this.coeff_catindexof)); + ext.put(prefix + DATE, Integer.toString(this.coeff_date)); + ext.put(prefix + DOMLENGTH, Integer.toString(this.coeff_domlength)); + ext.put(prefix + HITCOUNT, Integer.toString(this.coeff_hitcount)); + ext.put(prefix + LANGUAGE, Integer.toString(this.coeff_language)); + ext.put(prefix + LLOCAL, Integer.toString(this.coeff_llocal)); + ext.put(prefix + LOTHER, Integer.toString(this.coeff_lother)); + ext.put(prefix + PHRASESINTEXT, Integer.toString(this.coeff_phrasesintext)); + ext.put(prefix + POSINPHRASE, Integer.toString(this.coeff_posinphrase)); + ext.put(prefix + POSINTEXT, Integer.toString(this.coeff_posintext)); + ext.put(prefix + POSOFPHRASE, Integer.toString(this.coeff_posofphrase)); + ext.put(prefix + TERMFREQUENCY, Integer.toString(this.coeff_termfrequency)); + ext.put(prefix + URLCOMPS, Integer.toString(this.coeff_urlcomps)); + ext.put(prefix + URLLENGTH, Integer.toString(this.coeff_urllength)); + ext.put(prefix + WORDDISTANCE, Integer.toString(this.coeff_worddistance)); + ext.put(prefix + WORDSINTEXT, Integer.toString(this.coeff_wordsintext)); + ext.put(prefix + WORDSINTITLE, Integer.toString(this.coeff_wordsintitle)); + ext.put(prefix + YBR, Integer.toString(this.coeff_ybr)); return ext; } - + public Map postToExternalMap(final String prefix) { - final Map ext = new HashMap(); - ext.put(prefix + URLCOMPINTOPLIST, Integer.toString(coeff_urlcompintoplist)); - ext.put(prefix + DESCRCOMPINTOPLIST, Integer.toString(coeff_descrcompintoplist)); - ext.put(prefix + PREFER, Integer.toString(coeff_prefer)); + final Map ext = new LinkedHashMap(); + ext.put(prefix + URLCOMPINTOPLIST, Integer.toString(this.coeff_urlcompintoplist)); + ext.put(prefix + DESCRCOMPINTOPLIST, Integer.toString(this.coeff_descrcompintoplist)); + ext.put(prefix + PREFER, Integer.toString(this.coeff_prefer)); return ext; } - + public String toExternalURLGet(final String prefix) { final Map emap = toExternalMap(""); final StringBuilder ext = new StringBuilder(emap.size() * 40); - for (Map.Entry entry: emap.entrySet()) { + for (final Map.Entry entry: emap.entrySet()) { ext.append('&'); ext.append(prefix); ext.append(entry.getKey()); @@ -252,5 +254,5 @@ public class RankingProfile { } return ext.toString(); } - + }