On 12/31/2018, at 13:54, Dj <[email protected] <mailto:[email protected]>> wrote: > Mike, that makes a lot more sense now. I looked at page for the Module and it > seems it's run from terminal and OSX has perl pre-installed?
Hey Dj, BBEdit can run shell scripts as Text-Filters, and they do not need to be run from the Terminal. BBEdit text-filters operate on the selection if there is one, otherwise they operate on the whole front document. Text filters are installed here: ~/Library/Application Support/BBEdit/Text Filters/ Text filters are run from: BBEdit Menu Bar > Text > Apply Text Filter > <your_filter> And of course you can give them keyboard shortcuts in BBEdit's Menus & Shortcuts preferences. http://www.bbeditextras.org/wiki/index.php?title=Text_Filters <http://www.bbeditextras.org/wiki/index.php?title=Text_Filters> See the User Manual for more details. > Or is it a "module" than can be run somehow from within BBEdit? Perl comes pre-installed on macOS, although it's usually a fairly old version. The module Mike recommends is something you the user have to install, and that's probably more complication than you want to mess with. For that matter it doesn't really do the job in and of itself. It requires additional coding. A Perl script using the Lingua module that'll run as a BBEdit Text Filter would looks something like this: #!/usr/bin/env perl -0777 -sw use v5.12; use utf8; use Lingua::EN::Sentence qw( get_sentences add_acronyms ); my $text = <>; add_acronyms('lt','gen'); ## adding support for 'Lt. Gen.' my $sentences = get_sentences($text); ## Get the sentences. foreach my $sentence (@$sentences) { if ( $sentence =~ /(\b\w[^.!]+?\?)/ ) { say $1; } } It produces this: —Eskimo proverb What can be added to the happiness of man who is in health, out of debt, and has a clear conscience? —Adam Smith Do you prefer that you be right, or that you be happy? What am I doing right? —Tom Walsh Why not seize the pleasure at once? How often is happiness destroyed by preparation, foolish preparation? Unhappiness Is anyone in all the world safe from unhappiness? —Vauvenargues Why is it that so many people are afraid to admit that they are happy? —Maurice Maeterlinck Who is the happiest of men? Da vies Is life so wretched? Isn't it rather your hands which are too small, your vision which is muddled? —Marcus Cato the Elder If you haven't forgiven yourself something, how can you forgive others? —Mark Twain How shall I love the sin, yet keep the sense, And love the offender, yet detest the offence? —George Macdonald Who would care to question the ground of forgiveness or compassion? —Socrates Who Is Really Poor? —Japanese proverb Who Is Really Rich? —Colette Was it always my nature to take a bad time and block out the good times, until any success became an accident and failure seemed the only truth? Next to what? Which is nearly the same result as my plain regular expression. I can accomplish the same result as the script using the Lingua module without using it: #!/usr/bin/env perl -0777 -sw use v5.12; use utf8; my $text = <>; my @array = $text =~ /(\b\w[^.!]+?\?)/gms; $, = "\n"; say @array; Perl is a wonderful tool for parsing text, but learning it requires a pretty sizable investment. -- Best Regards, Chris -- This is the BBEdit Talk public discussion group. If you have a feature request or need technical support, please email "[email protected]" rather than posting to the group. Follow @bbedit on Twitter: <https://www.twitter.com/bbedit> --- You received this message because you are subscribed to the Google Groups "BBEdit Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/bbedit.
