added a snippet marking

(search words are now bold in snippets)

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@1823 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
orbiter 19 years ago
parent bfec51969d
commit bae3783d38

@ -62,7 +62,6 @@
<tr><td class="MenuItem">&nbsp;<img border="0" src="/env/grafics/lock.gif" align="top">&nbsp;<a href="/ViewLog_p.html" class="MenuItemLink">Log</a></td></tr>
<tr><td class="MenuItem">&nbsp;<img border="0" src="/env/grafics/lock.gif" align="top">&nbsp;<a href="/PerformanceQueues_p.html" class="MenuItemLink">Performance</a></td></tr>
<tr><td class="MenuItem">&nbsp;<img border="0" src="/env/grafics/lock.gif" align="top">&nbsp;<a href="/Connections_p.html" class="MenuItemLink">Connections</a></td></tr>
<tr><td class="MenuItem">&nbsp;<img border="0" src="/env/grafics/lock.gif" align="top">&nbsp;<a href="/Skins_p.html" class="MenuItemLink">Skins</a></td></tr>
<tr><td class="MenuSpacer"></td></tr>
<tr><td class="MenuHeader">&nbsp;The Project</td></tr>

@ -40,11 +40,11 @@ public class snippet {
Set queryHashes = plasmaSearchQuery.words2hashes(query);
plasmaSnippetCache.result snippet = switchboard.snippetCache.retrieve(url, queryHashes, true, 260);
prop.put("status",snippet.source);
if (snippet.source < 11) {
prop.put("text", (snippet.line != null)?snippet.line.trim():"unknown");
prop.put("status",snippet.getSource());
if (snippet.getSource() < 11) {
prop.put("text", (snippet.exists()) ? snippet.getLineMarked(queryHashes) : "unknown");
} else {
prop.put("text", (snippet.error != null)?snippet.error.trim():"unkown");
prop.put("text", snippet.getError());
}
prop.put("urlHash",plasmaURL.urlHash(url));

@ -137,13 +137,13 @@ public final class search {
while ((acc.hasMoreElements()) && (i < squery.wantedResults)) {
urlentry = acc.nextElement();
snippet = sb.snippetCache.retrieve(urlentry.url(), squery.queryHashes, false, 260);
if (snippet.source == plasmaSnippetCache.ERROR_NO_MATCH) {
if (snippet.getSource() == plasmaSnippetCache.ERROR_NO_MATCH) {
// suppress line: there is no match in that resource
} else {
if (snippet.line == null) {
resource = urlentry.toString();
if (snippet.exists()) {
resource = urlentry.toString(snippet.getLineRaw());
} else {
resource = urlentry.toString(snippet.line);
resource = urlentry.toString();
}
if (resource != null) {
links.append("resource").append(i).append("=").append(resource).append(serverCore.crlfString);

@ -95,16 +95,48 @@ public class plasmaSnippetCache {
}
public class result {
public String line;
public String error;
public int source;
private String line;
private String error;
private int source;
public result(String line, int source, String errortext) {
this.line = line;
this.source = source;
this.error = errortext;
}
public boolean exists() {
return line != null;
}
public String toString() {
return line;
return (line == null) ? "" : line;
}
public String getLineRaw() {
return (line == null) ? "" : line;
}
public String getError() {
return (error == null) ? "" : error.trim();
}
public String getLineMarked(Set queryHashes) {
if (line == null) return "";
if ((queryHashes == null) || (queryHashes.size() == 0)) return line.trim();
if (line.endsWith(".")) line = line.substring(0, line.length() - 1);
Iterator i = queryHashes.iterator();
String h;
String[] w = line.split(" ");
while (i.hasNext()) {
h = (String) i.next();
for (int j = 0; j < w.length; j++) {
if (plasmaWordIndexEntry.word2hash(w[j]).equals(h)) w[j] = "<b>" + w[j] + "</b>";
}
}
StringBuffer l = new StringBuffer(line.length() + queryHashes.size() * 8);
for (int j = 0; j < w.length; j++) {
l.append(w[j]);
l.append(' ');
}
return l.toString().trim();
}
public int getSource() {
return source;
}
}

@ -1855,7 +1855,7 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements ser
//addScoreForked(ref, gs, urlstring.split("/"));
if (urlstring.matches(query.urlMask)) { //.* is default
snippet = snippetCache.retrieve(url, query.queryHashes, false, 260);
if (snippet.source == plasmaSnippetCache.ERROR_NO_MATCH) {
if (snippet.getSource() == plasmaSnippetCache.ERROR_NO_MATCH) {
// suppress line: there is no match in that resource
} else {
prop.put("results_" + i + "_delete", "/yacysearch.html?search=" + formerSearch + "&Enter=Search&count=" + query.wantedResults + "&order=" + ranking.orderString() + "&resource=local&time=3&deleteref=" + urlhash + "&urlmaskfilter=.*");
@ -1869,12 +1869,12 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements ser
prop.put("results_" + i + "_size", Long.toString(urlentry.size()));
prop.put("results_" + i + "_words",URLEncoder.encode(query.queryWords.toString(),"UTF-8"));
// adding snippet if available
if (snippet.line == null) {
if (snippet.exists()) {
prop.put("results_" + i + "_snippet", 1);
prop.put("results_" + i + "_snippet_text", snippet.getLineMarked(query.queryHashes));
} else {
prop.put("results_" + i + "_snippet", 0);
prop.put("results_" + i + "_snippet_text", "");
} else {
prop.put("results_" + i + "_snippet", 1);
prop.put("results_" + i + "_snippet_text", snippet.line.trim());
}
i++;
}

Loading…
Cancel
Save