def check_road(self, road, idx): tempList = ['ka', 'kha', 'ga', 'gha', 'uma', 'ca', 'cha', 'ja', 'jha', 'za', 'zha', 'ta', 'tha', 'da', 'dha', 'na', 'pa', 'pha', 'fa', 'ma', 'ra', 'la', 'ha', 'ya', 'gp'] if 'road' == road or 'avenue' == road or 'ave' == road or 'lane' == road or 'sarani' == road or 'soroni' == road or 'rd#' == road or 'sarak' == road or 'sharak' == road or 'shorok' == road or 'sharani' == road or 'highway' == road or 'path' == road or 'poth' == road or 'chowrasta' == road or 'sarak' == road or 'rasta' == road or 'sorok' == road or 'goli' == road or 'street' == road or 'line' == road: if 'ave' == road: road = 'avenue' if idx != len(self.tempArray)-1: if (any(char.isdigit() for char in self.tempArray[idx+1])): num = re.findall(r'\d+', self.tempArray[idx+1]) num = max(map(int, num)) if(self.matched[self.roadkey] == None and num < 1000): self.matched[self.roadkey] = road + " "+self.tempArray[idx+1] return True # road x avenue y if self.matched[self.roadkey] == None: self.matched[self.roadkey] = '' if num < 1000: self.matched[self.roadkey] = self.matched[self.roadkey] + ", "+road+" " + self.tempArray[idx+1] return True if idx != 0: if (not any(char.isdigit() for char in self.tempArray[idx-1])): i = idx-1 road_str = '' if (not self.matched[self.areakey] == None and self.tempArray[i] == self.matched[self.areakey]): self.matched[self.roadkey] = self.matched[self.areakey] + " " + road return True while i >= 0: if any(char.isdigit() for char in self.tempArray[i]) or self.tempArray[i] in self.address_component: break if not i == 0 and (self.tempArray[i-1] in self.address_component or self.tempArray[i-1] in self.building_name_key or self.tempArray[i-1] in tempList or (re.match(r'^[a-z]$', self.tempArray[i-1]) and self.tempArray[i-2] == 'block')): if not any(char.isdigit() for char in self.tempArray[i]): road_str = self.tempArray[i] + " " + road_str break break road_str = self.tempArray[i] + " " + road_str i = i-1 if(self.matched[self.roadkey] == None): self.matched[self.roadkey] = road_str + road return True self.matched[self.roadkey] = self.matched[self.roadkey] + ", "+road_str + road # matched_array.append(matched[roadkey]) return True