As per my original post ..
Next time, I strongly recommend you show us how far you got, and which approaches you tried. To wax poetic for a moment, we're happy to help push you out of a ditch, but we're not going to teach you how to drive.
You're still at the conceptual stage. Tell us what you've implmented (perhaps with some Perl code), what your approach is and then tell us what part of it doesn't work for you. We're not going to break it down into logical steps for you. That's the analysis stage, and you should be able to do that yourself.
Good luck.
Alex / talexb / Toronto
"Groklaw is the open-source mentality applied to legal research" ~ Linus Torvalds