summaryrefslogtreecommitdiffstats
path: root/.local/bin/sentences
diff options
context:
space:
mode:
Diffstat (limited to '.local/bin/sentences')
-rwxr-xr-x.local/bin/sentences10
1 files changed, 6 insertions, 4 deletions
diff --git a/.local/bin/sentences b/.local/bin/sentences
index 75314f5..cc21d3b 100755
--- a/.local/bin/sentences
+++ b/.local/bin/sentences
@@ -4,15 +4,17 @@ use strict;
4 4
5my $pont = qr{[.!?]+}; ## punctuation 5my $pont = qr{[.!?]+}; ## punctuation
6my $abrev = qr{\b(?:Pr|Dr|Mr|[A-Z])\.}; ## abbreviations 6my $abrev = qr{\b(?:Pr|Dr|Mr|[A-Z])\.}; ## abbreviations
7my $header = qr{(=+ .*? =+)};
7 8
8$/ = ""; 9$/ = "";
9 10
10while(<>) { 11while(<>) {
11 chomp; ## for each paragraph, 12 chomp; ## for each paragraph,
12 13
13 s/\h*\n\h*/ /g; ## remove \n 14 s/\h*\n\h*/ /g; ## remove \n
14 s/($pont)\h+(\S)/$1\n$2/g; ## punctuation+space 15 s/($pont)\h+(\S)/$1\n$2/g; ## punctuation+space
15 s/($abrev)\n/$1 /g; ## undo \n after abbreviations 16 s/($abrev)\n/$1 /g; ## undo \n after abbreviations
17 s/$header\h+(\S)/$1\n$2/g; ## vimwiki headers
16 18
17 print "$_\n"; 19 print "$_\n";
18} 20}