| Sure! In very broad strokes: First, download yourself a copy of Google's diff-match-patch. Second, make a template for the email you have (think "Your shipment will be delivered {{date}}. Thank you!" vs. the original raw email "Your shipment will be delivered 2014-04-04. Thank you!"). Third, run it through diff-match-patch. Forth, walk over the change tree and record the insertion (1), a deletion (-1) or equality (0) transformations (one as keys the other as values). (There are a lot of edge cases to handle between the forth and fifth step, but test cases make those pretty obvious (if not very frustrating.) Fifth, collate the keys/values into a dictionary and do some last minute cleanups. We will be documenting a REST API so you can use parser.zapier.com directly, and it is pretty easy to forward emails automatically to our robot (so you can conceivably avoid writing anything at all and just use the app). |