a fix for the snippet computation and hopefully better snippets

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@7701 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
orbiter 14 years ago
parent deda54d684
commit 76f2817e00

@ -397,7 +397,7 @@ public class ResultFetcher {
snippetFetchWordHashes,
null,
((query.constraint != null) && (query.constraint.get(Condenser.flag_cat_indexof))),
180,
220,
Integer.MAX_VALUE,
!query.isLocal());
return new ResultEntry(page, query.getSegment(), peers, snippet, null, dbRetrievalTime, 0); // result without snippet

@ -159,8 +159,7 @@ public class SnippetExtractor {
" [..] " +
sentence.substring((maxpos + 26 > sentence.length()) ? sentence.length() : maxpos + 26).trim();
maxpos = maxpos + lenb - sentence.length() + 6;
}
if (maxpos > maxLength) {
} else if (maxpos > maxLength) {
// the string is too long, even if we cut it at the end
// so cut it here at both ends at once
assert maxpos >= minpos;
@ -174,11 +173,11 @@ public class SnippetExtractor {
}
if (sentence.length() > maxLength) {
// trim sentence, 1st step (cut at right side)
sentence = sentence.substring(0, maxpos).trim() + " [..]";
sentence = sentence.substring(0, Math.min(maxpos + 20, sentence.length())).trim() + " [..]";
}
if (sentence.length() > maxLength) {
// trim sentence, 2nd step (cut at left side)
sentence = "[..] " + sentence.substring(minpos).trim();
sentence = "[..] " + sentence.substring(Math.max(minpos - 20, 0)).trim();
}
if (sentence.length() > maxLength) {
// trim sentence, 3rd step (cut in the middle)

Loading…
Cancel
Save