e870ef14c590502fb0dc5ff3199e2602a87ec008,ner_v1/detectors/numeral/budget/budget_detection.py,BudgetDetector,_detect_max_budget,#BudgetDetector#Any#Any#,226

Before Change


        if original_list is None:
            original_list = []

        patterns = re.findall(
            r"(\s(max|upto|o?nly|around|below|less than|less|less den|\<\s*\=?)\s+(rs.|rs|rupees|rupee)"
            r"?\s*([\d.,]+\s*[klmct]?[a-z]*|[\d.,]+\s*[klmct]?[a-z]*)\s*(rs.|rs|rupees|rupee|\.)?\s)",
            self.processed_text.lower())
        for pattern in patterns:
            original = pattern[0].strip()

            budget = {
                "min_budget": 0,
                "max_budget": 0,
                "type": BUDGET_TYPE_NORMAL
            }

            if any([unit in pattern[3] for unit in self.unit_present_list]):
                comma_removed_unit_text = pattern[3].replace(",", "")
                amount = int(self.regex_object.unit_substitute(comma_removed_unit_text))
            else:
                comma_removed_number = pattern[3].replace(",", "")
                amount = int(comma_removed_number)

            if self.min_digit <= len(str(amount)) <= self.max_digit:
                budget["max_budget"] = amount
                budget_list.append(budget)
                original_list.append(original)

After Change


        if original_list is None:
            original_list = []

        pattern = re.compile(r"\s("
                             r"(?:max|upto|o?nly|around|below|less than|less|less den|\<\s*\=?)"
                             r"\s+" +
                             self._budget_pattern +
                             r")(?:\b|\.|\s)", flags=re.UNICODE | re.IGNORECASE)

        for match in pattern.finditer(self.processed_text):
            original, amount, unit = match.groups()

            budget = {
                "min_budget": 0,
                "max_budget": 0,
                "type": BUDGET_TYPE_NORMAL
            }

            scale = self.get_scale(unit)

            if amount.replace(",", "").replace(".", "").isdigit():
                amount = float(amount.replace(",", "")) * scale

                amount = int(amount)  // casting to int for backward compatibility
                if self.min_digit <= len(str(amount)) <= self.max_digit:
                    budget["max_budget"] = amount
                    budget_list.append(budget)
                    original_list.append(original.strip())

        return budget_list, original_list

    def _detect_min_max_budget(self, budget_list=None, original_list=None):
        Detects both minimum and maximum budget from text using regex
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 4

Non-data size: 7

Instances


Project Name: hellohaptik/chatbot_ner
Commit Name: e870ef14c590502fb0dc5ff3199e2602a87ec008
Time: 2019-03-18
Author: jain.chirag925@gmail.com
File Name: ner_v1/detectors/numeral/budget/budget_detection.py
Class Name: BudgetDetector
Method Name: _detect_max_budget


Project Name: googledatalab/pydatalab
Commit Name: 5b48f9a9c097d26d395873044ceaa1a0b886682a
Time: 2017-06-14
Author: brandondutra@google.com
File Name: solutionbox/code_free_ml/mltoolbox/code_free_ml/analyze.py
Class Name:
Method Name: run_cloud_analysis


Project Name: googledatalab/pydatalab
Commit Name: 5b48f9a9c097d26d395873044ceaa1a0b886682a
Time: 2017-06-14
Author: brandondutra@google.com
File Name: solutionbox/code_free_ml/mltoolbox/code_free_ml/analyze.py
Class Name:
Method Name: run_local_analysis


Project Name: hellohaptik/chatbot_ner
Commit Name: e870ef14c590502fb0dc5ff3199e2602a87ec008
Time: 2019-03-18
Author: jain.chirag925@gmail.com
File Name: ner_v1/detectors/numeral/budget/budget_detection.py
Class Name: BudgetDetector
Method Name: _detect_min_budget