merge_machine/preprocess_fields_v3.py
def unique_cell_values(vs, maxListLength = 3):
	''' Returns a unique value per cell, or None as appropriate. '''
	def select_best_value(vs): 
		return None if len(vs) < 1 else sorted(vs, key = lambda v: len(v), reverse = True)[0]
	def merger_by_token_list(v1): 
		return ' '.join(v1)
	em = defaultdict(set) # an equivalence map
	for v in vs:
		if v is None or len(v) < 1: continue
		key = normalize_and_validate_phrase(v)
		if key is None: continue
		em[merger_by_token_list(v)].add(v)
	return list([select_best_value(vs) for vs in em.values()])[:maxListLength]
 Returns a unique value per cell, or None as appropriate. 
Returns a unique value per cell, or None as appropriate.
Returns a unique value per cell or None as appropriate .
def unique_cell_values(vs, maxListLength = 3):
	def select_best_value(vs): 
		return None if len(vs) < 1 else sorted(vs, key = lambda v: len(v), reverse = True)[0]
	def merger_by_token_list(v1): 
		return ' '.join(v1)
	em = defaultdict(set) 
	for v in vs:
		if v is None or len(v) < 1: continue
		key = normalize_and_validate_phrase(v)
		if key is None: continue
		em[merger_by_token_list(v)].add(v)
	return list([select_best_value(vs) for vs in em.values()])[:maxListLength]
def unique_cell_values ( vs , maxListLength = 3 ) : def select_best_value ( vs ) : return None if len ( vs ) < 1 else sorted ( vs , key = lambda v : len ( v ) , reverse = True ) [ 0 ] def merger_by_token_list ( v1 ) : return ' ' . join ( v1 ) em = defaultdict ( set ) for v in vs : if v is None or len ( v ) < 1 : continue key = normalize_and_validate_phrase ( v ) if key is None : continue em [ merger_by_token_list ( v ) ] . add ( v ) return list ( [ select_best_value ( vs ) for vs in em . values ( ) ] ) [ : maxListLength ]
Returns a unique value per cell, or None as appropriate.
Returns a unique value per cell or None as appropriate .
''' Returns a unique value per cell, or None as appropriate. ''' # an equivalence map
vs
maxListLength