Document understanding by extracting the logical structure