'''
Created on Oct 31, 2011
@author: rodger
'''
def processFile(file):
    '''
    The parameter file is the name of a file with one or more names
    on a line. Each name is two words separated by a blank.
    Multiple names on a line are separated by a colon
    Return a list of names
    '''
    nameList = []
    for line in file:
        listNames = line.strip().split(':')
        [nameList.append(nm.split()) for nm in listNames]
    return nameList

def processFiles(numberFiles):
    ''' Given the number of files to process, assume all have
    the name "namesNUM.txt". Process all those files
    '''
    #TODO:
    
    return [ ]
        
def printFirstWithLasts(namemap):
    print "Print Unique First Names with all Last Names"      
    #TODO:






    
    
def mapNameToNumberLastNames(countmap, data):
    '''
    countmap is a map of first names to its number of occurrences
    The parameter data is a list of lists where each list is two  
    strings representing the first and last name of a person.         
    '''
    #todo:
    print







            
def  mapNameToLastNames(namemap, data):
    '''
    namemap is a map of first names to list of corresponding last names 
    The parameter data is a list of lists where each list is two  
    strings representing the first and last name of a person.    
    '''  
    #todo:
    print








def  mapNameToSetLastNames(namesetmap, data):
    '''
    namemap is a map of first names to list of corresponding last names 
    The parameter data is a list of lists where each list is two  
    strings representing the first and last name of a person.    
    '''  











def main():
    '''
    This is the code for processing one file named names1.txt
    
    fileWithNames = open("../data/names1.txt")
    namelist = processFile(fileWithNames)  
    '''
    # this is the code for processing three files
    namelist = processFiles(3)
    
    print "namelist is: ", namelist 
    print

    countmap = {}
    mapNameToNumberLastNames(countmap, namelist)
    print countmap
    
    namemap = {}
    mapNameToLastNames(namemap, namelist)
    print namemap
    
    namesetmap = {}
    mapNameToSetLastNames(namesetmap, namelist)
    print namesetmap    
         
    printFirstWithLasts(namemap)
    print
    
    #TODO: Compute maxnum    
    maxnum = 0
    
    
    
    print "maximum number of corresponding last names is ",
    print maxnum
    print
    #TODO: compute lastIndex - list of names with max number last names
    lastIndex = ["none"]
   
    
    
    
    print "first name with most last names is:"
    #TODO:
 
 
 
    
if __name__ == "__main__":
    main() 
        
     
