'Convert a word into discrete features in self.crf_features, including word before and word after.'

def _sentence_to_features(self, sentence):

    sentence_features = []
    for word_idx in range(len(sentence)):
        prefixes = [u'-1', u'0', u'+1']
        word_features = {}
        for i in range(3):
            if ((word_idx == (len(sentence) - 1)) and (i == 2)):
                word_features[u'EOS'] = True
            elif ((word_idx == 0) and (i == 0)):
                word_features[u'BOS'] = True
            else:
                word = sentence[((word_idx - 1) + i)]
                prefix = prefixes[i]
                features = self.crf_features[i]
                for feature in features:
                    word_features[((prefix + u':') + feature)] = self.function_dict[feature](word)
        sentence_features.append(word_features)
    return sentence_features
