File size: 1,565 Bytes
8ba15ea
 
 
 
 
 
 
1f22e94
 
8ba15ea
 
 
1f22e94
 
8ba15ea
36a20b5
8ba15ea
 
 
 
 
 
 
 
36a20b5
8ba15ea
 
36a20b5
8ba15ea
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
from preprocess.preprocess import Preprocessor
from processor.matching import prepare_groups_with_ids,new_find_matches_with_ids


class Processor():
    def __init__(self, long_types_list, short_types_list, sour_list, 

                 type_wine, gbs, colors_for_trim, grapes, other_words,

                 sour_merge_dict, type_merge_dict, color_merge_dict,

                 country_list, normalized_names_dict):

        self.preprocessor=Preprocessor(long_types_list, short_types_list, sour_list, 
                 type_wine, gbs, colors_for_trim, grapes, other_words,
                 sour_merge_dict, type_merge_dict, color_merge_dict,
                 country_list, normalized_names_dict)

    def process(self, products, items, is_items_first=False, th=65, include_alternatives=True):
        items, products=self.preprocessor.process(products, items)

        print('-----*-----Matching-----*-----')
        
        if is_items_first:
            products['new_brand']=products['brand']
            items['brand']=items['new_brand']
            products_groups = prepare_groups_with_ids(products)
            res=new_find_matches_with_ids(items, products_groups, products, name_threshold=th, include_alternatives=include_alternatives)
        else:
            items_groups = prepare_groups_with_ids(items)
            res=new_find_matches_with_ids(products, items_groups, items, name_threshold=th, include_alternatives=include_alternatives)

        return res.drop(['type','type_wine','alco','gb'], axis=1), items, products