@@ -165,15 +165,23 @@ def _clean_street(self, street: str, locality: str = "") -> Tuple[str, bool]:
165165 {"match" : "4909 FM 2826" , "replace" : "4909 Farm to Market Road" , "locality" : "ROBSTOWN" },
166166 {"match" : "6920 DIGITAL RD" , "replace" : "11541 Montana Avenue" , "locality" : "EL PASO" },
167167 # default matches should come last
168- {"match" : "'s" , "replace" : "" , "locality" : "" },
169- {"match" : "." , "replace" : "" , "locality" : "" },
170- {"match" : "," , "replace" : "" , "locality" : "" },
171168 ]
172169 cleaned = False
173170 for f in street_filters :
174171 if (f ["match" ] in street ) and ((f ["locality" ] and f ["locality" ] == locality ) or not f ["locality" ]):
175172 street = street .replace (f ["match" ], f ["replace" ])
176173 cleaned = True
174+ break
175+ # simpler loop for default cleanup
176+ default_matches = [
177+ {"match" : "'s" , "replace" : "" },
178+ {"match" : "." , "replace" : "" },
179+ {"match" : "," , "replace" : "" },
180+ ]
181+ for f in default_matches :
182+ if f ["match" ] in street :
183+ street = street .replace (f ["match" ], f ["replace" ])
184+ cleaned = True
177185 return street , cleaned
178186
179187 def _repair_zip (self , zip_code : int , locality : str ) -> Tuple [str , bool ]:
@@ -185,7 +193,7 @@ def _repair_zip(self, zip_code: int, locality: str) -> Tuple[str, bool]:
185193 cleaned = False
186194 if len (zcode ) == 4 :
187195 zcode = f"0{ zcode } "
188- cleaned = True
196+ return zcode , cleaned
189197 matches = [
190198 {"match" : "89512" , "replace" : "89506" , "locality" : "Reno" },
191199 {"match" : "82901" , "replace" : "82935" , "locality" : "Rock Springs" },
0 commit comments