i always liked the approach of the plan9 script, bayesian in its approach (perhaps).

it is also admirably short.

-Steve