Ejemplo n.º 1
0
    def test_two(self):

        input = {}
        input["a"] = ('in', ["1", "2", "3"])
        input["b"] = ('in', ["1", "2", "4"])

        all_companies_with_all_labels_dict,max_companies_dict,all_with_max_dict= \
            CompaniesComparison.find_groups_with_size(input,3)

        self.assertEqual(all_companies_with_all_labels_dict, [])
Ejemplo n.º 2
0
    def test_three(self):

        input = {}
        input["a"] = ('in', ["1", "2", "3"])
        input["b"] = ('in', ["1", "2", "3", "4"])

        all_companies_with_all_labels_dict,max_companies_dict,all_with_max_dict= \
            CompaniesComparison.find_groups_with_size(input,3)

        self.assertListOfSets(all_companies_with_all_labels_dict,
                              [(["a", "b"], ["1", "2", "3"])])
Ejemplo n.º 3
0
    def test_seven(self):

        input = {}
        input["a"] = ('in1', ["1", "2", "3", "5"])
        input["b"] = ('in2', ["1", "2", "3", "4"])
        input["c"] = ('in1', ["2", "3", "4"])
        input["d"] = ('in1', ["1", "2", "3", "4", "5"])

        all_companies_with_all_labels_dict,max_companies_dict,all_companies_max_labels= \
            CompaniesComparison.find_groups_with_size(input,4)

        self.assertIsItemContained(all_companies_with_all_labels_dict,
                                   (["d", "a"], ["2", "3", "1", "5"]))
        self.assertIsItemContained(all_companies_max_labels,
                                   (["d", "a"], ["2", "3", "1", "5"]))
Ejemplo n.º 4
0
    def test_four(self):

        input = {}
        input["a"] = ('in', ["1", "2", "3"])
        input["b"] = ('in', ["1", "2", "3", "4"])
        input["c"] = ('in', ["2", "3", "4"])

        all_companies_with_all_labels_dict,max_companies_dict,all_companies_max_labels= \
            CompaniesComparison.find_groups_with_size(input,2)

        self.assertIsItemContained(all_companies_with_all_labels_dict,
                                   (["a", "b", "c"], ["2", "3"]))
        self.assertIsItemContained(all_companies_with_all_labels_dict,
                                   (["a", "c"], ["2", "3"]))
        self.assertIsItemContained(all_companies_with_all_labels_dict,
                                   (["a", "b"], ["1", "2"]))
        self.assertIsItemContained(all_companies_with_all_labels_dict,
                                   (["a", "b"], ["2", "3"]))

        self.assertIsItemContained(max_companies_dict,
                                   (["a", "b", "c"], ["2", "3"]))

        self.assertIsItemContained(all_companies_max_labels,
                                   (["a", "b", "c"], ["2", "3"]))
Ejemplo n.º 5
0
from json_helper import JsonHelper
from companies_comparison import CompaniesComparison

MIN_CRITERIA_NUM = 4

with open('companiesComparisonWidgetInput.json', 'r') as content_file:
    content = content_file.read()

company_to_labels = JsonHelper.convert_companies_json_to_dictionary(content)

all_companies_with_all_labels_dict,max_companies_dict,all_with_max_dict = \
    CompaniesComparison.find_groups_with_size(company_to_labels, MIN_CRITERIA_NUM)

print "All combinations of all companies with all combinations of shared creterias of size %s:" % MIN_CRITERIA_NUM
print JsonHelper.convert_companies_to_labels_list_to_json(
    all_companies_with_all_labels_dict) + '\n'

print 'All the Maximum number of companies that have a shared creteria of %s:' % MIN_CRITERIA_NUM
print JsonHelper.convert_companies_to_labels_list_to_json(
    max_companies_dict) + '\n'

print 'All the Companies combinations with their max shared cretierias that have a minimum shared creteria of %s:' % MIN_CRITERIA_NUM
print JsonHelper.convert_companies_to_labels_list_to_json(
    all_with_max_dict) + '\n'