jurisdiction regex
This commit is contained in:
parent
c2c7bf069b
commit
453ef7eb27
83
dev-0/out.tsv
Normal file
83
dev-0/out.tsv
Normal file
@ -0,0 +1,83 @@
|
|||||||
|
jurisdiction=New_York
|
||||||
|
jurisdiction=New_York
|
||||||
|
jurisdiction=Delaware
|
||||||
|
jurisdiction=Delaware
|
||||||
|
jurisdiction=Delaware
|
||||||
|
jurisdiction=Washington
|
||||||
|
jurisdiction=Delaware
|
||||||
|
jurisdiction=New_Jersey
|
||||||
|
jurisdiction=New_York
|
||||||
|
|
||||||
|
jurisdiction=Delaware
|
||||||
|
jurisdiction=Delaware
|
||||||
|
jurisdiction=Delaware
|
||||||
|
jurisdiction=Delaware
|
||||||
|
jurisdiction=New_York
|
||||||
|
jurisdiction=Massachusetts
|
||||||
|
jurisdiction=Minnesota
|
||||||
|
jurisdiction=California
|
||||||
|
jurisdiction=New_York
|
||||||
|
jurisdiction=Delaware
|
||||||
|
jurisdiction=Iowa
|
||||||
|
jurisdiction=California
|
||||||
|
jurisdiction=Virginia
|
||||||
|
jurisdiction=North_Carolina
|
||||||
|
jurisdiction=Arizona
|
||||||
|
jurisdiction=Indiana
|
||||||
|
jurisdiction=New_Jersey
|
||||||
|
jurisdiction=California
|
||||||
|
jurisdiction=Delaware
|
||||||
|
jurisdiction=Georgia
|
||||||
|
jurisdiction=Delaware
|
||||||
|
jurisdiction=New_York
|
||||||
|
jurisdiction=California
|
||||||
|
jurisdiction=Minnesota
|
||||||
|
jurisdiction=California
|
||||||
|
jurisdiction=Kentucky
|
||||||
|
jurisdiction=Minnesota
|
||||||
|
jurisdiction=Ohio
|
||||||
|
jurisdiction=Massachusetts
|
||||||
|
jurisdiction=California
|
||||||
|
jurisdiction=Minnesota
|
||||||
|
jurisdiction=California
|
||||||
|
jurisdiction=Delaware
|
||||||
|
jurisdiction=Illinois
|
||||||
|
jurisdiction=Minnesota
|
||||||
|
jurisdiction=Texas
|
||||||
|
jurisdiction=New_Jersey
|
||||||
|
jurisdiction=Delaware
|
||||||
|
jurisdiction=Washington
|
||||||
|
jurisdiction=Georgia
|
||||||
|
jurisdiction=Delaware
|
||||||
|
jurisdiction=Oregon
|
||||||
|
jurisdiction=Delaware
|
||||||
|
jurisdiction=Delaware
|
||||||
|
jurisdiction=Delaware
|
||||||
|
jurisdiction=Massachusetts
|
||||||
|
jurisdiction=California
|
||||||
|
jurisdiction=Delaware
|
||||||
|
jurisdiction=Delaware
|
||||||
|
jurisdiction=Illinois
|
||||||
|
jurisdiction=Idaho
|
||||||
|
jurisdiction=Washington
|
||||||
|
jurisdiction=California
|
||||||
|
jurisdiction=New_York
|
||||||
|
jurisdiction=California
|
||||||
|
jurisdiction=Utah
|
||||||
|
jurisdiction=Delaware
|
||||||
|
jurisdiction=Washington
|
||||||
|
jurisdiction=Virginia
|
||||||
|
jurisdiction=New_York
|
||||||
|
jurisdiction=New_York
|
||||||
|
jurisdiction=Illinois
|
||||||
|
jurisdiction=California
|
||||||
|
jurisdiction=Delaware
|
||||||
|
|
||||||
|
jurisdiction=Texas
|
||||||
|
jurisdiction=California
|
||||||
|
jurisdiction=Washington
|
||||||
|
jurisdiction=Delaware
|
||||||
|
jurisdiction=Washington
|
||||||
|
jurisdiction=New_York
|
||||||
|
jurisdiction=Washington
|
||||||
|
jurisdiction=Illinois
|
|
33
run.py
Normal file
33
run.py
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
import re
|
||||||
|
import sys
|
||||||
|
|
||||||
|
filename = sys.argv[1]
|
||||||
|
|
||||||
|
with open(filename, encoding='utf-8') as f_in, open('out.tsv', 'w', encoding='utf-8') as f_out:
|
||||||
|
for line in f_in:
|
||||||
|
cols = line.split('\t')
|
||||||
|
clean_col = re.sub(r'(\\n)|(\\f)|(\\t)|(\\)', ' ', cols[-1])
|
||||||
|
clean_col = re.sub('[^A-Za-z ]', ' ', clean_col)
|
||||||
|
clean_col = re.sub(' +', ' ', clean_col)
|
||||||
|
stateof2words = re.search('[sS]tate of [A-Z]\w+( \w+)?', clean_col)
|
||||||
|
if stateof2words:
|
||||||
|
stateof2words = stateof2words.group().split()
|
||||||
|
if stateof2words[2] in ['New', 'South', 'West', 'Rhode', 'North']:
|
||||||
|
f_out.write('jurisdiction=' + stateof2words[2] + '_' + stateof2words[3] + '\n')
|
||||||
|
else:
|
||||||
|
f_out.write('jurisdiction=' + stateof2words[2] + '\n')
|
||||||
|
else:
|
||||||
|
found = False
|
||||||
|
for word in ['Alabama', 'Alaska', 'Arizona', 'Arkansas', 'California', 'Colorado', 'Connecticut', 'Delaware',
|
||||||
|
'Florida', 'Georgia', 'Hawaii', 'Idaho', 'Illinois', 'Indiana', 'Iowa', 'Kansas', 'Kentucky',
|
||||||
|
'Louisiana', 'Maine', 'Maryland', 'Massachusetts', 'Michigan', 'Minnesota', 'Mississippi',
|
||||||
|
'Missouri', 'Montana', 'Nebraska', 'Nevada', 'New Hampshire', 'New Jersey', 'New Mexico',
|
||||||
|
'New York', 'North Carolina', 'North Dakota', 'Ohio', 'Oklahoma', 'Oregon', 'Pennsylvania',
|
||||||
|
'Rhode Island', 'South Carolina', 'South Dakota', 'Tennessee', 'Texas', 'Utah', 'Vermont',
|
||||||
|
'Virginia', 'Washington', 'West Virginia', 'Wisconsin', 'Wyoming']:
|
||||||
|
if word in clean_col:
|
||||||
|
f_out.write('jurisdiction=' + word + '\n')
|
||||||
|
found = True
|
||||||
|
break
|
||||||
|
if not found:
|
||||||
|
f_out.write('\n')
|
203
test-A/out.tsv
Normal file
203
test-A/out.tsv
Normal file
@ -0,0 +1,203 @@
|
|||||||
|
jurisdiction=Ohio
|
||||||
|
jurisdiction=Delaware
|
||||||
|
jurisdiction=Louisiana
|
||||||
|
jurisdiction=New_York
|
||||||
|
jurisdiction=Nevada
|
||||||
|
jurisdiction=Colorado
|
||||||
|
jurisdiction=Colorado
|
||||||
|
jurisdiction=California
|
||||||
|
jurisdiction=Delaware
|
||||||
|
jurisdiction=New_York
|
||||||
|
jurisdiction=California
|
||||||
|
jurisdiction=Delaware
|
||||||
|
jurisdiction=New_York
|
||||||
|
jurisdiction=New_York
|
||||||
|
jurisdiction=Delaware
|
||||||
|
jurisdiction=California
|
||||||
|
jurisdiction=Washington
|
||||||
|
jurisdiction=Victoria
|
||||||
|
jurisdiction=Florida
|
||||||
|
jurisdiction=Delaware
|
||||||
|
jurisdiction=Florida
|
||||||
|
jurisdiction=New_York
|
||||||
|
jurisdiction=California
|
||||||
|
jurisdiction=Florida
|
||||||
|
jurisdiction=New_York
|
||||||
|
jurisdiction=Washington
|
||||||
|
jurisdiction=Texas
|
||||||
|
jurisdiction=Delaware
|
||||||
|
jurisdiction=Georgia
|
||||||
|
jurisdiction=Washington
|
||||||
|
jurisdiction=Delaware
|
||||||
|
jurisdiction=Nevada
|
||||||
|
jurisdiction=California
|
||||||
|
jurisdiction=California
|
||||||
|
jurisdiction=New_York
|
||||||
|
jurisdiction=New_York
|
||||||
|
jurisdiction=New York
|
||||||
|
jurisdiction=Delaware
|
||||||
|
jurisdiction=Florida
|
||||||
|
jurisdiction=California
|
||||||
|
jurisdiction=Virginia
|
||||||
|
jurisdiction=Pennsylvania
|
||||||
|
jurisdiction=Delaware
|
||||||
|
jurisdiction=Washington
|
||||||
|
jurisdiction=California
|
||||||
|
jurisdiction=California
|
||||||
|
jurisdiction=Delaware
|
||||||
|
jurisdiction=Delaware
|
||||||
|
jurisdiction=New_Jersey
|
||||||
|
jurisdiction=California
|
||||||
|
jurisdiction=Texas
|
||||||
|
jurisdiction=Delaware
|
||||||
|
jurisdiction=Washington
|
||||||
|
jurisdiction=New_York
|
||||||
|
jurisdiction=Delaware
|
||||||
|
jurisdiction=New_York
|
||||||
|
jurisdiction=Pennsylvania
|
||||||
|
jurisdiction=California
|
||||||
|
jurisdiction=Georgia
|
||||||
|
jurisdiction=Delaware
|
||||||
|
jurisdiction=Delaware
|
||||||
|
jurisdiction=Massachusetts
|
||||||
|
jurisdiction=Connecticut
|
||||||
|
jurisdiction=California
|
||||||
|
jurisdiction=Texas
|
||||||
|
jurisdiction=Delaware
|
||||||
|
jurisdiction=Virginia
|
||||||
|
jurisdiction=Delaware
|
||||||
|
jurisdiction=Washington
|
||||||
|
jurisdiction=Minnesota
|
||||||
|
jurisdiction=Oregon
|
||||||
|
jurisdiction=Texas
|
||||||
|
jurisdiction=Colorado
|
||||||
|
jurisdiction=Colorado
|
||||||
|
jurisdiction=Nevada
|
||||||
|
jurisdiction=New_York
|
||||||
|
jurisdiction=Delaware
|
||||||
|
jurisdiction=Illinois
|
||||||
|
jurisdiction=New_York
|
||||||
|
jurisdiction=New_York
|
||||||
|
jurisdiction=Florida
|
||||||
|
jurisdiction=Virginia
|
||||||
|
jurisdiction=New_York
|
||||||
|
jurisdiction=Nevada
|
||||||
|
jurisdiction=Delaware
|
||||||
|
jurisdiction=New_Jersey
|
||||||
|
jurisdiction=North_Carolina
|
||||||
|
jurisdiction=Minnesota
|
||||||
|
jurisdiction=Connecticut
|
||||||
|
jurisdiction=North_Carolina
|
||||||
|
jurisdiction=Kansas
|
||||||
|
jurisdiction=Florida
|
||||||
|
jurisdiction=Washington
|
||||||
|
jurisdiction=Oregon
|
||||||
|
jurisdiction=New_York
|
||||||
|
jurisdiction=Georgia
|
||||||
|
jurisdiction=Delaware
|
||||||
|
jurisdiction=New_York
|
||||||
|
jurisdiction=Colorado
|
||||||
|
jurisdiction=California
|
||||||
|
jurisdiction=Tennessee
|
||||||
|
jurisdiction=Ohio
|
||||||
|
jurisdiction=Minnesota
|
||||||
|
jurisdiction=Delaware
|
||||||
|
jurisdiction=California
|
||||||
|
jurisdiction=Connecticut
|
||||||
|
jurisdiction=Maryland
|
||||||
|
jurisdiction=Delaware
|
||||||
|
jurisdiction=Utah
|
||||||
|
jurisdiction=California
|
||||||
|
jurisdiction=Utah
|
||||||
|
jurisdiction=Colorado
|
||||||
|
jurisdiction=New_York
|
||||||
|
jurisdiction=Delaware
|
||||||
|
jurisdiction=California
|
||||||
|
jurisdiction=New_York
|
||||||
|
jurisdiction=Virginia
|
||||||
|
jurisdiction=Delaware
|
||||||
|
jurisdiction=Texas
|
||||||
|
jurisdiction=Massachusetts
|
||||||
|
jurisdiction=Colorado
|
||||||
|
jurisdiction=New_York
|
||||||
|
jurisdiction=Michigan
|
||||||
|
jurisdiction=Pennsylvania
|
||||||
|
jurisdiction=Japan
|
||||||
|
jurisdiction=New_Jersey
|
||||||
|
jurisdiction=New_York
|
||||||
|
jurisdiction=Minnesota
|
||||||
|
jurisdiction=Ohio
|
||||||
|
jurisdiction=Oregon
|
||||||
|
jurisdiction=New_Jersey
|
||||||
|
jurisdiction=Florida
|
||||||
|
jurisdiction=Oregon
|
||||||
|
jurisdiction=Massachusetts
|
||||||
|
jurisdiction=Ohio
|
||||||
|
jurisdiction=Minnesota
|
||||||
|
jurisdiction=Maryland
|
||||||
|
jurisdiction=Indiana
|
||||||
|
jurisdiction=California
|
||||||
|
jurisdiction=Virginia
|
||||||
|
jurisdiction=Tennessee
|
||||||
|
jurisdiction=Delaware
|
||||||
|
jurisdiction=Maryland
|
||||||
|
jurisdiction=Pennsylvania
|
||||||
|
jurisdiction=Ohio
|
||||||
|
jurisdiction=California
|
||||||
|
jurisdiction=New_Jersey
|
||||||
|
jurisdiction=Colorado
|
||||||
|
jurisdiction=Indiana
|
||||||
|
jurisdiction=Virginia
|
||||||
|
jurisdiction=Minnesota
|
||||||
|
jurisdiction=New York
|
||||||
|
jurisdiction=Delaware
|
||||||
|
jurisdiction=New_York
|
||||||
|
jurisdiction=California
|
||||||
|
jurisdiction=Delaware
|
||||||
|
jurisdiction=Louisiana
|
||||||
|
jurisdiction=Georgia
|
||||||
|
jurisdiction=New_York
|
||||||
|
jurisdiction=New_York
|
||||||
|
jurisdiction=Oregon
|
||||||
|
jurisdiction=Nevada
|
||||||
|
jurisdiction=California
|
||||||
|
jurisdiction=North_Carolina
|
||||||
|
jurisdiction=California
|
||||||
|
jurisdiction=Georgia
|
||||||
|
jurisdiction=California
|
||||||
|
jurisdiction=New_York
|
||||||
|
|
||||||
|
jurisdiction=New_York
|
||||||
|
jurisdiction=Indiana
|
||||||
|
jurisdiction=Georgia
|
||||||
|
jurisdiction=New_Jersey
|
||||||
|
jurisdiction=Minnesota
|
||||||
|
jurisdiction=North_Carolina
|
||||||
|
jurisdiction=Georgia
|
||||||
|
jurisdiction=Kentucky
|
||||||
|
jurisdiction=Nevada
|
||||||
|
jurisdiction=Missouri
|
||||||
|
jurisdiction=Colorado
|
||||||
|
jurisdiction=Connecticut
|
||||||
|
jurisdiction=Delaware
|
||||||
|
jurisdiction=North_Carolina
|
||||||
|
jurisdiction=California
|
||||||
|
jurisdiction=Georgia
|
||||||
|
jurisdiction=California
|
||||||
|
jurisdiction=New_York
|
||||||
|
jurisdiction=Pennsylvania
|
||||||
|
jurisdiction=California
|
||||||
|
jurisdiction=Maryland
|
||||||
|
jurisdiction=California
|
||||||
|
jurisdiction=Delaware
|
||||||
|
jurisdiction=Pennsylvania
|
||||||
|
jurisdiction=New_York
|
||||||
|
jurisdiction=Delaware
|
||||||
|
jurisdiction=Virginia
|
||||||
|
jurisdiction=Delaware
|
||||||
|
jurisdiction=Nevada
|
||||||
|
jurisdiction=Nevada
|
||||||
|
jurisdiction=Delaware
|
||||||
|
jurisdiction=California
|
||||||
|
jurisdiction=Colorado
|
||||||
|
|
|
Loading…
Reference in New Issue
Block a user