Skip to content

Instantly share code, notes, and snippets.

@aadps
Created July 7, 2021 18:57
Show Gist options
  • Save aadps/5f70cdd727620aff9a883eda18d432e1 to your computer and use it in GitHub Desktop.
Save aadps/5f70cdd727620aff9a883eda18d432e1 to your computer and use it in GitHub Desktop.
with open("/mnt/dev/lexicon.txt", "r") as file1, open("/mnt/dev/l.txt", "w") as file2:
for line in file1:
items = line.split("\t")
if items[3].startswith("nn"):
items[3] = "1"
elif items[3].startswith("vv"):
items[3] = "2"
elif items[3].startswith("jj"):
items[3] = "3"
elif items[3].startswith("rr"):
items[3] = "4"
else:
items[3] = "5"
new = "\t".join(items)+"\n"
file2.write(new)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment