Proximity Metrics For Contextual Pattern Recognition