Subversion Repositories SmartDukaan

Rev

Rev 4199 | Rev 5377 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 4199 Rev 5291
Line 32... Line 32...
32
        for brand in self.brands:
32
        for brand in self.brands:
33
            if full_name.startswith(brand):  return (brand, full_name.replace(brand, '').strip())
33
            if full_name.startswith(brand):  return (brand, full_name.replace(brand, '').strip())
34
        
34
        
35
        return ("", full_name)
35
        return ("", full_name)
36
 
36
 
-
 
37
class DuplicateMappingTracker:
-
 
38
    
-
 
39
    def __init__(self):
-
 
40
        self.mapping = {}
-
 
41
    
-
 
42
    def track(self, url, entity_id):
-
 
43
        if url in self.mapping:
-
 
44
            self.mapping[url].append(entity_id)
-
 
45
        else:
-
 
46
            self.mapping[url] = [entity_id]
-
 
47
    
-
 
48
    def getDuplicateMappings(self):
-
 
49
        
-
 
50
        duplicate_mappings = {}
-
 
51
        
-
 
52
        for url, entities in duplicate_mappings.iteritems():
-
 
53
            if len(entities) > 1:
-
 
54
                duplicate_mappings[url] = entities
-
 
55
        
-
 
56
        return duplicate_mappings
-
 
57
    
37
def getURLSource(url):
58
def getURLSource(url):
38
    try:
59
    try:
39
        return str(url.split('.')[1].strip())
60
        return str(url.split('.')[1].strip())
40
    except Exception:
61
    except Exception:
41
        return None
62
        return None
Line 80... Line 101...
80
    '''
101
    '''
81
    Receives a list of products (returned from search results) &
102
    Receives a list of products (returned from search results) &
82
    returns a clustered dictionary, where products are grouped by
103
    returns a clustered dictionary, where products are grouped by
83
    the 'source'
104
    the 'source'
84
    '''
105
    '''
85
    clustered_results = {'adexmart': [], 'flipkart': [], 'homeshop18': [], 'infibeam': [], 'letsbuy': []}
106
    clustered_results = {'adexmart': [], 'flipkart': [], 'homeshop18': [], 'infibeam': [], 'snapdeal': []}
86
    
107
    
87
    for product in products:
108
    for product in products:
88
        clustered_results[product['source']].append(product)
109
        clustered_results[product['source']].append(product)
89
    
110
    
90
    return clustered_results
111
    return clustered_results
Line 110... Line 131...
110
            'letsbuy': 'http://www.letsbuy.com/advanced_search_result.php?cPath=254&keywords=$$'
131
            'letsbuy': 'http://www.letsbuy.com/advanced_search_result.php?cPath=254&keywords=$$'
111
        }
132
        }
112
        return search_urls[source].replace('$$', name)
133
        return search_urls[source].replace('$$', name)
113
 
134
 
114
def getDisplayInfo(filtered_cluster, product_name):
135
def getDisplayInfo(filtered_cluster, product_name):
115
    display_info = {'adexmart': {}, 'flipkart': {}, 'homeshop18': {}, 'infibeam': {}, 'letsbuy': {}}
136
    display_info = {'adexmart': {}, 'flipkart': {}, 'homeshop18': {}, 'infibeam': {}, 'snapdeal': {}}
116
    
137
    
117
    for source, products in filtered_cluster.iteritems():
138
    for source, products in filtered_cluster.iteritems():
118
        
139
        
119
        if len(products) > 0:
140
        if len(products) > 0:
120
            if isPriceSame(products):
141
            if isPriceSame(products):