state jurisdiction v2
This commit is contained in:
parent
8bede28e3d
commit
e5e75b82bc
@ -52,7 +52,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 20,
|
"execution_count": 23,
|
||||||
"id": "ea8069f7-de8e-454c-8eac-9fb7cc0df626",
|
"id": "ea8069f7-de8e-454c-8eac-9fb7cc0df626",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
@ -60,6 +60,7 @@
|
|||||||
"def jurisdiction(path_in, path_out): \n",
|
"def jurisdiction(path_in, path_out): \n",
|
||||||
" with open(path_in, 'r', encoding='utf8') as file:\n",
|
" with open(path_in, 'r', encoding='utf8') as file:\n",
|
||||||
" lines = file.readlines()\n",
|
" lines = file.readlines()\n",
|
||||||
|
" lines = lines.replace('.', ' ').replace(',', ' ').lower()\n",
|
||||||
" with open(path_out, 'wt')as file_out:\n",
|
" with open(path_out, 'wt')as file_out:\n",
|
||||||
" for i in lines:\n",
|
" for i in lines:\n",
|
||||||
" file_out.write(\"jurisdiction=\"+str(state_prediction(i))+'\\n') \n",
|
" file_out.write(\"jurisdiction=\"+str(state_prediction(i))+'\\n') \n",
|
||||||
@ -80,7 +81,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 22,
|
"execution_count": 24,
|
||||||
"id": "594a25a9-a0ce-4de9-82c8-df50a4ecac39",
|
"id": "594a25a9-a0ce-4de9-82c8-df50a4ecac39",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [
|
"outputs": [
|
||||||
@ -89,7 +90,7 @@
|
|||||||
"output_type": "stream",
|
"output_type": "stream",
|
||||||
"text": [
|
"text": [
|
||||||
"[NbConvertApp] Converting notebook run.ipynb to script\n",
|
"[NbConvertApp] Converting notebook run.ipynb to script\n",
|
||||||
"[NbConvertApp] Writing 1634 bytes to run.py\n"
|
"[NbConvertApp] Writing 1697 bytes to run.py\n"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
@ -35,12 +35,13 @@ def state_prediction(text_in):
|
|||||||
return max(state_dict, key=state_dict.get)
|
return max(state_dict, key=state_dict.get)
|
||||||
|
|
||||||
|
|
||||||
# In[20]:
|
# In[23]:
|
||||||
|
|
||||||
|
|
||||||
def jurisdiction(path_in, path_out):
|
def jurisdiction(path_in, path_out):
|
||||||
with open(path_in, 'r', encoding='utf8') as file:
|
with open(path_in, 'r', encoding='utf8') as file:
|
||||||
lines = file.readlines()
|
lines = file.readlines()
|
||||||
|
lines = lines.replace('.', ' ').replace(',', ' ').lower()
|
||||||
with open(path_out, 'wt')as file_out:
|
with open(path_out, 'wt')as file_out:
|
||||||
for i in lines:
|
for i in lines:
|
||||||
file_out.write("jurisdiction="+str(state_prediction(i))+'\n')
|
file_out.write("jurisdiction="+str(state_prediction(i))+'\n')
|
||||||
@ -55,7 +56,7 @@ jurisdiction('train/in.tsv', 'train/out.tsv')
|
|||||||
jurisdiction('test-A/in.tsv', 'test-A/out.tsv')
|
jurisdiction('test-A/in.tsv', 'test-A/out.tsv')
|
||||||
|
|
||||||
|
|
||||||
# In[ ]:
|
# In[22]:
|
||||||
|
|
||||||
|
|
||||||
# get_ipython().system('jupyter nbconvert --to script run.ipynb')
|
# get_ipython().system('jupyter nbconvert --to script run.ipynb')
|
||||||
|
@ -52,7 +52,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 20,
|
"execution_count": 23,
|
||||||
"id": "ea8069f7-de8e-454c-8eac-9fb7cc0df626",
|
"id": "ea8069f7-de8e-454c-8eac-9fb7cc0df626",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
@ -60,6 +60,7 @@
|
|||||||
"def jurisdiction(path_in, path_out): \n",
|
"def jurisdiction(path_in, path_out): \n",
|
||||||
" with open(path_in, 'r', encoding='utf8') as file:\n",
|
" with open(path_in, 'r', encoding='utf8') as file:\n",
|
||||||
" lines = file.readlines()\n",
|
" lines = file.readlines()\n",
|
||||||
|
" lines = lines.replace('.', ' ').replace(',', ' ').lower()\n",
|
||||||
" with open(path_out, 'wt')as file_out:\n",
|
" with open(path_out, 'wt')as file_out:\n",
|
||||||
" for i in lines:\n",
|
" for i in lines:\n",
|
||||||
" file_out.write(\"jurisdiction=\"+str(state_prediction(i))+'\\n') \n",
|
" file_out.write(\"jurisdiction=\"+str(state_prediction(i))+'\\n') \n",
|
||||||
@ -80,7 +81,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 22,
|
"execution_count": 24,
|
||||||
"id": "594a25a9-a0ce-4de9-82c8-df50a4ecac39",
|
"id": "594a25a9-a0ce-4de9-82c8-df50a4ecac39",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [
|
"outputs": [
|
||||||
@ -89,7 +90,7 @@
|
|||||||
"output_type": "stream",
|
"output_type": "stream",
|
||||||
"text": [
|
"text": [
|
||||||
"[NbConvertApp] Converting notebook run.ipynb to script\n",
|
"[NbConvertApp] Converting notebook run.ipynb to script\n",
|
||||||
"[NbConvertApp] Writing 1634 bytes to run.py\n"
|
"[NbConvertApp] Writing 1697 bytes to run.py\n"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
5
run.py
5
run.py
@ -35,12 +35,13 @@ def state_prediction(text_in):
|
|||||||
return max(state_dict, key=state_dict.get)
|
return max(state_dict, key=state_dict.get)
|
||||||
|
|
||||||
|
|
||||||
# In[20]:
|
# In[23]:
|
||||||
|
|
||||||
|
|
||||||
def jurisdiction(path_in, path_out):
|
def jurisdiction(path_in, path_out):
|
||||||
with open(path_in, 'r', encoding='utf8') as file:
|
with open(path_in, 'r', encoding='utf8') as file:
|
||||||
lines = file.readlines()
|
lines = file.readlines()
|
||||||
|
lines = lines.replace('.', ' ').replace(',', ' ').lower()
|
||||||
with open(path_out, 'wt')as file_out:
|
with open(path_out, 'wt')as file_out:
|
||||||
for i in lines:
|
for i in lines:
|
||||||
file_out.write("jurisdiction="+str(state_prediction(i))+'\n')
|
file_out.write("jurisdiction="+str(state_prediction(i))+'\n')
|
||||||
@ -55,7 +56,7 @@ jurisdiction('train/in.tsv', 'train/out.tsv')
|
|||||||
jurisdiction('test-A/in.tsv', 'test-A/out.tsv')
|
jurisdiction('test-A/in.tsv', 'test-A/out.tsv')
|
||||||
|
|
||||||
|
|
||||||
# In[ ]:
|
# In[22]:
|
||||||
|
|
||||||
|
|
||||||
# get_ipython().system('jupyter nbconvert --to script run.ipynb')
|
# get_ipython().system('jupyter nbconvert --to script run.ipynb')
|
||||||
|
Loading…
Reference in New Issue
Block a user