# HG changeset patch # User Paul Boddie # Date 1290465944 -3600 # Node ID 8d35240236b2a411c31a389881b4176687b236f6 # Parent d308dc25f5a2b0330d08bcb147e51eb328ee2139 Added integrity checks for appropriate term and position ordering. diff -r d308dc25f5a2 -r 8d35240236b2 iixr/terms.py --- a/iixr/terms.py Sun Nov 21 20:44:43 2010 +0100 +++ b/iixr/terms.py Mon Nov 22 23:45:44 2010 +0100 @@ -40,6 +40,9 @@ term information file. """ + if term <= self.last_term: + raise ValueError, "Term %r precedes the previous term %r." % (term, self.last_term) + # Write the prefix length and term suffix. common = len(commonprefix([self.last_term, term])) @@ -193,6 +196,10 @@ """ offset, frequency, doc_frequency = self.position_dict_writer.write_term_positions(doc_positions) + + if not frequency or not doc_frequency: + raise ValueError, "Term %r has no occurrences recorded: %r" % (term, doc_positions) + self._write_term(term, offset, frequency, doc_frequency) def close(self):