示例#1
0
def attempt_merge(a, m, threshold, debug = False):
    l1 = amazon.level1_merge(a, m)
    total = sum(i[2] for i in l1)
    if debug:
        print total, l1
    if total >= threshold:
        return True
    l2 = amazon.level2_merge(a, m)
    total = sum(i[2] for i in l2)
    if debug:
        print total, l2
    return total >= threshold
示例#2
0
def attempt_merge(a, m, threshold, debug = False):
    l1 = amazon.level1_merge(a, m)
    total = sum(i[2] for i in l1)
    if debug:
        print(total, l1)
    if total >= threshold:
        return True
    l2 = amazon.level2_merge(a, m)
    total = sum(i[2] for i in l2)
    if debug:
        print(total, l2)
    return total >= threshold
示例#3
0
    def compare(self, editions):
        key1 = editions[0]["key"]
        key2 = editions[1]["key"]
        try:
            (rec_amazon, rec_marc) = amazon_and_marc(key1, key2)
        except AssertionError:
            yield "must be one amazon and one marc edition"
            return
        yield "<h2>Level 1</h2>"
        l1 = merge_amazon.level1_merge(rec_amazon, rec_marc)
        for i in self.field_table(l1, rec_amazon, rec_marc):
            yield i

        yield "<h2>Level 2</h2>"
        l2 = merge_amazon.level2_merge(rec_amazon, rec_marc)
        for i in self.field_table(l2, rec_amazon, rec_marc):
            yield i
示例#4
0
文件: bot.py 项目: zgruza/openlibrary
    def amazon_compare(self, editions):
        key1 = editions[0]['key']
        key2 = editions[1]['key']
        try:
            (rec_amazon, rec_marc) = amazon_and_marc(key1, key2)
        except AssertionError:
            yield 'must be one amazon and one marc edition'
            return
        yield '<h2>Level 1</h2>'
        l1 = merge_amazon.level1_merge(rec_amazon, rec_marc)
        for i in self.field_table(l1, rec_amazon, rec_marc):
            yield i

        yield '<h2>Level 2</h2>'
        l2 = merge_amazon.level2_merge(rec_amazon, rec_marc)
        for i in self.field_table(l2, rec_amazon, rec_marc):
            yield i