ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/ns_dev/Python/NinoCode/Active_prgs/Redgrave/Amazon_NameSearches.py
Revision: 848
Committed: Tue Dec 10 18:00:23 2024 UTC (15 months, 2 weeks ago) by nino.borges
Content type: text/x-python
File size: 8029 byte(s)
Log Message:
Now that I make the NamesNormQC a library and I'm not running code in it, I'm able to now call that instead of trying to mirror it here, which was a mess.  Much better.

File Contents

# Content
1 """
2
3 Amazon_NameSearches
4
5 Created by:
6 Emanuel Borges
7 12.3.2024
8
9 This program to test searching the MAL.
10
11 """
12
13
14
15 import os, re
16 import MyCode.Active_prgs.Redgrave.Amazon_PrivLogQC
17 import MyCode.Active_prgs.Redgrave.Amazon_NamesNormQC
18
19
20
21
22
23 if __name__ == '__main__':
24 #cleanedDatExportFileName = r"C:\Users\eborges\OneDrive - Redgrave LLP\Documents\Cases\Amazon\_PrivLogQCProcess\20241202 - FTC-CID\PLOG All IDs (20241203)\TEST-PLOG.txt"
25 #cleanedDatExportFileName = r"C:\Users\eborges\OneDrive - Redgrave LLP\Documents\Cases\Amazon\_PrivLogQCProcess\20241202 - FTC-CID\PLOG All IDs (20241203)\PLOG All IDs (20241203)_Converted_SubSetOnly.txt"
26 cleanedDatExportFileName = r"C:\Users\eborges\OneDrive - Redgrave LLP\Documents\Cases\Amazon\_PrivLogQCProcess\Data Exports\CAAG\CAAG_Log_Data_Export_Converted.txt"
27 masterAttorneyListFileName = r"C:\Users\eborges\OneDrive - Redgrave LLP\Documents\Cases\Amazon\_PrivLogQCProcess\Amazon_ Master Attorney List 2024.12.1(7045413.15).xlsx"
28 fullNameOveridesFileName = r"C:\Users\eborges\OneDrive - Redgrave LLP\Documents\Cases\Amazon\_PrivLogQCProcess\FullNameOverides - Copy.txt"
29 #fullNameOveridesFileName = r"C:\Users\eborges\OneDrive - Redgrave LLP\Documents\Cases\Amazon\_PrivLogQCProcess\FullNameOverides.txt"
30 allPossibleEmailAddressesRegExPattern = r"[\w.+-]+@[\w-]+\.[\w.-]+"
31 outputFile = open(r"C:\Users\eborges\OneDrive - Redgrave LLP\Documents\Cases\Amazon\_PrivLogQCProcess\Data Exports\CAAG\namesSearchResults_new.txt",'w')
32
33
34
35 nv = MyCode.Active_prgs.Redgrave.Amazon_NamesNormQC.NamesVerification(cleanedDatExportFileName, masterAttorneyListFileName, fullNameOveridesFileName)
36
37
38 ## This is just some simple searching of email addresses
39 ## contents = open(r"C:\Users\eborges\OneDrive - Redgrave LLP\Documents\Cases\Amazon\_PrivLogQCProcess\Consilio\VEAS-MasterAttorneyList\2024-12-05_EmailAddressesOnly.txt",encoding='UTF-8').readlines()
40 ## contents = contents[1:]
41 ## for line in contents:
42 ## line = line.replace("\n","")
43 ## line = line.split(";")
44 ## for i in line:
45 ## personMatch = nv.malPeopleList.search_by_email(i.upper())
46 ## if personMatch:
47 ## if personMatch.is_attorney == 'YES':
48 ## pass
49 ## #print(f"{i} is an attorney match!")
50 ## elif personMatch.is_attorney == 'NO':
51 ## print(f"{i} is an downgrade match!")
52 ## else:
53 ## print(f"{i} is a possible Split Role match!")
54
55
56 ## This section was used for comparing the names in legal sources to any email addresses I could locate on that same line.
57 contents = open(cleanedDatExportFileName,encoding='UTF-8').readlines()
58 contents = contents[1:]
59 for line in contents:
60 attorneysInDocumentSet = set()
61 downgradesInSet = set()
62 line = line.replace("\n","")
63 #singleLine = contents[3]
64 resultSet = set()
65 results = re.findall(allPossibleEmailAddressesRegExPattern, line)
66 for result in results:
67 resultSet.add(result)
68 line = line.split("|")
69 legalSources = line[11].upper()
70 if legalSources:
71 legalSources =legalSources.split(";")
72 #print(f"\n\n{legalSources}")
73 for r in list(resultSet):
74 #print(r)
75 personMatch = nv.malPeopleList.search_by_email(r.upper())
76 if personMatch:
77 #print("entry exists")
78 if personMatch.full_name_overide:
79 if f"{personMatch.full_name_overide}*" in legalSources:
80 if personMatch.is_attorney == 'YES':
81 attorneysInDocumentSet.add(f"{personMatch.full_name_overide}* is a match on {r.upper()}. This is an Attorney.")
82 #print (f"{personMatch.full_name_overide}* is a match on {r.upper()}. This is an Attorney.")
83 else:
84 downgradesInSet.add(f"{personMatch.full_name_overide}* is a match on {r.upper()}. This is a DOWNGRADE.")
85 #print (f"{personMatch.full_name_overide}* is a match on {r.upper()}. This is a DOWNGRADE.")
86 if personMatch.full_name_preferred:
87 fullPreferredName = personMatch.full_name_preferred
88 fullPreferredName = fullPreferredName.replace('(LEGAL)','')
89 fullPreferredName = fullPreferredName.replace('(SHE, HER)','')
90 fullPreferredName = fullPreferredName.replace('(SHE HER)','')
91 fullPreferredName = fullPreferredName.replace(',,',',')
92 #print(fullPreferredName)
93 preferedLastName, preferedFirstName = fullPreferredName.split(',')
94 preferedLastName = preferedLastName.strip()
95 preferedFirstName = preferedFirstName.strip()
96 preferedFirstName = preferedFirstName.split(" ")[0]
97 fullName = f"{preferedFirstName} {preferedLastName}"
98 #if f"{preferedLastName}, {preferedFirstName}*" in legalSources:
99 if f"{preferedFirstName} {preferedLastName}*" in legalSources:
100 if personMatch.is_attorney == 'YES':
101 #attorneysInDocumentSet.add(f"{preferedLastName}, {preferedFirstName}* is a match on {r.upper()}. This is an Attorney.")
102 attorneysInDocumentSet.add(f"{preferedFirstName} {preferedLastName}* is a match on {r.upper()}. This is an Attorney.")
103 #print(f"{preferedLastName}, {preferedFirstName}* is a match on {r.upper()}. This is an Attorney.")
104 else:
105 #downgradesInSet.add(f"{preferedLastName}, {preferedFirstName}* is a match on {r.upper()}. This is a DOWNGRADE.")
106 downgradesInSet.add(f"{preferedFirstName} {preferedLastName}* is a match on {r.upper()}. This is a DOWNGRADE.")
107 #print(f"{preferedLastName}, {preferedFirstName}* is a match on {r.upper()}. This is a DOWNGRADE.")
108 #if f"{personMatch.last_name}, {personMatch.first_name}*" in legalSources:
109 if f"{personMatch.first_name} {personMatch.last_name}*" in legalSources:
110 if personMatch.is_attorney == 'YES':
111 #attorneysInDocumentSet.add(f"{personMatch.last_name}, {personMatch.first_name}* is a match on {r.upper()}. This is an Attorney.")
112 attorneysInDocumentSet.add(f"{personMatch.first_name} {personMatch.last_name}* is a match on {r.upper()}. This is an Attorney.")
113 #print(f"{personMatch.last_name}, {personMatch.first_name}* is a match on {r.upper()}. This is an Attorney.")
114 else:
115 #downgradesInSet.add(f"{personMatch.last_name}, {personMatch.first_name}* is a match on {r.upper()}. This is a DOWNGRADE.")
116 downgradesInSet.add(f"{personMatch.first_name} {personMatch.last_name}* is a match on {r.upper()}. This is a DOWNGRADE.")
117 #print(f"{personMatch.last_name}, {personMatch.first_name}* is a match on {r.upper()}. This is a DOWNGRADE.")
118 outputFile.write(f"{line[0]} has {len(attorneysInDocumentSet)} matching attorneys and {len(downgradesInSet)} matching downgrades. ")
119 if len(attorneysInDocumentSet) > 0:
120 outputFile.write("There is at least 1 matching attorney.\n")
121 else:
122 outputFile.write("There are NO matching attorneys!\n")
123 else:
124 pass
125 #print("\n\nEmpty legal sources field")