in reply to Find a good starting section of a long text

I'd develop weighted tests for each condition. Count chars for paragraphs ending shorter ($par_short) and longer ($par_long) than $goal. Do the same for sentences ($sen_short and $sen_long) and words ($word_short, $word_long).

Then use the minimum of ( ($goal - $test) * 1/$weight ) ** 2

Tuning the weight of the tests requires looking at sample data, but (30, 15, 5) for par, sen and word should be a start. The given example weights a paragraph deviating by 30 chars from $goal the same as a word deviating 5 chars.

  • Comment on Re: Find a good starting section of a long text