ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/ns_dev/Python/NinoCode/Active_prgs/Redgrave/SF-SubjectLineDeconstructor.py
Revision: 802
Committed: Thu Sep 28 13:38:29 2023 UTC (2 years, 5 months ago) by nino.borges
Content type: text/x-python
File size: 1572 byte(s)
Log Message:
Very simple program that will read a list of subject lines and deconstruct them to consilidate them into a list of something attorneys
can use to pull out responsive terms.

File Contents

# User Rev Content
1 nino.borges 802 """
2    
3     SF-SubjectLineDeconstructor
4    
5     Created by:
6     Emanuel Borges
7     09.21.2023
8    
9     Very simple program that will read a list of subject lines and deconstruct them to consilidate them into a list of something attorneys
10     can use to pull out responsive terms.
11    
12     """
13    
14     def ProcessLine(line, removalList):
15     line = line.strip()
16     for begVal in removalList:
17     if line.startswith(begVal):
18     line = line.replace(begVal,"",1)
19     return line.strip()
20    
21    
22     if __name__ == '__main__':
23     removalList = ['[EXTERNAL] ', 'RE: ', 'FW: ','Accepted: ','Canceled: ','Tentative: ', 'Re: ', 'Fw: ', 'Fwd: ', 'Automatic reply: ', 'Declined: ', '[EXTERNAL EMAIL] ']
24     sfInputFileName = r"C:\Users\eborges\Documents\Cases\State Farm\subject_line_raw.txt"
25    
26     outputFileName = r"C:\Users\eborges\Documents\Cases\State Farm\subject_line_EB.txt"
27    
28     sfSubjectSet = set()
29    
30     contents = open(sfInputFileName).readlines()
31     print(f"This file contains {len(contents)} lines.")
32     for line in contents:
33     line = line.replace("\n","")
34     begLineTest = True
35     while begLineTest == True:
36     begLineTest = False
37     for begVal in removalList:
38     if line.startswith(begVal):
39     begLineTest = True
40     line = ProcessLine(line, removalList)
41    
42     sfSubjectSet.add(line)
43    
44     outputFile = open(outputFileName,'w')
45     sfSubJectList = list(sfSubjectSet)
46     sfSubJectList.sort()
47     for i in sfSubJectList:
48     outputFile.write(f"{i}\n")
49     outputFile.close()