Learning the syntax and semantic rules of an ECG grammar