From e3b81c05f411db2534068fa9cf62906aa815c264 Mon Sep 17 00:00:00 2001 From: theta00 <72700814+theta00@users.noreply.github.com> Date: Tue, 3 May 2022 14:52:01 +0200 Subject: [PATCH] Find jurisdiction --- dev-0/out.tsv | 83 ++++++++++++++++++++ run.py | 53 +++++++++++++ test-A/out.tsv | 203 +++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 339 insertions(+) create mode 100644 dev-0/out.tsv create mode 100644 run.py create mode 100644 test-A/out.tsv diff --git a/dev-0/out.tsv b/dev-0/out.tsv new file mode 100644 index 0000000..12bd1e1 --- /dev/null +++ b/dev-0/out.tsv @@ -0,0 +1,83 @@ +jurisdiction=Delaware +jurisdiction=Georgia +jurisdiction=Delaware +jurisdiction=Massachusetts +jurisdiction=Delaware +jurisdiction=Washington +jurisdiction=California +jurisdiction=New_Jersey +jurisdiction=California + +jurisdiction=Delaware +jurisdiction=Delaware +jurisdiction=Delaware +jurisdiction=Delaware +jurisdiction=Delaware +jurisdiction=Massachusetts +jurisdiction=Delaware +jurisdiction=Delaware +jurisdiction=Delaware +jurisdiction=Delaware +jurisdiction=Minnesota +jurisdiction=Delaware +jurisdiction=Virginia +jurisdiction=North_Carolina +jurisdiction=Arizona +jurisdiction=Indiana +jurisdiction=New_Jersey +jurisdiction=California +jurisdiction=Delaware +jurisdiction=Georgia +jurisdiction=Delaware +jurisdiction=Nevada +jurisdiction=California +jurisdiction=Minnesota +jurisdiction=Delaware +jurisdiction=Kentucky +jurisdiction=Minnesota +jurisdiction=Delaware +jurisdiction=Michigan +jurisdiction=Delaware +jurisdiction=Minnesota +jurisdiction=California +jurisdiction=Delaware +jurisdiction=Illinois +jurisdiction=Minnesota +jurisdiction=Texas +jurisdiction=Delaware +jurisdiction=Delaware +jurisdiction=Delaware +jurisdiction=Georgia +jurisdiction=Delaware +jurisdiction=Oregon +jurisdiction=Delaware +jurisdiction=Delaware +jurisdiction=California +jurisdiction=California +jurisdiction=California +jurisdiction=Delaware +jurisdiction=Delaware +jurisdiction=Delaware +jurisdiction=Idaho +jurisdiction=Washington +jurisdiction=Delaware +jurisdiction=New_York +jurisdiction=Delaware +jurisdiction=Delaware +jurisdiction=Oregon +jurisdiction=Washington +jurisdiction=Virginia +jurisdiction=Delaware +jurisdiction=New_York +jurisdiction=Delaware +jurisdiction=Idaho +jurisdiction=Delaware + +jurisdiction=Texas +jurisdiction=Delaware +jurisdiction=Washington +jurisdiction=New_York +jurisdiction=Washington +jurisdiction=Pennsylvania +jurisdiction=Delaware +jurisdiction=Illinois diff --git a/run.py b/run.py new file mode 100644 index 0000000..7fed888 --- /dev/null +++ b/run.py @@ -0,0 +1,53 @@ +#!/usr/bin/env python +# coding: utf-8 + +# In[13]: + + +import re + + +# In[1]: + + +state_names = ["Alaska", "Alabama", "Arkansas", "American Samoa", "Arizona", "California", "Colorado", "Connecticut", "District ", "of Columbia", "Delaware", "Florida", "Georgia", "Guam", "Hawaii", "Iowa", "Idaho", "Illinois", "Indiana", "Kansas", "Kentucky", "Louisiana", "Massachusetts", "Maryland", "Maine", "Michigan", "Minnesota", "Missouri", "Mississippi", "Montana", "North Carolina", "North Dakota", "Nebraska", "New Hampshire", "New Jersey", "New Mexico", "Nevada", "New York", "Ohio", "Oklahoma", "Oregon", "Pennsylvania", "Puerto Rico", "Rhode Island", "South Carolina", "South Dakota", "Tennessee", "Texas", "Utah", "Virginia", "Virgin Islands", "Vermont", "Washington", "Wisconsin", "West Virginia", "Wyoming"] +regex = re.compile(r'\b(' + '|'.join(state_names) + r')\b') + + +# In[43]: + + +with open('dev-0/in.tsv', 'r', encoding='utf8') as file: + lines = file.readlines() + + +# In[44]: + + +with open('dev-0/out.tsv', 'w') as file: + for line in lines: + jur = regex.search(line) + if jur: + file.write('jurisdiction=' + jur.group().replace(' ', '_') +'\n') + else: + file.write('\n') + + +# In[41]: + + +with open('test-A/in.tsv', 'r', encoding='utf8') as file: + lines = file.readlines() + + +# In[42]: + + +with open('test-A/out.tsv', 'w') as file: + for line in lines: + jur = regex.search(line) + if jur: + file.write('jurisdiction=' + jur.group().replace(' ', '_') +'\n') + else: + file.write('\n') + diff --git a/test-A/out.tsv b/test-A/out.tsv new file mode 100644 index 0000000..27a71f1 --- /dev/null +++ b/test-A/out.tsv @@ -0,0 +1,203 @@ +jurisdiction=Ohio +jurisdiction=Delaware +jurisdiction=Indiana +jurisdiction=Delaware +jurisdiction=Nevada +jurisdiction=Utah +jurisdiction=Delaware +jurisdiction=Maryland +jurisdiction=Delaware +jurisdiction=New_York +jurisdiction=California +jurisdiction=Delaware +jurisdiction=New_York +jurisdiction=Georgia +jurisdiction=Texas +jurisdiction=California +jurisdiction=Washington + +jurisdiction=Florida +jurisdiction=Delaware +jurisdiction=Florida +jurisdiction=New_York +jurisdiction=California +jurisdiction=Florida +jurisdiction=New_York +jurisdiction=Washington +jurisdiction=Texas +jurisdiction=Delaware +jurisdiction=Delaware +jurisdiction=Washington +jurisdiction=Delaware +jurisdiction=Nevada +jurisdiction=Delaware +jurisdiction=California +jurisdiction=Delaware +jurisdiction=California +jurisdiction=Virginia +jurisdiction=Delaware +jurisdiction=Florida +jurisdiction=California +jurisdiction=Virginia +jurisdiction=Pennsylvania +jurisdiction=Delaware +jurisdiction=Vermont +jurisdiction=Virginia +jurisdiction=California +jurisdiction=Delaware +jurisdiction=Delaware +jurisdiction=New_Jersey +jurisdiction=Delaware +jurisdiction=Texas +jurisdiction=Massachusetts +jurisdiction=Delaware +jurisdiction=New_York +jurisdiction=Delaware +jurisdiction=Pennsylvania +jurisdiction=District_ +jurisdiction=California +jurisdiction=Delaware +jurisdiction=Delaware +jurisdiction=Delaware +jurisdiction=Massachusetts +jurisdiction=Connecticut +jurisdiction=California +jurisdiction=Texas +jurisdiction=Delaware +jurisdiction=District_ +jurisdiction=Delaware +jurisdiction=Oregon +jurisdiction=Minnesota +jurisdiction=Delaware +jurisdiction=Texas +jurisdiction=Colorado +jurisdiction=Colorado +jurisdiction=Nevada +jurisdiction=Delaware +jurisdiction=Kansas +jurisdiction=Wisconsin +jurisdiction=New_Jersey +jurisdiction=New_York +jurisdiction=Delaware +jurisdiction=Virginia +jurisdiction=Delaware +jurisdiction=Nevada +jurisdiction=Delaware +jurisdiction=New_Jersey +jurisdiction=Delaware +jurisdiction=Minnesota +jurisdiction=Connecticut +jurisdiction=North_Carolina +jurisdiction=Delaware +jurisdiction=Florida +jurisdiction=Washington +jurisdiction=Ohio +jurisdiction=New_York +jurisdiction=Georgia +jurisdiction=New_York +jurisdiction=Delaware +jurisdiction=Colorado +jurisdiction=Delaware +jurisdiction=Delaware +jurisdiction=Ohio +jurisdiction=Minnesota +jurisdiction=Delaware +jurisdiction=California +jurisdiction=Connecticut +jurisdiction=Maryland +jurisdiction=Delaware +jurisdiction=Utah +jurisdiction=Delaware +jurisdiction=Utah +jurisdiction=Colorado +jurisdiction=Delaware +jurisdiction=Delaware +jurisdiction=California +jurisdiction=Delaware +jurisdiction=Virginia +jurisdiction=Delaware +jurisdiction=Texas +jurisdiction=Massachusetts +jurisdiction=Colorado +jurisdiction=New_York +jurisdiction=Michigan +jurisdiction=Pennsylvania +jurisdiction=New_York +jurisdiction=Delaware +jurisdiction=Texas +jurisdiction=Minnesota +jurisdiction=Ohio +jurisdiction=Oregon +jurisdiction=New_Jersey +jurisdiction=Florida +jurisdiction=Oregon +jurisdiction=Massachusetts +jurisdiction=Delaware +jurisdiction=California +jurisdiction=Maryland +jurisdiction=Illinois +jurisdiction=California +jurisdiction=Virginia +jurisdiction=Tennessee +jurisdiction=Delaware +jurisdiction=Delaware +jurisdiction=Minnesota +jurisdiction=Ohio +jurisdiction=Delaware +jurisdiction=New_Jersey +jurisdiction=Nevada +jurisdiction=Indiana +jurisdiction=Virginia +jurisdiction=Delaware +jurisdiction=New_York +jurisdiction=Delaware +jurisdiction=New_York +jurisdiction=Delaware + +jurisdiction=Louisiana +jurisdiction=Georgia +jurisdiction=New_York +jurisdiction=New_York +jurisdiction=Oregon +jurisdiction=Nevada +jurisdiction=Delaware +jurisdiction=North_Carolina +jurisdiction=Florida +jurisdiction=Georgia +jurisdiction=California +jurisdiction=New_York + +jurisdiction=New_York +jurisdiction=Delaware +jurisdiction=Georgia +jurisdiction=New_Jersey +jurisdiction=Minnesota +jurisdiction=North_Carolina +jurisdiction=Delaware +jurisdiction=Kentucky +jurisdiction=Nevada +jurisdiction=Missouri +jurisdiction=Utah +jurisdiction=Connecticut +jurisdiction=Delaware +jurisdiction=Delaware +jurisdiction=Delaware +jurisdiction=Georgia +jurisdiction=Delaware +jurisdiction=Washington +jurisdiction=California +jurisdiction=California +jurisdiction=Maryland +jurisdiction=Delaware +jurisdiction=Delaware +jurisdiction=Pennsylvania +jurisdiction=Delaware +jurisdiction=Delaware +jurisdiction=District_ +jurisdiction=Indiana +jurisdiction=Nevada +jurisdiction=Nevada +jurisdiction=Delaware +jurisdiction=California +jurisdiction=Colorado +