pattern analysis

Look here. It ca be very close to what you need.