Skip to content

Commit

Permalink
rebuild prior to publishing
Browse files Browse the repository at this point in the history
  • Loading branch information
tbrowder committed Jan 20, 2024
1 parent c84b54b commit 0df5b9a
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 11 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,16 @@ DESCRIPTION

**Abbreviations** is a module with one automatically exported subroutine, `abbreviations`, which takes as input a set of words and returns the original set with added unique abbreviations for the set. (Note the input words are also abbreviations in the context of this module.)

A natural consequence of generating all the abbreviations for a set of one word is this: the ouput provides the parts of a junction which matches any partial length of the target word. For example, given a target word 'Args':
A natural consequence of generating all the abbreviations for a set of one word is this: the output provides a regex alternation which matches any partial length of the target word. For example, given a target word 'Args':

use Abbreviations;
use Test;
my $target = "Args";
my $junction = abbrev $target; # OUTPUT: «"A|Ar|Arg|Args"␤»;
my $regex = abbrev $target; # OUTPUT: «"A|Ar|Arg|Args"␤»;
my $res = False;
my @w = $junction.split('|');
my @w = $regex.split('|');
for @w {
when /$junction/ {
when /<$regex>/ {
$res = True
}
default {
Expand All @@ -50,7 +50,7 @@ Its signature:

A *word* satisfies the Raku regex `$word ~~ /\S+/` which is quite loose. Using programs can of course further restrict that if need be. For example, for use with module **Opt::Handler** words must satisfy this regex: `$word ~~ /<ident>/`.

The input word set can be in one of three forms: (1) a list (recommended), (2) a string containing the words separated by spaces, or (3) as a hash (or set) with the words being keys of the hash (set members). Duplicate words will be automatically and quietly eliminated.
As shown in the example above, limiting the input set to one word results in the output of a regex alternation string. The rest of this description applies to sets of two or more words. The input word set can be in one of three forms: (1) a list (recommended), (2) a string containing the words separated by spaces, or (3) as a hash (or set) with the words being keys of the hash (set members). Duplicate words will be automatically and quietly eliminated.

Note the input word set will not be modified unless the `:lower-case` option is used. In that case, all characters will be transformed to lower-case and any new duplicate words deleted.

Expand Down
13 changes: 8 additions & 5 deletions docs/README.rakudoc
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,20 @@ returns the original set with added unique abbreviations for the set.
module.)

A natural consequence of generating all the abbreviations for a
set of one word is this: the ouput
provides the parts of a junction which matches any
set of one word is this: the output
provides a regex alternation which matches any
partial length of the target word. For example, given a target
word 'Args':

=begin code
use Abbreviations;
use Test;
my $target = "Args";
my $junction = abbrev $target; # OUTPUT: «"A|Ar|Arg|Args"␤»;
my $regex = abbrev $target; # OUTPUT: «"A|Ar|Arg|Args"␤»;
my $res = False;
my @w = $junction.split('|');
my @w = $regex.split('|');
for @w {
when /$junction/ {
when /<$regex>/ {
$res = True
}
default {
Expand All @@ -62,6 +62,9 @@ loose. Using programs can of course further restrict that if need
be. For example, for use with module B<Opt::Handler> words must
satisfy this regex: C<$word ~~ /<ident>/>.

As shown in the example above, limiting the input set to one word
results in the output of a regex alternation string. The rest
of this description applies to sets of two or more words.
The input word set can be in one of three forms: (1) a list
(recommended), (2) a string containing the words separated by spaces,
or (3) as a hash (or set) with the words being keys of the hash (set
Expand Down
19 changes: 18 additions & 1 deletion t/9-junction.t
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,24 @@ use Subs;

my $debug = 0;

plan 6;
plan 7;

{
# Example from the README
my $target = "Args";
my $regex = abbrev $target; # OUTPUT: «"A|Ar|Arg|Args"␤»;
my $res = False;
my @w = $regex.split('|');
for @w {
when /<$regex>/ {
$res = True
}
default {
$res = False
}
}
is $res, True; # OUTPUT: «ok 1␤»
}

# Single word
my $target = "Args";
Expand Down

0 comments on commit 0df5b9a

Please sign in to comment.