Skip to content

Commit

Permalink
reruns
Browse files Browse the repository at this point in the history
  • Loading branch information
sanjanasrivastava committed Aug 4, 2023
1 parent 654daab commit 867ba0b
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 3 deletions.
1 change: 0 additions & 1 deletion bddl/data_generation/generate_datafiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from bddl.data_generation.get_syn_prop_annots_canonical import create_get_save_annots_canonical, create_get_save_properties_to_synsets, create_get_save_synsets_to_descriptors
from bddl.data_generation.propagate_by_intersection import create_get_save_propagated_canonical
from bddl.data_generation.process_prop_param_annots import create_get_save_propagated_annots_params
# from bddl.data_generation.parse_tm_cleaning_csv import parse_tm_cleaning_csv
import pandas as pd
import csv
import nltk
Expand Down
2 changes: 2 additions & 0 deletions bddl/data_generation/get_hierarchy_full.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,13 @@ def get_hierarchy(syn_prop_dict):


def create_get_save_hierarchy_with_properties(hierarchy):
print("Adding params to hierarchy file...")
with open(SYN_PROP_PARAM_FN) as f:
syn_prop_param_dict = json.load(f)
add_properties(hierarchy, syn_prop_param_dict)
with open(HIERARCHY_PROPERTIES_OUTPUT_FN, "w") as f:
json.dump(hierarchy, f, indent=2)
print("Added params to hierarchy file, saved.")
return hierarchy


Expand Down
6 changes: 6 additions & 0 deletions bddl/data_generation/get_syn_prop_annots_canonical.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,21 +175,27 @@ def get_synset_descriptors(synsets_to_filtered_properties): # take in canonical
# API - only these should be used outside these script, and these should only be used outside this script

def create_get_save_annots_canonical(syn_prop_dict):
print("Creating canonical annots file...")
canonical = get_annots_canonical(syn_prop_dict)
with open(CANONICAL_FN, "w") as f:
json.dump(canonical, f, indent=4)
print("Created and saved canonical annots file.")
return canonical

def create_get_save_properties_to_synsets(propagated_canonical):
print("Creating properties to synsets...")
props_to_syns = make_properties_to_synsets(propagated_canonical)
with open(PROP_TO_SYN_FILE, "w") as f:
json.dump(props_to_syns, f, indent=4)
print("Created and saved properties to synsets file.")
return props_to_syns

def create_get_save_synsets_to_descriptors(propagated_canonical):
print("Creating synsets to descriptors...")
syn_to_desc = get_synset_descriptors(propagated_canonical)
with open(SYN_TO_DESC_FILE, "w") as f:
json.dump(syn_to_desc, f, indent=4)
print("Created and saved synset to descriptor file.")
return syn_to_desc


Expand Down
4 changes: 3 additions & 1 deletion bddl/data_generation/process_prop_param_annots.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ def get_synsets_to_particle_remover_params():
# Main parameter method

def create_get_save_propagated_annots_params(syns_to_props):
print("Processing param annots...")

synsets_to_particleremover_params = get_synsets_to_particle_remover_params()
for particleremover_syn, particleremover_params in synsets_to_particleremover_params.items():
Expand Down Expand Up @@ -207,9 +208,10 @@ def create_get_save_propagated_annots_params(syns_to_props):

syns_to_props[param_record["synset"]][prop][param_name] = formatted_param_value


with open(PARAMS_OUTFILE_FN, "w") as f:
json.dump(syns_to_props, f, indent=4)

print("Params parsed and added to flat and hierarchical files, saved.")


if __name__ == "__main__":
Expand Down
2 changes: 1 addition & 1 deletion bddl/generated_data/prop_param_annots/heatSource.csv
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ engine.n.01,1,0,0,90
pressure_cooker.n.01,1,1,1,121
stove.n.01,1,0,0,1980
sauna_heater.n.01,1,0,0,77
space_heater.n.01,1,0,0,42
space_heater.n.01,1,0,0,42

0 comments on commit 867ba0b

Please sign in to comment.