Add Rule matching and applying.

Script can now match rules against a file and succesfully substitute
keywords with their tags. All that is needed is to actually write the
new files.