metric learning and information retrieval
Conditional Random Fields (CRFs) can be used for segmenting/labeling sequential problems. Try CRF++: Yet Another CRF toolkit,  a simple, customizable, and open source implementation of Conditional Random Fields (CRFs) 

You can label and create a tagged training corpus and use CRF++ 

You also need to create a feature template

Refer : http://taku910.github.io/crfpp/ for more details. 

Check the example from data for CoNLL shared task (PoS tagging).