tweak training so that it takes in a parser object