Пример #1
0
def get_most_frequent_name_from_pid(person_id= -1):
    '''
    Finds the most frequent name of a person to be
    representative for this person.

    @param person_id: the person ID to look at
    @type person_id: int

    @return: returns the most frequent normalized name of a person
    @rtype: string
    '''
    if (not person_id > -1) or (not isinstance(person_id, int)):
        return "'%s' doesn't look like a person ID!" % person_id

    mf_name = ""

    try:
        nn = tu.get_person_names_count((person_id,))
        mf_name = sorted(nn, key=lambda k:k[1], reverse=True)[0][0]
    except IndexError:
        pass

    if mf_name:
        return mf_name
    else:
        return "This person does not seem to have a name!"
Пример #2
0
def get_person_names_from_id(person_id= -1):
    '''
    Finds and returns the names associated with this person along with the
    frequency of occurrence (i.e. the number of papers)

    @param person_id: an id to find the names for
    @type person_id: int

    @return: name and number of occurrences of the name
    @rtype: tuple of tuple
    '''
#    #retrieve all rows for the person
    if (not person_id > -1) or (not isinstance(person_id, int)):
        return []

    return tu.get_person_names_count((person_id,))
Пример #3
0
def get_longest_name_from_pid(person_id= -1):
    '''
    Finds the longest name of a person to be representative for this person.

    @param person_id: the person ID to look at
    @type person_id: int

    @return: returns the longest normalized name of a person
    @rtype: string
    '''
    if (not person_id > -1) or (not isinstance(person_id, int)):
        return "This doesn't look like a person ID!"

    longest_name = ""

    for name in tu.get_person_names_count((person_id,)):
        if name and len(name[0]) > len(longest_name):
            longest_name = name[0]

    if longest_name:
        return longest_name
    else:
        return "This person does not seem to have a name!"