def changeset_sentence(cset): """Take a changeset object and return a sentence""" user = elements.get_user(cset) # A future version will actually look at the action types action = 'edited' eles = [] for i in cset['actions']: eles.extend(i[1]) ele_features = zip(eles, db.matchEach(eles)) sorted_ef = elements.sort_by_num_features(ele_features) grouped_features = elements.feature_grouper(sorted_ef) sorted_features = elements.sort_grouped(grouped_features) english_list = elements.grouped_to_english(sorted_features) return "%s %s %s" % (user, action, english_list)
def changeset_sentence(cset): """Take a changeset object and return a sentence""" # Future versions will be able to handle multiple users #user = elements.get_user(cset) user = cset['user'] # A future version will do more complex action grouping eles = cset['elements'] actions = Set() for action, action_elements in cset['actions']: actions.add(action) if len(actions) == 1: action = 'edited'#action_hash[actions.pop()] else: action = 'edited' ele_features = zip(eles, db.matchEach(eles)) sorted_ef = elements.sort_by_num_features(ele_features) grouped_features = elements.feature_grouper(sorted_ef) sorted_features = elements.sort_grouped(grouped_features) english_list = elements.grouped_to_english(sorted_features) return "%s %s" % (action, english_list)
def changeset_sentence(cset): """Take a changeset object and return a sentence""" # Future versions will be able to handle multiple users #user = elements.get_user(cset) user = cset['user'] # A future version will do more complex action grouping eles = cset['elements'] actions = Set() for action, action_elements in cset['actions']: actions.add(action) if len(actions) == 1: action = 'edited' #action_hash[actions.pop()] else: action = 'edited' ele_features = zip(eles, db.matchEach(eles)) sorted_ef = elements.sort_by_num_features(ele_features) grouped_features = elements.feature_grouper(sorted_ef) sorted_features = elements.sort_grouped(grouped_features) english_list = elements.grouped_to_english(sorted_features) return "%s %s" % (action, english_list)