e870ef14c590502fb0dc5ff3199e2602a87ec008,ner_v1/detectors/numeral/budget/budget_detection.py,BudgetDetector,_detect_min_budget,#BudgetDetector#Any#Any#,182
Before Change
budget_list = []
if original_list is None:
original_list = []
patterns = re.findall(
r"(\s(above|more? than|more?|greater than|greater|abv|abov|more? den|\>\s*\=?)\s+"
r"(rs.|rs|rupees|rupee)*\s*([\d.,]+\s*[klmct]?[a-z]*|[\d.,]+\s*[klmct]?[a-z]*)\s*"
r"(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]):
replace_comma = re.sub(",", "", pattern[3])
amount = int(self.regex_object.unit_substitute(replace_comma))
else:
replace_comma = re.sub(",", "", pattern[3])
amount = int(replace_comma)
if self.min_digit <= len(str(amount)) <= self.max_digit:
budget["min_budget"] = amount
budget_list.append(budget)
original_list.append(original)
return budget_list, original_list
def _detect_max_budget(self, budget_list=None, original_list=None):
Detects maximum budget from text using regex
After Change
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["min_budget"] = amount
budget_list.append(budget)
original_list.append(original.strip())
return budget_list, original_list
def _detect_max_budget(self, budget_list=None, original_list=None):
Detects maximum budget from text using regex
In pattern: SUPERPATTERN
Frequency: 3
Non-data size: 4
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_min_budget
Project Name: comic/grand-challenge.org
Commit Name: e357e1dbcdf36eb12be0bc5043e0a098f94a833a
Time: 2017-05-09
Author: jamesmeakin@gmail.com
File Name: django/comicsite/templatetags/comic_templatetags.py
Class Name: comic_URLNode
Method Name: render
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: 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