Example #1
0
def team_name_parser(name):
  
  # give proper capitalization
  ns = ' '.join(s[:1].upper() + s[1:] for s in name.lower().split(' '))
  
  try:
    return ABB.keys()[ABB.values().index(ns)]
  except:
    #print 'UNKNOWN TEAM NAME: %s' % name
    pass
  
  return name
Example #2
0
def team_name_parser(name):
  # give proper capitalization, translate to expected team name
  # WASHINGTON CAPITALS -> Washington Capitals
  # ST. LOUIS BLUES -> St Louis Blues
  ns = ' '.join(s[:1].upper() + s[1:] for s in name.lower().replace('.','').split(' '))

  try:
    return ABB.keys()[ABB.values().index(ns)] #Reverse lookup, by value.
  except:
    #print 'UNKNOWN TEAM NAME: %s' % name
    pass

  return name
def team_name_parser(name):
  # give proper capitalization, translate to expected team name
  # WASHINGTON CAPITALS -> Washington Capitals
  # ST. LOUIS BLUES -> St Louis Blues
  ns = ' '.join(s[:1].upper() + s[1:] for s in name.lower().replace('.','').split(' '))
  
  try:
    return ABB.keys()[ABB.values().index(ns)] #Reverse lookup, by value.
  except:
    #print 'UNKNOWN TEAM NAME: %s' % name
    pass
  
  return name
Example #4
0
def get_abbreviation(team):
    good_name = re.sub(r'[\.\s\-]', '', team_name_parser(team))
    for entry in ABB.items():
        if re.sub(r'[\.\s]', '', entry[1].upper()) == good_name.upper():
            return entry[0]