forked from anthonyprinaldi/code_tree_generator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget_training_data
executable file
·56 lines (47 loc) · 1.34 KB
/
get_training_data
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/bin/bash
venv_path="venv"
search_dir="$1"
adj_dir="../adj/"
node_feat_dir="../node_feats/"
if [ ! -d "$search_dir" ]; then
echo "Directory does not exist: $search_dir"
exit 1
fi
if [ ! -d "$venv_path" ]; then
echo "Virtual env path does not exist: $venv_path"
exit 1
fi
if [ -f "../$(basename "$0").log" ]; then
echo "Removing old log file ../$(basename "$0").log"
rm "../$(basename "$0").log"
fi
if [ ! -d "$adj_dir" ]; then
echo "${adj_dir} does not exist...creating"
mkdir "$adj_dir"
fi
if [ ! -d "$node_feat_dir" ]; then
echo "${node_feat_dir} does not exist...creating"
mkdir "$node_feat_dir"
fi
source "${venv_path}/bin/activate"
echo $(ls "$search_dir" | wc -l) "files to process"
for folder in $(ls "$search_dir"); do
full_path="${search_dir}${folder}"
if [ -d "$full_path" ]; then
base="$(basename "$full_path")"
echo -n "${base}..."
if [ ! -f "${adj_dir}${base}.npz" ] && [ ! -f "${node_feat_dir}${base}.csv" ]; then
# run the python script for generating the tree
python3 parser.py \
--dir "$full_path" \
--nf "${node_feat_dir}${base}" \
--adj "${adj_dir}${base}" \
--dim "$2" >> "../$(basename "$0").log"
echo "Done"
else
echo "Skipping (exists)"
fi
fi
done
echo "Done generating all trees."
echo "Log file generated: ../$(basename "$0").log"