Skip to content

Commit

Permalink
#95 commennt update_data and minor code changes
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewtavis committed Jan 12, 2022
1 parent 6c2ed0d commit 55b8bb8
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions Data/update_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
Updates all data for Scribe by running all WDQS queries and formatting scripts.
"""


import json
import os
import sys
Expand Down Expand Up @@ -41,9 +40,6 @@
language = sys.argv[1]
word_type = sys.argv[2]

print(language)
print(word_type)

# Derive Data directory elements for potential queries.
data_dir_elements = []

Expand Down Expand Up @@ -101,7 +97,7 @@

data_added_dict = {}

for q in tqdm(queries_to_run[:1], desc="Data updated", unit="dirs",):
for q in tqdm(queries_to_run, desc="Data updated", unit="dirs",):
target_type = q.split("/")[1]
query_name = "query" + target_type.title() + ".sparql"
query_path = "./" + q + "/" + query_name
Expand All @@ -117,6 +113,7 @@

query_results = query["results"]["bindings"]

# Format and save the resulting JSON.
results_formatted = []
for r in query_results: # query_results is also a list
r_dict = {k: r[k]["value"] for k in r.keys()}
Expand All @@ -130,6 +127,7 @@
) as f:
json.dump(results_formatted, f, ensure_ascii=False, indent=2)

# Call the corresponding formatting file and update data changes.
call(
["python", f"./{q.split('/')[0]}/{q.split('/')[1]}/format_{q.split('/')[1]}"],
shell=True,
Expand Down

0 comments on commit 55b8bb8

Please sign in to comment.