File size: 1,740 Bytes
7725656
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
57
#!/bin/bash

# all available lang codes in Indonesia local-languages or linguistically-related to Indonesian Language:
# "ace", "ban", "bjn", "bug", "gor", "id", "jv", "map-bms", "min", "ms", "nia", "su", "tet"

#params of executions
folder_dir_to_save=./indo_wiki_dedup
input_folder_to_be_dedup=./indo_wiki_raw

drop_hard_dupl=True
drop_soft_dupl=True


# main executions

# src: https://stackoverflow.com/a/18887210 (to list all files under a dir)
shopt -s nullglob
file_name_array=($input_folder_to_be_dedup/*)
shopt -u nullglob # Turn off nullglob to make sure it doesn't interfere with anything later
file_name_array="${file_name_array}"

if [ ${#file_name_array[@]} == 0 ]; then
    echo "No files found under directory $input_folder_to_be_dedup" >&2
fi

if [ ! -d $folder_dir_to_save ];
then
    echo "Dir $folder_dir_to_save not exists! Creating the dir..."
    mkdir $folder_dir_to_save
fi

echo "The params hard-dedup drop is set as $drop_hard_dupl"
echo "The params soft-dedup drop is set as $drop_soft_dupl"

# echo "${file_name_array[0]}"
# echo "${file_name_array[1]}"
# echo "${file_name_array[2]}"
# echo "${file_name_array[3]}"

for val in ${!file_name_array[@]}; do
    csv_path=${file_name_array[$val]}

    if [[ ${csv_path} != *".csv" ]]; then
        echo "The extracted file name isn't a CSV! Skipping! Received $csv_path"
        continue
    fi

    echo "Executing Dedup on iteration no "$((val+1))" of total ${#file_name_array[@]} for input data $csv_path"
    python cleanse_wiki_data.py \
        --raw-csv-path $csv_path \
        --drop-hard-dupl $drop_hard_dupl \
        --drop-soft-dupl $drop_soft_dupl \
        --save-dir-path $folder_dir_to_save
    echo "Done Execution"
done
echo "Done Dedup Process"