-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMatch.py
More file actions
33 lines (29 loc) · 1.26 KB
/
Match.py
File metadata and controls
33 lines (29 loc) · 1.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import re
import Completion
# Criterias needs to include:
# the initial dictionary OR a list of previous matched addresses to loop on
# the element that needs to be search in
# the element that needs to be search with
def matchWithCriterias(criterias):
toLookIn = criterias["toLookIn"]
completionState = criterias["completionState"]
toMatch = criterias["toMatch"]
matches = []
for address in toLookIn:
string = address.city.split(" ") if completionState == Completion.CompletionState.CITY else address.streetName.split(" ")
for subString in string:
if address not in matches and subString.find(toMatch) == 0:
matches.append(address)
return matches
def getTabOfDiffEltsOfAddrFrom(matched, criterias):
tmp = []
for address in matched:
if criterias["completionState"] == Completion.CompletionState.CITY:
if not address.city in tmp:
tmp.append(address.city)
if not criterias["completionState"]:
if not address.streetName in tmp:
tmp.append(address.streetName)
elif criterias["completionState"] == Completion.CompletionState.STREETNAME:
tmp = matched
return tmp