e03e65987a844db3dddfdc2dd085358a3ff3634f
3 # Function to replace contractions
4 replace_contractions
() {
5 # Desc: Replace ' with ʼ in contractions
6 # Note: In contractions of UTF-8 text file, replaces U+0027
7 # APOSTROPHE with U+02BC MODIFIER LETTER APOSTROPHE
11 # Version: 0.1.1 (BK-2020-03)
12 # Depends: GNU sed 4.8
15 if [[ "$#" -gt 1 ]]; then
16 echo "FATAL:Incorrect argument count:$#" 1>&2;
20 if [[ -f "$1" ]]; then
28 # Perform substitutions
29 ## Note: See https://en.wiktionary.org/wiki/Category:English_contractions
30 ## Note: Order of replacements sorted most-specific first.
32 -e "s/(you|You|YOU)'(ren|REN|ven|VEN)'(t|T)/\1ʼ\2ʼ\3/g" \
33 -e "s/(you|You|YOU)'(dn|DN)'(t|T)'(ve|VE)/\1ʼ\2ʼ\3ʼ\4/g" \
34 -e "s/(you|You|YOU)'(d|D|ll|LL)'(ve|VE)/\1ʼ\2ʼ\3/g" \
35 -e "s/(you|You|YOU)'(d|D|ll|LL|re|RE|ve|VE)/\1ʼ\2/g" \
36 -e "s/(y|Y)'(all|ALL)'(dn|DN)'(t|T)'(ve|VE)/\1ʼ\2ʼ\3ʼ\4ʼ\5/g" \
37 -e "s/(y|Y)'(all|ALL)'(d|D)'(nt|NT)'(ve|VE)/\1ʼ\2ʼ\3ʼ\4ʼ\5/g" \
38 -e "s/(y|Y)'(all|ALL)'(d|D)'(ve|VE)/\1ʼ\2ʼ\3ʼ\4/g" \
39 -e "s/(y|Y)'(all|ALL)'(d|D|ll|LL|re|RE|ve|VE)/\1ʼ\2ʼ\3/g" \
40 -e "s/(y|Y)'(all|ALL)/\1ʼ\2/g" \
41 -e "s/(y|Y)'(ain|AIN)'(t|T)/\1ʼ\2ʼ\3/g" \
42 -e "s/(wouldn|Wouldn|WOULDN)'(t|T)'(ve|VE)/\1ʼ\2ʼ\3/g" \
43 -e "s/(wouldn|Wouldn|WOULDN)'(t|T)/\1ʼ\2/g" \
44 -e "s/(won|Won|WON)'(t|T)'(ve|VE)/\1ʼ\2ʼ\3/g" \
45 -e "s/(won|Won|WON)'(t|T)/\1ʼ\2/g" \
46 -e "s/(who|Who|WHO)'(d|D|ll|LL)'(ve|VE)/\1ʼ\2ʼ\3/g" \
47 -e "s/(who|Who|WHO)'(d|D|ll|LL|re|RE|s|S|ve|VE)/\1ʼ\2/g" \
48 -e "s/(where|Where|WHERE)'(s|S)/\1ʼ\2/g" \
49 -e "s/(what|What|WHAT)'(ll|LL|re|RE|s|S|ve|VE)/\1ʼ\2/g" \
50 -e "s/(weren|Weren|WEREN)'(t|T)/\1ʼ\2/g" \
51 -e "s/(we|We|WE)'(ven|VEN)'(t|T)/\1ʼ\2ʼ\3/g" \
52 -e "s/(we|We|WE)'(ren|REN)'(t|T)/\1ʼ\2ʼ\3/g" \
53 -e "s/(we|We|WE)'(d|D|ll|LL)'(ve|VE)/\1ʼ\2ʼ\3/g" \
54 -e "s/(we|We|WE)'(d|D|ll|LL|re|RE|ve|VE)/\1ʼ\2/g" \
55 -e "s/(they|They|THEY)'(d|D|ll|LL)'(ve|VE)/\1ʼ\2ʼ\3/g" \
56 -e "s/(they|They|THEY)'(d|D|ll|LL|re|RE|ve|VE)/\1ʼ\2/g" \
57 -e "s/(there|There|THERE)'(ll|LL)'(ve|VE)/\1ʼ\2ʼ\3/g" \
58 -e "s/(there|There|THERE)'(s|S|ve|VE)/\1ʼ\2/g" \
59 -e "s/(that|That|THAT)'(d|D|ll|LL)'(ve|VE)/\1ʼ\2ʼ\3/g" \
60 -e "s/(that|That|THAT)'(d|D|ll|LL|s|S)/\1ʼ\2/g" \
61 -e "s/(shouldn|Shouldn|SHOULDN)'(t|T)'(ve|VE)/\1ʼ\2ʼ\3/g" \
62 -e "s/(shouldn|Shouldn|SHOULDN)'(t|T)/\1ʼ\2/g" \
63 -e "s/(she|She|SHE)'(d|D|ll|LL)'(ve|VE)/\1ʼ\2ʼ\3/g" \
64 -e "s/(she|She|SHE)'(d|D|ll|LL|s|S)/\1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|Hadn|HADN)'(t|T)/\1ʼ\2/g" \
87 -e "s/(d|D)'(ya|YA|you|YOU)/\1ʼ\2/g" \
88 -e "s/(don|Don|DON)'(t|T)/\1ʼ\2/g" \
89 -e "s/(doesn|Doesn|DOESN)'(t|T)/\1ʼ\2/g" \
90 -e "s/(didn|Didn|DIDN)'(t|T)/\1ʼ\2/g" \
91 -e "s/(could|Could|COULD)'(ve|VE)/\1ʼ\2/g" \
92 -e "s/(couldn|Couldn|COULDN)'(t|T)'(ve|VE)/\1ʼ\2ʼ\3/g" \
93 -e "s/(couldn|Couldn|COULDN)'(t|T)/\1ʼ\2/g" \
94 -e "s/(can|Can|CAN)'(t|T)'(ve|VE)/\1ʼ\2ʼ\3/g" \
95 -e "s/(can|Can|CAN)'(t|T)/\1ʼ\2/g" \
96 -e "s/(aren|Aren|AREN)'(t|T)/\1ʼ\2/g" \
97 -e "s/(ate|Ate|ATE)'(nt|NT)/\1ʼ\2/g" \
98 -e "s/(ain|Ain|AIN)'(t|T)/\1ʼ\2/g" \
100 }; # replace ' with ʼ in contractions
102 # Author: Steven Baltakatei Sandoval