1.1 --- a/test.py Thu Aug 27 00:02:50 2009 +0200
1.2 +++ b/test.py Thu Aug 27 20:52:48 2009 +0200
1.3 @@ -192,29 +192,17 @@
1.4 ("sea", [(36, [2, 6])])
1.5 ]
1.6
1.7 -f = open("test", "wb")
1.8 -w = iixr.TermWriter(f)
1.9 -f2 = open("testI", "wb")
1.10 -w2 = iixr.TermIndexWriter(f2)
1.11 -f3 = open("testP", "wb")
1.12 -w3 = iixr.PositionWriter(f3)
1.13 -wd = iixr.TermDictionaryWriter(w, w2, w3, 3)
1.14 -wi = iixr.IndexWriter(wd)
1.15 +index = iixr.Index("test_index")
1.16 +wi = index.get_writer(3)
1.17 for docnum, text in docs:
1.18 for position, term in enumerate(text.split()):
1.19 wi.add_position(term, docnum, position)
1.20 wi.close()
1.21
1.22 -f = open("test", "rb")
1.23 -r = iixr.TermReader(f)
1.24 -f2 = open("testI", "rb")
1.25 -r2 = iixr.TermIndexReader(f2)
1.26 -f3 = open("testP", "rb")
1.27 -r3 = iixr.PositionReader(f3)
1.28 -rd = iixr.TermDictionaryReader(r, r2, r3)
1.29 +rd = index.get_reader()
1.30 for term, doc_positions in doc_tests:
1.31 dp = rd.find_positions(term)
1.32 print doc_positions == dp, doc_positions, dp
1.33 -rd.close()
1.34 +index.close()
1.35
1.36 # vim: tabstop=4 expandtab shiftwidth=4