def choosecat(str, classnames):
    """ Gets a string and tries to match its category with an int. """
    for i, id in enumerate(classnames):
        if id in str:
            return i
    return None