You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
yacy_search_server/htroot/Ranking_p.java

175 lines
8.0 KiB

// 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
//
// This is a part of YaCy, a peer-to-peer based web search engine
//
// $LastChangedDate: 2007-07-19 22:11:48 +0000 (Do, 19 Jul 2007) $
// $LastChangedRevision: 3995 $
// $LastChangedBy: orbiter $
//
// 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
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// 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.Map;
import java.util.Map.Entry;
import de.anomic.http.httpRequestHeader;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.search.QueryParams;
import de.anomic.search.RankingProfile;
import de.anomic.search.QueryEvent;
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<String, String> rankingParameters = new HashMap<String, String>();
static {
rankingParameters.put(RankingProfile.APP_DC_CREATOR, "Appearance In Author");
rankingParameters.put(RankingProfile.APP_DC_TITLE, "Appearance In Title");
rankingParameters.put(RankingProfile.APPEMPH, "Appearance In Emphasized Text");
rankingParameters.put(RankingProfile.APP_DC_DESCRIPTION, "Appearance In Reference/Anchor Name");
rankingParameters.put(RankingProfile.APP_DC_SUBJECT, "Appearance In Tags");
rankingParameters.put(RankingProfile.APPURL, "Appearance In URL");
rankingParameters.put(RankingProfile.AUTHORITY, "Authority of Domain");
rankingParameters.put(RankingProfile.CATHASAPP, "Category App, Appearance");
rankingParameters.put(RankingProfile.CATHASAUDIO, "Category Audio Appearance");
rankingParameters.put(RankingProfile.CATHASIMAGE, "Category Image Appearance");
rankingParameters.put(RankingProfile.CATHASVIDEO, "Category Video Appearance");
rankingParameters.put(RankingProfile.CATINDEXOF, "Category Index Page");
rankingParameters.put(RankingProfile.DATE, "Date");
rankingParameters.put(RankingProfile.DESCRCOMPINTOPLIST, "Description Comp. Appears In Toplist");
rankingParameters.put(RankingProfile.DOMLENGTH, "Domain Length");
rankingParameters.put(RankingProfile.HITCOUNT, "Hit Count");
rankingParameters.put(RankingProfile.LLOCAL, "Links To Local Domain");
rankingParameters.put(RankingProfile.LOTHER, "Links To Other Domain");
rankingParameters.put(RankingProfile.PHRASESINTEXT, "Phrases In Text");
rankingParameters.put(RankingProfile.POSINTEXT, "Position In Text");
rankingParameters.put(RankingProfile.POSOFPHRASE, "Position Of Phrase");
rankingParameters.put(RankingProfile.POSINPHRASE, "Position In Phrase");
rankingParameters.put(RankingProfile.PREFER, "Application Of Prefer Pattern");
rankingParameters.put(RankingProfile.TERMFREQUENCY, "Term Frequency");
rankingParameters.put(RankingProfile.URLCOMPINTOPLIST, "URL Component Appears In Toplist");
rankingParameters.put(RankingProfile.URLCOMPS, "URL Components");
rankingParameters.put(RankingProfile.URLLENGTH, "URL Length");
rankingParameters.put(RankingProfile.WORDDISTANCE, "Word Distance");
rankingParameters.put(RankingProfile.WORDSINTEXT, "Words In Text");
rankingParameters.put(RankingProfile.WORDSINTITLE, "Words In Title");
rankingParameters.put(RankingProfile.YBR, "YaCy Block Rank");
rankingParameters.put(RankingProfile.LANGUAGE, "Preferred Language");
}
private static serverObjects defaultValues() {
final serverObjects prop = new serverObjects();
prop.put("search", "");
* Complete number localization and provide a more reasonable interface to serverObjects: - put(key, value) methods are now used if a value added to the map should be kept as it is. Numbers are transformed (but not formatted) to an equivalent String representation. - putASIS(...) have been removed, now done with simple put(...) (see above). - puNum(...) can be used for number values which should be stored in a formatted way, either depending on the current locale setting for yacy (default) or in a "none" locale (see javadocs and setLocalize()). - putHTML(...) escapes special characters into corresponding HTML enities ('<' => '&lt;') which was done with put(...) before and so was called too often, becauses it is necessary only for very few cases. Additionally there is a "forXML" mode which only replaces < > & ". In short: Use put(...) for almost everything, use putXY(...) if you need some special transformation of the value. A few bugs have been fixed as well, and there should be a small performance improvement for complex pages with a lot of values. * added additional Sum/Avg rows to access tracker pages, see http://forum.yacy-websuche.de/viewtopic.php?f=5&t=456 * removed duplicate code (mostly related to the big changes above). TODO: - make sure, number formats work as expected _everywhere_, report overseen stuff http://forum.yacy-websuche.de/viewtopic.php?f=5&t=437 - probably a good idea to add special putDate() methods as they are used in many pages and create duplicated formatting code + maybe some centralized handling for memory value formatting. - further improve the speed of page creation for the WatchCrawler. git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@4178 6c8d7289-2bf4-0310-a012-ef5d649a1542
18 years ago
prop.put("num-results", "0");
prop.put("excluded", "0");
prop.put("combine", "0");
prop.put("resultbottomline", "0");
prop.put("localCount", "10");
prop.put("localWDist", "999");
//prop.put("globalChecked", "checked");
* Complete number localization and provide a more reasonable interface to serverObjects: - put(key, value) methods are now used if a value added to the map should be kept as it is. Numbers are transformed (but not formatted) to an equivalent String representation. - putASIS(...) have been removed, now done with simple put(...) (see above). - puNum(...) can be used for number values which should be stored in a formatted way, either depending on the current locale setting for yacy (default) or in a "none" locale (see javadocs and setLocalize()). - putHTML(...) escapes special characters into corresponding HTML enities ('<' => '&lt;') which was done with put(...) before and so was called too often, becauses it is necessary only for very few cases. Additionally there is a "forXML" mode which only replaces < > & ". In short: Use put(...) for almost everything, use putXY(...) if you need some special transformation of the value. A few bugs have been fixed as well, and there should be a small performance improvement for complex pages with a lot of values. * added additional Sum/Avg rows to access tracker pages, see http://forum.yacy-websuche.de/viewtopic.php?f=5&t=456 * removed duplicate code (mostly related to the big changes above). TODO: - make sure, number formats work as expected _everywhere_, report overseen stuff http://forum.yacy-websuche.de/viewtopic.php?f=5&t=437 - probably a good idea to add special putDate() methods as they are used in many pages and create duplicated formatting code + maybe some centralized handling for memory value formatting. - further improve the speed of page creation for the WatchCrawler. git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@4178 6c8d7289-2bf4-0310-a012-ef5d649a1542
18 years ago
prop.put("globalChecked", "0");
prop.put("postsortChecked", "1");
prop.put("localTime", "6");
prop.put("results", "");
* Complete number localization and provide a more reasonable interface to serverObjects: - put(key, value) methods are now used if a value added to the map should be kept as it is. Numbers are transformed (but not formatted) to an equivalent String representation. - putASIS(...) have been removed, now done with simple put(...) (see above). - puNum(...) can be used for number values which should be stored in a formatted way, either depending on the current locale setting for yacy (default) or in a "none" locale (see javadocs and setLocalize()). - putHTML(...) escapes special characters into corresponding HTML enities ('<' => '&lt;') which was done with put(...) before and so was called too often, becauses it is necessary only for very few cases. Additionally there is a "forXML" mode which only replaces < > & ". In short: Use put(...) for almost everything, use putXY(...) if you need some special transformation of the value. A few bugs have been fixed as well, and there should be a small performance improvement for complex pages with a lot of values. * added additional Sum/Avg rows to access tracker pages, see http://forum.yacy-websuche.de/viewtopic.php?f=5&t=456 * removed duplicate code (mostly related to the big changes above). TODO: - make sure, number formats work as expected _everywhere_, report overseen stuff http://forum.yacy-websuche.de/viewtopic.php?f=5&t=437 - probably a good idea to add special putDate() methods as they are used in many pages and create duplicated formatting code + maybe some centralized handling for memory value formatting. - further improve the speed of page creation for the WatchCrawler. git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@4178 6c8d7289-2bf4-0310-a012-ef5d649a1542
18 years ago
prop.put("urlmaskoptions", "0");
prop.putHTML("urlmaskoptions_urlmaskfilter", ".*");
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<String, String> map, final String prefix, final String attrExtension) {
prop.put("attr" + attrExtension, map.size());
String key;
int i, j = 0;
for (final Entry<String, String> entry: map.entrySet()) {
key = entry.getKey();
prop.put("attr" + attrExtension + "_" + j + "_name", rankingParameters.get(key.substring(prefix.length())));
prop.put("attr" + attrExtension + "_" + j + "_nameorg", key);
prop.put("attr" + attrExtension + "_" + j + "_select", maxRankingRange);
for (i=0; i<maxRankingRange; i++) {
prop.put("attr" + attrExtension + "_" + j + "_select_" + i + "_nameorg", key);
prop.put("attr" + attrExtension + "_" + j + "_select_" + i + "_value", i);
try {
prop.put("attr" + attrExtension + "_" + j + "_select_" + i + "_checked",
(i == Integer.valueOf(entry.getValue()).intValue()) ? "1" : "0");
} catch (final NumberFormatException e) {
* Complete number localization and provide a more reasonable interface to serverObjects: - put(key, value) methods are now used if a value added to the map should be kept as it is. Numbers are transformed (but not formatted) to an equivalent String representation. - putASIS(...) have been removed, now done with simple put(...) (see above). - puNum(...) can be used for number values which should be stored in a formatted way, either depending on the current locale setting for yacy (default) or in a "none" locale (see javadocs and setLocalize()). - putHTML(...) escapes special characters into corresponding HTML enities ('<' => '&lt;') which was done with put(...) before and so was called too often, becauses it is necessary only for very few cases. Additionally there is a "forXML" mode which only replaces < > & ". In short: Use put(...) for almost everything, use putXY(...) if you need some special transformation of the value. A few bugs have been fixed as well, and there should be a small performance improvement for complex pages with a lot of values. * added additional Sum/Avg rows to access tracker pages, see http://forum.yacy-websuche.de/viewtopic.php?f=5&t=456 * removed duplicate code (mostly related to the big changes above). TODO: - make sure, number formats work as expected _everywhere_, report overseen stuff http://forum.yacy-websuche.de/viewtopic.php?f=5&t=437 - probably a good idea to add special putDate() methods as they are used in many pages and create duplicated formatting code + maybe some centralized handling for memory value formatting. - further improve the speed of page creation for the WatchCrawler. git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@4178 6c8d7289-2bf4-0310-a012-ef5d649a1542
18 years ago
prop.put("attr" + attrExtension + "_" + j + "_select_" + i + "_checked", "0");
}
}
prop.put("attr" + attrExtension + "_" + j + "_value",
Integer.valueOf(map.get(key)).intValue());
j++;
}
}
removed the indexing queue. This queue was superfluous since the introduction of the blocking queues last year, where documents are parsed, analysed and stored in the index with concurrency. - The indexing queue was a historic data structure that was introduced at the very beginning at the project as a part of the switchboard organisation object structure. Without the indexing queue the switchboard queue becomes also superfluous. It has been removed as well. - Removing the switchboard queue requires that all servlets are called without a opaque generic ('<?>'). That caused that all serlets had to be modified. - Many servlets displayed the indexing queue or the size of that queue. In the past months the indexer was so fast that mostly the indexing queue appeared empty, so there was no use of it any more. Because the queue has been removed, the display in the servlets had also to be removed. - The surrogate work task had been a part of the indexing queue control structure. Without the indexing queue the surrogates needed its own task management. That has been integrated here. - Because the indexing queue had a special queue entry object and properties attached to this object, the propterties had to be moved to the queue entry object which is part of the new indexing queue withing the blocking queue, the Response Object. That object has now also the new properties of the removed indexing queue entry object. git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@6225 6c8d7289-2bf4-0310-a012-ef5d649a1542
16 years ago
public static serverObjects respond(final httpRequestHeader header, final serverObjects post, final serverSwitch env) {
final plasmaSwitchboard sb = (plasmaSwitchboard) env;
// clean up all search events
QueryEvent.cleanupEvents(true);
// case if no values are requested
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(QueryParams.CONTENTDOM_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()));
final serverObjects prop = defaultValues();
//prop.putAll(ranking.toExternalMap("local"));
putRanking(prop, ranking, "local");
return prop;
}
if (post.containsKey("ResetRanking")) {
sb.setConfig("rankingProfile", "");
final RankingProfile ranking = new RankingProfile(QueryParams.CONTENTDOM_TEXT);
final serverObjects prop = defaultValues();
//prop.putAll(ranking.toExternalMap("local"));
putRanking(prop, ranking, "local");
return prop;
}
final RankingProfile localRanking = new RankingProfile("local", post.toString());
final serverObjects prop = new serverObjects();
putRanking(prop, localRanking, "local");
prop.putAll(localRanking.toExternalMap("local"));
return prop;
}
}