<commit_before># -*- coding: utf-8 -*-


class ShopItem:
    def __init__(self, article_id, amount, name, price, link):
        self.article_id = article_id
        self.amount = amount
        self.name = name
        self.price = price
        self.link = link

    def __unicode__(self):
        return str(self.price / 100.0) + u'€ ' + self.name + u' (' + self.link + u')'

    def __eq__(self, other):
        return other and self.price == other.price and self.link == other.link

    def __ne__(self, other):
        result = self.__eq__(other)
        if result is NotImplemented:
            return result
        return not result

    def __hash__(self):
        return hash(self.name)

    @classmethod
    def parse(cls, string):
        price_end = string.find(u'€ ')
        name_end = string.find(u' (', price_end)
        link_end = string.find(u')', name_end)

        price = int(float(string[:price_end]) * 100)
        name = string[price_end + 2:name_end]
        link = string[name_end + 2:link_end]

        return ShopItem(None, None, name, price, link)


class Item:

    def __init__(self, name, sub_name=None, cc_price=None, ingredients=None, ratings=None, url=None, amount=1, num_rating=0):
        self.name = name
        self.sub_name = sub_name
        self.cc_price = cc_price
        self.ingredients = ingredients
        self.ratings_data = ratings
        self.num_rating = num_rating
        self.amount = amount
        self.shop_items = None
        self.selected_item = None
        if url:
            self.url = url
        else:
            from FoodScan.BarcodeSync.BarcodeDecoder.cascadingBarcodeDecoder import CascadingBarcodeDecoder
            self.url = CascadingBarcodeDecoder.url(self.name)

    def inc_amount(self, amount=1):
        self.amount += amount

    def set_shop_items(self, shop_items):
        self.shop_items = []
        selected_replaced = False
        for item in shop_items:
            item.amount = self.amount
            self.shop_items.append(item)

            if item == self.selected_item:
                self.selected_item = item
                selected_replaced = True

        if self.selected_item and not selected_replaced:
            self.selected_item = None

        if len(shop_items) == 1:
            self.selected_item = self.shop_items[0]

    def select_shop_item(self, item):
        if self.shop_items is None and item is not None:
            self.shop_items = [item]

        if item is None:
            self.selected_item = None
        else:
            for i in self.shop_items:
                if i == item:<commit_msg>only add searched items automatically if the whole search title is in the name<commit_after># -*- coding: utf-8 -*-


class ShopItem:
    def __init__(self, article_id, amount, name, price, link):
        self.article_id = article_id
        self.amount = amount
        self.name = name
        self.price = price
        self.link = link

    def __unicode__(self):
        return str(self.price / 100.0) + u'€ ' + self.name + u' (' + self.link + u')'

    def __eq__(self, other):
        return other and self.price == other.price and self.link == other.link

    def __ne__(self, other):
        result = self.__eq__(other)
        if result is NotImplemented:
            return result
        return not result

    def __hash__(self):
        return hash(self.name)

    @classmethod
    def parse(cls, string):
        price_end = string.find(u'€ ')
        name_end = string.find(u' (', price_end)
        link_end = string.find(u')', name_end)

        price = int(float(string[:price_end]) * 100)
        name = string[price_end + 2:name_end]
        link = string[name_end + 2:link_end]

        return ShopItem(None, None, name, price, link)


class Item:

    def __init__(self, name, sub_name=None, cc_price=None, ingredients=None, ratings=None, url=None, amount=1, num_rating=0):
        self.name = name
        self.sub_name = sub_name
        self.cc_price = cc_price
        self.ingredients = ingredients
        self.ratings_data = ratings
        self.num_rating = num_rating
        self.amount = amount
        self.shop_items = None
        self.selected_item = None
        if url:
            self.url = url
        else:
            from FoodScan.BarcodeSync.BarcodeDecoder.cascadingBarcodeDecoder import CascadingBarcodeDecoder
            self.url = CascadingBarcodeDecoder.url(self.name)

    def inc_amount(self, amount=1):
        self.amount += amount

    def set_shop_items(self, shop_items):
        self.shop_items = []
        selected_replaced = False
        for item in shop_items:
            item.amount = self.amount
            self.shop_items.append(item)

            if item == self.selected_item:
                self.selected_item = item
                selected_replaced = True

        if self.selected_item and not selected_replaced:
            self.selected_item = None

        if len(shop_items) == 1 and self.name in self.shop_items[0]:
            self.selected_item = self.shop_items[0]

    def select_shop_item(self, item):
        if self.shop_items is None and item is not None:
            self.shop_items = [item]

        if item is None:
            self.selected_item = None
        else:
            for i in self.shop_items:
                if i == item:
{'fraction_non_alphanumeric': 0.09411764705882353, 'fraction_numerical': 0.005788982259570495, 'mean_word_length': 2.0711009174311927, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '3779062', 'n_tokens_mistral': 1634, 'n_tokens_neox': 1575, 'n_words': 404}