1.1 --- a/iixr/phrases.py Sat Nov 20 00:00:01 2010 +0100
1.2 +++ b/iixr/phrases.py Sat Nov 20 00:01:14 2010 +0100
1.3 @@ -4,7 +4,7 @@
1.4 Phrase iterators providing navigation over common positions for a number of
1.5 different terms.
1.6
1.7 -Copyright (C) 2009 Paul Boddie <paul@boddie.org.uk>
1.8 +Copyright (C) 2009, 2010 Paul Boddie <paul@boddie.org.uk>
1.9
1.10 This program is free software; you can redistribute it and/or modify it under
1.11 the terms of the GNU General Public License as published by the Free Software
1.12 @@ -168,6 +168,8 @@
1.13 raise StopIteration
1.14
1.15 def is_phrase_position(self, last, last_token, current, current_token):
1.16 - return current - last <= 1 and current_token > last_token
1.17 + last_position, last_preceding = last
1.18 + position, preceding = current
1.19 + return position - last_position <= 1 and current_token > last_token
1.20
1.21 # vim: tabstop=4 expandtab shiftwidth=4
2.1 --- a/iixr/positions.py Sat Nov 20 00:00:01 2010 +0100
2.2 +++ b/iixr/positions.py Sat Nov 20 00:01:14 2010 +0100
2.3 @@ -19,7 +19,7 @@
2.4 """
2.5
2.6 from iixr.files import *
2.7 -from iixr.data import vint, vint_to_array
2.8 +from iixr.data import vint, vint_to_array, string_to_array
2.9 from array import array
2.10
2.11 class PositionWriter(FileWriter):
2.12 @@ -53,8 +53,11 @@
2.13
2.14 last = 0
2.15
2.16 - for position in positions:
2.17 + # Handle tuples incorporating preceding text.
2.18 +
2.19 + for position, preceding in positions:
2.20 vint_to_array(position - last, output)
2.21 + string_to_array(preceding, output)
2.22 last = position
2.23
2.24 output.tofile(self.f)
2.25 @@ -89,7 +92,8 @@
2.26
2.27 while i < npositions:
2.28 last += self.read_number()
2.29 - positions.append(last)
2.30 + preceding = self.read_string()
2.31 + positions.append((last, preceding))
2.32 i += 1
2.33
2.34 return self.last_docnum, positions