-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathformat_data.sh
More file actions
executable file
·37 lines (29 loc) · 926 Bytes
/
format_data.sh
File metadata and controls
executable file
·37 lines (29 loc) · 926 Bytes
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
#/bin/bash
src_path=$1
src_name=$(basename $src_path)
if [ $src_name == 'tweets_clean.txt' ]; then
cat $src_path \
| awk -F'\t' '{print($2, "\t", $3)}' \
| sed -e 's/\t\s*::\s*/\t/' -e 's/"//g' \
| sed -e 's/</</g' -e 's/>/>/g' -e 's/&/\&/g' -e "s/"/'/g"
exit
fi
if [ $src_name == 'text_emotion.csv' ]; then
cat $src_path \
| tail -n +2 \
| python3 -c 'import csv, sys; csv.writer(sys.stdout, dialect="excel-tab").writerows(csv.reader(sys.stdin))' \
| sed -e 's///g' -e 's/"//g' \
| sed -e 's/</</g' -e 's/>/>/g' -e 's/&/\&/g' -e "s/"/'/g" \
| awk -F'\t' '{print $4"\t"$2}'
exit
fi
src_dir_name=$(basename $(dirname $src_path))
if [ $src_dir_name == 'semeval2018' ]; then
cat $src_path \
| tail -n +2 \
| sed -e 's///g' -e 's/"//g' \
| sed -e 's/</</g' -e 's/>/>/g' -e 's/&/\&/g' -e "s/"/'/g" \
exit
fi