-
Notifications
You must be signed in to change notification settings - Fork 1
/
search_typos_exclude.sh
70 lines (58 loc) · 2 KB
/
search_typos_exclude.sh
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
63
64
65
66
67
68
69
70
###
# @Author: Shuangchi He / Yulv
# @Email: [email protected]
# @Date: 2022-04-30 21:40:21
# @Motto: Entities should not be multiplied unnecessarily.
# @LastEditors: Shuangchi He
# @LastEditTime: 2022-06-04 11:04:17
# @FilePath: /Search-for-Typos/search_typos_exclude.sh
# @Description: Search for typos in code or text.
# Repository: https://github.com/Yulv-git/Search-for-Typos
###
current_dir=$(cd `dirname $0`; pwd)
target_dir="$1"
exclude="$2"
echo "target_dir: ${target_dir}"
echo "exclude: ${exclude}"
# repeated English words
while read item
do
item=`echo ${item} | sed 's/\r//'`
item2="${item} ${item}"
echo
echo "Could the word '${item}' be repeated???"
grep -r -i -w -n --color=auto "${item2}" ${target_dir} --exclude=${exclude}
done < ${current_dir}/typos_lib/repeated_English_words.txt
# repeated Chinese characters
while read item
do
item=`echo ${item} | sed 's/\r//'`
item2="${item}${item}"
echo
echo "Could the character '${item}' be repeated???"
grep -r -n --color=auto "${item2}" ${target_dir} --exclude=${exclude}
done < ${current_dir}/typos_lib/repeated_Chinese_characters.txt
# typos of English words/strings
while read item
do
item=`echo ${item} | sed 's/\r//'`
echo
echo "Could the word/string '${item}' be a typo???"
grep -r -i -n --color=auto "${item}" ${target_dir} --exclude=${exclude}
done < ${current_dir}/typos_lib/typos_English_words_strings.txt
# wrong Chinese phrases
while read item
do
item=`echo ${item} | sed 's/\r//'`
echo
echo "Is this Chinese phrase '${item}' used wrong???"
egrep -r -n --color=auto "${item}" ${target_dir} --exclude=${exclude}
done < ${current_dir}/typos_lib/wrong_Chinese_phrases.txt
# wrong English phrases
while read item
do
item=`echo ${item} | sed 's/\r//'`
iitem2=${item//"Space=Blank"/" "}
echo "Is this English phrase '${item2}' used wrong???"
grep -r -i -w -n --color=auto "${item2}" ${target_dir} --exclude=${exclude}
done < ${current_dir}/typos_lib/wrong_English_phrases.txt