Ticket #448: test_xapian_hunspell_stemmer.py

File test_xapian_hunspell_stemmer.py, 1005 bytes (added by Evgeny Sizikov, 15 years ago)
Line 
1# -*- coding: utf-8 -*-
2
3import sys
4sys.path.insert(0, 'build/lib.linux-x86_64-2.6')
5sys.path.insert(0, 'build/lib.linux-i386-2.6')
6sys.path.insert(0, 'build/lib.linux-i586-2.6')
7sys.path.insert(0, 'build/lib.linux-i686-2.6')
8
9def main():
10 import xapian
11 from xapian_hunspell_stemmer import HunspellStem
12
13 query_parser = xapian.QueryParser()
14 stop = xapian.SimpleStopper()
15 stop.add('of')
16 stop.add('the')
17 query_parser.set_stopper(stop)
18 stem = HunspellStem('en')
19# stem = xapian.Stem('en')
20# print stem(u'gold')
21 query_parser.set_stemmer(stem)
22 query_parser.set_stemming_strategy(xapian.QueryParser.STEM_ALL)
23 for w in query_parser.parse_query("I'm afraid your patches won't actually work! But it does!"):
24 print w,
25 print
26
27 doc = xapian.Document()
28 generator = xapian.TermGenerator()
29 generator.set_document(doc)
30 generator.set_flags(xapian.TermGenerator.FLAG_SPELLING)
31 generator.set_stemmer(stem)
32
33if __name__ == '__main__':
34 main()