def feature_extractor(X): template.apply(X, templates) if X: X[0]['F'].append('__BOS__') X[-1]['F'].append('__EOS__')