1. a document processor comprising: a classifier that classifies fragments of an input document respective to a set of terminal elements; a probabilistic grammar defining transformation rules operating on elements selected from the set of terminal elements and a set of non-terminal elements; and a parser that defines a parsed document structure associating the input document fragments with terminal elements connected by links of non-terminal elements conforming with the probabilistic grammar, the parsed document structure being used to organize the input document.