Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- ## From:
- # Hi mom.how is DAD today?when he comes back HOME,tell him to cAll me; else, I will caLL him tomorrow . bye for noW.
- #
- #
- # Hi dad . How are you ??
- ## to
- # Hi mom. How is dad today? When he comes back home, tell him to call me; Else, I will call him tomorrow. Bye for now.
- #
- # Hi dad. How are you?
- # PREP = Pre-processing
- # POSTP = Post-processing
- FILE=~/testt
- # Read file, TODO: Check it exists?
- VALUE=$(cat "$FILE")
- # Remove duplicates of quoted characters PREP A / B
- for i in "?" ";" "!" "," " "; do
- VALUE=$(echo "$VALUE" | tr -s "$i")
- done
- # Lowercase all letters. PREP E
- VALUE=$(echo "$VALUE" | tr '[:upper:]' '[:lower:]')
- # Capitalize first letter at start of line. PREP D (in a way)
- VALUE=$(echo "$VALUE" | sed 's/^\s*./\U&\E/g')
- # Removes all spaces before special chars
- VALUE=$(echo "$VALUE" | sed 's/ \([\.!?;]\)/\1/g')
- # Removes all spaces after special chars
- VALUE=$(echo "$VALUE" | sed 's/\([\.!?,;]\)\s/\1/g')
- # Add spaces after special chars
- VALUE=$(echo "$VALUE" | sed 's/\([\.!?,;]\)/\1 /g')
- # Uppercase chars after special chars (. ! ? ;) PREP D
- VALUE=$(echo "$VALUE" | sed 's/[\.!?;]\s*./\U&\E/g')
- # Uppercase "I"s Not a PREP, but in example output
- VALUE=$(echo "$VALUE" | sed 's/\ i\ /\ I\ /g')
- echo "$VALUE"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement