示例#1
0
def compare_authors(amazon, marc):
    if len(amazon['authors']) == 0 and 'authors' not in marc:
        return ('main', 'no authors', 75)
    if len(amazon['authors']) == 0:
        return ('main', 'field missing from one record', -25)

    for name in amazon['authors']:
        if 'authors' in marc and match_name(name, marc['authors'][0]['name']):
            return ('main', 'exact match', 125)
        if 'by_statement' in marc and marc['by_statement'].find(name) != -1:
            return ('main', 'exact match', 125)
    if 'authors' not in marc:
        return ('main', 'field missing from one record', -25)

    max_score = 0
    for a in amazon['authors']:
        percent, ordered = keyword_match(a[0], marc['authors'][0]['name'])
        if percent > 0.50:
            score = percent * 80
            if ordered:
                score += 10
            if score > max_score:
                max_score = score
    if max_score:
        return ('main', 'keyword match', max_score)
    else:
        return ('main', 'mismatch', -200)
示例#2
0
def compare_authors(amazon, marc):
    if len(amazon['authors']) == 0 and 'authors' not in marc:
        return ('main', 'no authors', 75)
    if len(amazon['authors']) == 0:
        return ('main', 'field missing from one record', -25)

    for name in amazon['authors']:
        if 'authors' in marc and match_name(name, marc['authors'][0]['name']):
            return ('main', 'exact match', 125)
        if 'by_statement' in marc and marc['by_statement'].find(name) != -1:
            return ('main', 'exact match', 125)
    if 'authors' not in marc:
        return ('main', 'field missing from one record', -25)

    max_score = 0
    for a in amazon['authors']:
        percent, ordered = keyword_match(a[0], marc['authors'][0]['name'])
        if percent > 0.50:
            score = percent * 80
            if ordered:
                score += 10
            if score > max_score:
                max_score = score
    if max_score:
        return ('main', 'keyword match', max_score)
    else:
        return ('main', 'mismatch', -200)
示例#3
0
def check(i, j):
    assert names.match_name(i, j)
示例#4
0
def check(i, j):
    assert names.match_name(i, j)
示例#5
0
def test_names(amazon, marc):
    assert names.match_name(amazon, marc)