Second-order recurrent neural networks for grammatical inference