Do you have any other cameras or lenses that might make this part of a system? If you already have a Nikon lens, for example, the 5100 might be better.
If you are a beginner-to-intermediate photographer, then it really, seriously doesn't matter - both are excellent cameras and part of much larger systems that you can grow into. I'd buy the Canon as that's what I use, but I handled a 5100 over the weekend and it's a great little camera.