File size: 2,142 Bytes
550da22
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
58
59
60
61
62
#!/bin/bash

# all available lang codes in SEA local-languages or linguistically-related to following countries in SEA:
# Indonesia: "ace" (Acehnese), "ban" (Balinese), "bjn" (Banjarese), "bug" (Buginese), "gor" (Gorontalo), "id" (Indonesian), "jv" (Javanese), "mad" (Madurese), "map-bms" (Banyumasan, Dialect of Javanese), "min" (Minangkabau), "ms" (Malay), "nia" (Nias), "su" (Sundanese), "tet" (Tetum)
# Singapore: "ms" (Malay)
# Malaysia: "ms" (Malay)
# Brunei: "ms" (Malay)
# Thailand: "th" (Thai)
# Myanmar: "my" (Burmese), "shn" (Shan), "mnw" (Mon)
# Laos: "lo" (Lao)
# Vietnam: "vi" (Vietnamese)
# Cambodia: "km" (Khmer)
# East Timor: "tet" (Tetum)

#params of executions
folder_dir_to_save=./sea_wiki_dedup_data
input_folder_to_be_dedup=./sea_wiki_raw_data

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"

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"
    #see the script bcs there are more args than this command is using
    python dedup_raw_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"