From 4ad9fc2bff4a4b868b6d0fd6b0c6c41f38282336 Mon Sep 17 00:00:00 2001 From: orbiter Date: Thu, 13 Oct 2011 00:34:52 +0000 Subject: [PATCH] new snippet strategy for search hits in metadata: show beginning of text instead of hit position git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@7999 6c8d7289-2bf4-0310-a012-ef5d649a1542 --- .../net/yacy/search/snippet/TextSnippet.java | 46 ++++++++++++------- 1 file changed, 30 insertions(+), 16 deletions(-) diff --git a/source/net/yacy/search/snippet/TextSnippet.java b/source/net/yacy/search/snippet/TextSnippet.java index 1c3a13e14..cd87959a8 100644 --- a/source/net/yacy/search/snippet/TextSnippet.java +++ b/source/net/yacy/search/snippet/TextSnippet.java @@ -53,6 +53,7 @@ import net.yacy.kelondro.util.ByteBuffer; import net.yacy.peers.RemoteSearch; import net.yacy.repository.LoaderDispatcher; import net.yacy.search.Switchboard; +import de.anomic.crawler.retrieval.Request; import de.anomic.crawler.retrieval.Response; public class TextSnippet implements Comparable, Comparator { @@ -199,6 +200,18 @@ public class TextSnippet implements Comparable, Comparator= snippetMaxLength / 4 * 3) break; + } + if (s.length() > snippetMaxLength) { s.setLength(snippetMaxLength); s.trimToSize(); } + init(url.hash(), s.length() > 0 ? s.toString() : this.line, ResultClass.SOURCE_METADATA, null); + return; + } + try { final SnippetExtractor tsr = new SnippetExtractor(sentences, queryhashes, snippetMaxLength); textline = tsr.getSnippet(); @@ -248,30 +261,31 @@ public class TextSnippet implements Comparable, Comparator