diff options
author | Yigit Sever | 2021-01-17 15:56:15 +0300 |
---|---|---|
committer | Yigit Sever | 2021-01-17 15:56:15 +0300 |
commit | 1c50f2ee41a5ece26cde93e9f5cf5b1036714651 (patch) | |
tree | d7cf02d642b5b46773af25cce2ca3ab2b5ca06fa /.local/bin/sentences | |
parent | 900d60db7fbef32a952b65f2daf262a5aa8a24ba (diff) | |
download | dotfiles-1c50f2ee41a5ece26cde93e9f5cf5b1036714651.tar.gz dotfiles-1c50f2ee41a5ece26cde93e9f5cf5b1036714651.tar.bz2 dotfiles-1c50f2ee41a5ece26cde93e9f5cf5b1036714651.zip |
tidy up sentences script
Diffstat (limited to '.local/bin/sentences')
-rwxr-xr-x | .local/bin/sentences | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/.local/bin/sentences b/.local/bin/sentences index a02d061..75314f5 100755 --- a/.local/bin/sentences +++ b/.local/bin/sentences | |||
@@ -1,16 +1,18 @@ | |||
1 | #!/usr/bin/perl | 1 | #!/usr/bin/perl |
2 | 2 | ||
3 | use strict; | 3 | use strict; |
4 | my $pont=qr{[.!?]+}; ## pontuation | ||
5 | my $abrev=qr{\b(?:Pr|Dr|Mr|[A-Z])\.}; ## abreviations | ||
6 | 4 | ||
7 | $/=""; | 5 | my $pont = qr{[.!?]+}; ## punctuation |
6 | my $abrev = qr{\b(?:Pr|Dr|Mr|[A-Z])\.}; ## abbreviations | ||
8 | 7 | ||
9 | while(<>){ chomp; ## for each paragraph, | 8 | $/ = ""; |
10 | 9 | ||
11 | s/\h*\n\h*/ /g; ## remove \n | 10 | while(<>) { |
12 | s/($pont)\h+(\S)/$1\n$2/g; ## pontuation+space | 11 | chomp; ## for each paragraph, |
13 | s/($abrev)\n/$1 /g; ## undo \n after abreviations | ||
14 | 12 | ||
15 | print "$_\n\n"; | 13 | s/\h*\n\h*/ /g; ## remove \n |
14 | s/($pont)\h+(\S)/$1\n$2/g; ## punctuation+space | ||
15 | s/($abrev)\n/$1 /g; ## undo \n after abbreviations | ||
16 | |||
17 | print "$_\n"; | ||
16 | } | 18 | } |