Learning Flexible Features for Conditional Random Fields