Page MenuHomePhabricator
Paste P8758

(An Untitled Masterwork)
ActivePublic

Authored by awight on Jul 17 2019, 9:42 AM.
Tags
None
Referenced Files
F29790676: raw.txt
Jul 17 2019, 9:42 AM
Subscribers
None
#!/usr/bin/env python3
import csv
import json
def load_occupations():
with open("occupations.json") as f:
raw_data = json.load(f)
# Skip items without a label.
return [line["itemLabel"] for line in raw_data if \
not line["item"].endswith(line["itemLabel"])]
def load_demonyms():
with open("demonyms.json") as f:
raw_data = json.load(f)
# Skip items without a label.
return [line["itemLabel"] for line in raw_data if \
not line["item"].endswith(line["itemLabel"])]
def generate_fgrep(occupations):
with open("grep_cats.txt", "w") as out:
for occupation in occupations:
print('([^A-Za-z0-9]|\\b)' + occupation + '([^A-Za-z0-9]|\\b)', file=out)
if __name__ == "__main__":
generate_fgrep(load_occupations())