Well... you take a grammatical book and start reading the string letter by letter if one of the rules there is matched then you add a +1 to a counter. Since the rules differ from language to language I can't really tell you how to do it. I did it for Romanian... but I doubt it will help you.