headline() produces text fragments with query terms to help users identify search results. It's tempting to use extents, which we already use to compute ranks.
We want headline to be informative, so extents should be dense (more query terms in shorter text) and dispersed (more different query terms). Heuristics: