6. A method for defining structure for a document, the method comprising: identifying pairs of nearest primitive elements in a document comprising a plurality of primitive elements that are defined in terms of their position in the document; sorting the pairs of nearest primitive elements based on an order from a pair of nearest primitive elements that are a closest distance apart to a pair of nearest primitive elements that are a furthest distance apart; storing a single value that identifies, from the sorted pairs of nearest primitive elements, a particular pair of nearest primitive elements whose primitive elements are a minimum distance apart to form a partition, wherein each pair of nearest primitive elements that are a greater distance apart than the minimum distance is after the particular pair in the order; identifying partitions between the primitive elements in the document based on the single value and the sorted pairs of nearest primitive elements; and using the partitions to define structural elements for the document.
9. The method of claim 6 , wherein storing the single value comprises storing a plurality of single values that each identify different pairs of nearest primitive elements whose primitive elements are different minimum distances apart to form partitions.