def test_author_contrib(self):
        rec1 = {
            'authors': [
                {'db_name': 'Bruner, Jerome S.',
                 'name': 'Bruner, Jerome S.'}],
            'full_title': ('Contemporary approaches to cognition '
                           'a symposium held at the University of Colorado.'),
            'number_of_pages': 210,
            'publish_country': 'xxu',
            'publish_date': '1957',
            'publishers': ['Harvard U.P']}

        rec2 = {
            'authors': [
                {'db_name': ('University of Colorado (Boulder campus). '
                             'Dept. of Psychology.'),
                 'name': ('University of Colorado (Boulder campus). '
                          'Dept. of Psychology.')}],
            'contribs': [
                {'db_name': 'Bruner, Jerome S.',
                 'name': 'Bruner, Jerome S.'}],
            'full_title': ('Contemporary approaches to cognition '
                           'a symposium held at the University of Colorado'),
            'lccn': ['57012963'],
            'number_of_pages': 210,
            'publish_country': 'mau',
            'publish_date': '1957',
            'publishers': ['Harvard University Press']}

        e1 = build_marc(rec1)
        e2 = build_marc(rec2)

        assert compare_authors(e1, e2) == ('authors', 'exact match', 125)
        threshold = 875
        assert editions_match(e1, e2, threshold) is True
def test_merge():
    bpl = {'authors': [{'birth_date': u'1897',
                      'db_name': u'Green, Constance McLaughlin 1897-',
                      'entity_type': 'person',
                      'name': u'Green, Constance McLaughlin',
                      'personal_name': u'Green, Constance McLaughlin'}],
         'full_title': u'Eli Whitney and the birth of American technology',
         'isbn': [u'188674632X'],
         'normalized_title': u'eli whitney and the birth of american technology',
         'number_of_pages': 215,
         'publish_date': '1956',
         'publishers': [u'HarperCollins', u'[distributed by Talman Pub.]'],
         'short_title': u'eli whitney and the birth',
         'source_record_loc': 'bpl101.mrc:0:1226',
         'titles': [u'Eli Whitney and the birth of American technology',
                    u'eli whitney and the birth of american technology']}
    lc = {'authors': [{'birth_date': u'1897',
                     'db_name': u'Green, Constance McLaughlin 1897-',
                     'entity_type': 'person',
                     'name': u'Green, Constance McLaughlin',
                     'personal_name': u'Green, Constance McLaughlin'}],
        'full_title': u'Eli Whitney and the birth of American technology.',
        'isbn': [],
        'normalized_title': u'eli whitney and the birth of american technology',
        'number_of_pages': 215,
        'publish_date': '1956',
        'publishers': ['Little, Brown'],
        'short_title': u'eli whitney and the birth',
        'source_record_loc': 'marc_records_scriblio_net/part04.dat:119539872:591',
        'titles': [u'Eli Whitney and the birth of American technology.',
                   u'eli whitney and the birth of american technology']}

    assert compare_authors(bpl, lc) == ('authors', 'exact match', 125)
    threshold = 875
    assert attempt_merge(bpl, lc, threshold) is True
    def test_compare_authors_by_statement(self):
        # requires db_name to be present on both records.
        rec1 = {
            'full_title': 'Full Title, required',
            'authors': [{
                'name': 'Alistair Smith',
                'db_name': 'Alistair Smith'}]}
        rec2 = {
            'full_title': 'A different Full Title, only matching authors here.',
            'authors': [{
                'db_name': 'National Gallery (Great Britain)',
                'name': 'National Gallery (Great Britain)',
                'entity_type': 'org'}],
            'by_statement': 'Alistair Smith.'}

        result = compare_authors(build_marc(rec1), build_marc(rec2))
        assert result == ('main', 'exact match', 125)
def test_compare_authors_by_statement():
    # requires db_name to be present on both records.
    rec1 = {
            'full_title': 'Full Title, required',
            'authors': [{
                'name': 'Alistair Smith',
                'db_name': 'Alistair Smith'}]}
    rec2 = {
            'full_title': 'A different Full Title, only matching authors here.',
            'authors': [{
                'db_name': u'National Gallery (Great Britain)',
                'name': u'National Gallery (Great Britain)',
                'entity_type': 'org'}],
            'by_statement': 'Alistair Smith.'}

    result = compare_authors(build_marc(rec1), build_marc(rec2))
    # This expected result taken from the amazon and merge versions of compare_author,
    # Current merge_marc.compare_authors() does not take by_statement into account.
    assert result == ('main', 'exact match', 125)
Beispiel #5
0
    def test_match_without_ISBN(self):
        # Same year, different publishers
        # one with ISBN, one without
        bpl = {
            'authors': [{
                'birth_date': '1897',
                'db_name': 'Green, Constance McLaughlin 1897-',
                'entity_type': 'person',
                'name': 'Green, Constance McLaughlin',
                'personal_name': 'Green, Constance McLaughlin',
            }],
            'full_title':
            'Eli Whitney and the birth of American technology',
            'isbn': ['188674632X'],
            'normalized_title':
            'eli whitney and the birth of american technology',
            'number_of_pages':
            215,
            'publish_date':
            '1956',
            'publishers': ['HarperCollins', '[distributed by Talman Pub.]'],
            'short_title':
            'eli whitney and the birth',
            'source_record_loc':
            'bpl101.mrc:0:1226',
            'titles': [
                'Eli Whitney and the birth of American technology',
                'eli whitney and the birth of american technology',
            ],
        }
        lc = {
            'authors': [{
                'birth_date': '1897',
                'db_name': 'Green, Constance McLaughlin 1897-',
                'entity_type': 'person',
                'name': 'Green, Constance McLaughlin',
                'personal_name': 'Green, Constance McLaughlin',
            }],
            'full_title':
            'Eli Whitney and the birth of American technology.',
            'isbn': [],
            'normalized_title':
            'eli whitney and the birth of american technology',
            'number_of_pages':
            215,
            'publish_date':
            '1956',
            'publishers': ['Little, Brown'],
            'short_title':
            'eli whitney and the birth',
            'source_record_loc':
            'marc_records_scriblio_net/part04.dat:119539872:591',
            'titles': [
                'Eli Whitney and the birth of American technology.',
                'eli whitney and the birth of american technology',
            ],
        }

        assert compare_authors(bpl, lc) == ('authors', 'exact match', 125)
        threshold = 875
        assert editions_match(bpl, lc, threshold) is True