[Xapian-devel] patch - add SnippetGenerator class
Greg Banks
gnb at fastmail.fm
Wed Mar 13 05:56:44 GMT 2013
G'day,
This is some code which have been using for some time now in our
searching beta, forward ported from 1.2.12 to today's git. It adds a
class Xapian::SnippetGenerator which can be used to generate
human-readable snippet strings. By default, the snippets are HTML
formatted, with the matched search term inside a <b> tag, 5 words of
context around matched search terms, and ellipsis "..." between
non-adjacent context.
There is a certain amount of code duplication with the TermGenerator
class, which is ugly but I considered preferable to major surgery to
separate out the various parsing phases of TermGenerator so that some of
them could be re-used for SnippetGenerator. Sorry.
Yes, I know there is a GSOC project to add snippets to Xapian. That
code did not appear to be stable when I needed it, so I wrote my own.
Perhaps it might be useful to someone.
--
Greg.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: xapian-add-snippet-generator.patch
Type: text/x-patch
Size: 33621 bytes
Desc: not available
URL: <http://lists.xapian.org/pipermail/xapian-devel/attachments/20130313/0bbbf858/attachment-0001.bin>
More information about the Xapian-devel
mailing list