Skip to content

Commit

Permalink
fix data_dir in util
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmad88me committed Apr 23, 2020
1 parent 1b0b00a commit 5c94fa3
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 11 deletions.
4 changes: 2 additions & 2 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ def editor():
if headers == []:
error_msg = "Can't parse the source file "
return render_template('msg.html', msg=error_msg, msg_title="Error")
labels = util.get_classes_as_txt(ontologies)
labels = util.get_classes_as_txt(ontologies, data_dir=DATA_DIR)
# f = open(os.path.join(DATA_DIR, "labels.txt"))
return render_template('editor.html', labels_txt=labels, ontologies_txt=",".join(ontologies), headers=headers,
callback=callback_url, file_name=fname, error_msg=error_msg, warning_msg=warning_msg)
Expand All @@ -187,7 +187,7 @@ def editor():
def get_properties():
ontologies_txt = request.args.get('ontologies')
ontologies = ontologies_txt.split(',')
return jsonify({'properties': util.get_properties_as_list(ontologies)})
return jsonify({'properties': util.get_properties_as_list(ontologies, data_dir=DATA_DIR)})


@app.route("/get_properties_autocomplete")
Expand Down
2 changes: 1 addition & 1 deletion generate_lookup.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def build_property_lookup(dataset_name,properties_fdir, data_dir):
:return:
"""
print("build_property_lookup> dataset_name: "+dataset_name)
properties = util.get_properties_as_list([dataset_name])
properties = util.get_properties_as_list([dataset_name], data_dir=data_dir)
# start_idx = predict_base_URL(properties)
lookup_name = 'lookup'
lookup_folder_dir = os.path.join(data_dir,dataset_name,lookup_name)
Expand Down
12 changes: 4 additions & 8 deletions util.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@
import os


#DATA_DIR = os.path.join(BASE_DIR, 'data')
DATA_DIR = 'data'


def get_random_string(length=4):
return ''.join(random.choice(string.lowercase) for i in range(length))

Expand Down Expand Up @@ -218,26 +214,26 @@ def get_classes_from_file(odir):
return classes


def get_properties_as_list(ontologies):
def get_properties_as_list(ontologies, data_dir):
"""
:param ontologies:
:return:
"""
properties = []
for o in ontologies:
odir = os.path.join(DATA_DIR, o, 'properties.txt')
odir = os.path.join(data_dir, o, 'properties.txt')
properties += get_classes_from_file(odir)
return properties


def get_classes_as_txt(ontologies):
def get_classes_as_txt(ontologies, data_dir):
"""
:param ontologies:
:return:
"""
classes = []
for o in ontologies:
odir = os.path.join(DATA_DIR, o, 'classes.txt')
odir = os.path.join(data_dir, o, 'classes.txt')
classes += get_classes_from_file(odir)
# return classes
txt = ""
Expand Down

0 comments on commit 5c94fa3

Please sign in to comment.