1. A method for parsing a semi-structured document having a plurality of document lines on which a series of items are listed, the listing of each item spanning one or more document lines, said method comprising: obtaining a plurality of candidate records, each candidate record spanning one or more lines of the document; defining a term representing an optimal cost of selecting a number n of candidate records to span the document lines up to a given ending document line i; efficiently evaluating the term over a first range of values for n and a second range of values for i; and selecting a subset of the plurality of candidate records as a global optimal parse of the document, wherein the subset selected is based on the evaluation of the term.