<commit_before>import Business
import sys
import json
import distances

class Matcher:
    def __init__(self, filename1, filename2):
        self.data1 = self.create_collection(filename1)
        self.data2 = self.create_collection(filename2)

    def create_collection(file_name):
        f = open(file_name)
        data = json.load(f)
        biz_col = []
        for d in data:
            biz = Business.Business(d)
            biz_col.append(biz)
        f.close()
        return biz_col

    def find_matches(self, threshold, score):
        matches = []
        for datum1 in self.data1:
            for datum2 in self.data2:
                if score.similarity(datum1, datum2) > threshold:
                    matches.append((datum1, datum2))
        return matches

    def print_matches(self, threshold, score):
        matches = self.find_matches(threshold, score)
        for match in matches:
            print match[0].attr.id + ", " match[1].attr.id

class Score:
    # weighted_distances is a hash. Key is the distance class and
    # value is the weight.
    def __init__(self, weighted_distances):
        self.weighted_distances

    def similarity(self, datum1, datum2):
        score = 0
        total_weight = 0
        for distance, weight in self.weighted_distances.iteritems():
            dist = distance.distance(datum1, datum2)<commit_msg>Correcting a typo.<commit_after>import Business
import sys
import json
import distances

class Matcher:
    def __init__(self, filename1, filename2):
        self.data1 = self.create_collection(filename1)
        self.data2 = self.create_collection(filename2)

    def create_collection(file_name):
        f = open(file_name)
        data = json.load(f)
        biz_col = []
        for d in data:
            biz = Business.Business(d)
            biz_col.append(biz)
        f.close()
        return biz_col

    def find_matches(self, threshold, score):
        matches = []
        for datum1 in self.data1:
            for datum2 in self.data2:
                if score.similarity(datum1, datum2) > threshold:
                    matches.append((datum1, datum2))
        return matches

    def print_matches(self, threshold, score):
        matches = self.find_matches(threshold, score)
        for match in matches:
            print match[0].attr.id + ", " + match[1].attr.id

class Score:
    # weighted_distances is a hash. Key is the distance class and
    # value is the weight.
    def __init__(self, weighted_distances):
        self.weighted_distances

    def similarity(self, datum1, datum2):
        score = 0
        total_weight = 0
        for distance, weight in self.weighted_distances.iteritems():
            dist = distance.distance(datum1, datum2)
{'fraction_non_alphanumeric': 0.08676631425446592, 'fraction_numerical': 0.016040831206707983, 'mean_word_length': 2.2705601907032182, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4953913', 'n_tokens_mistral': 831, 'n_tokens_neox': 790, 'n_words': 213}