It is not so hard, because dative and accusative are always very different:
- With bestimmten Artikel, there is always difference (den-dem, die-der, das-dem, die-den). Similarly with unbestimmten Artikel (einen-einem, eine-einer, ein-einem, keine-keinen).
- In the case of pronouns, there is also a very visible difference (dich-dir, sie-ihr, etc)
On the first spot, this whole thing is not very hard. We have around 3 4x4 matrices (plus the pronouns, but also they are similar). The problem is that these to automatize... well... it can take years, even if your first language has much bigger ones. It is a big mistery of the language.
If I understand German sentences, I don't take care about what is dative or accusative. I simply decode the text from the meaning of the words. To identify Angehörigkeitrelationen ("of") is much more important, but it is also very characteristic.
To synthetise these structures, it is more easy to learn as realtime decoding them.
I think German is the best algorithmizable language I know, but this is also a reason, why is it a big win if you don't write code for that, instead develop this tool in your own mind. Look for complex sentences written by native speakers and decode some them.