Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Module name matching

Tags:

raku

I have a list of module names, as Strs, extracted from the META6.json. Specifically, the depends array. This contains the following entries:

"Config::Parser::toml:ver<1.0.1+>",                                   
"Config:api<1>:ver<1.3.5+>",                                      
"Dist::Helper:ver<0.21.0+>",                                      
"Hash::Merge",                                                  
"Terminal::Getpass:ver<0.0.5+>",

How can I best match individual entries? Doing eq string matches isn't specific enough, as Config wouldn't match Config:api<1>:ver<1.3.5+> as a string. Trying to match using .starts-with also wouldn't work correctly, as Config:ver<1.3.5> wouldn't match Config:api<1>:ver<1.3.5>.

like image 646
Tyil Avatar asked Jul 10 '18 23:07

Tyil


People also ask

What is fuzzy name matching?

What is fuzzy name matching? Fuzzy matching assigns a probability to a match between 0.0 and 1.0 based on linguistic and statistical methods instead of just choosing either 1 (true) or 0 (false). As a result, names Robert and Bob can be a match with high probability even though they're not identical.

What is first name matching failure?

Reasons for an invalid surname or first name error? These errors occur when the surname you registered your PAN card with does not match the surname you are trying to key in on the income tax portal. Many websites adopt the Western naming conventions, wherein they are required to enter surname, first name, middle name.

What is fuzzy matching example?

Fuzzy Matching (also called Approximate String Matching) is a technique that helps identify two elements of text, strings, or entries that are approximately similar but are not exactly the same. For example, let's take the case of hotels listing in New York as shown by Expedia and Priceline in the graphic below.


1 Answers

use Zef::Distribution::DependencySpecification;

my $spec-ver-all     = Zef::Distribution::DependencySpecification.new("Foo::Bar");
my $spec-ver-zero    = Zef::Distribution::DependencySpecification.new("Foo::Bar:ver<0>");
my $spec-ver-one     = Zef::Distribution::DependencySpecification.new("Foo::Bar:ver<1>");
my $spec-ver-oneplus = Zef::Distribution::DependencySpecification.new("Foo::Bar:ver<1+>");
my $spec-ver-two     = Zef::Distribution::DependencySpecification.new("Foo::Bar:ver<2>");
my $spec-ver-three   = Zef::Distribution::DependencySpecification.new("Foo::Bar:ver<3>");

say $spec-ver-one.spec-matcher($spec-ver-all);         # True
say $spec-ver-one.spec-matcher($spec-ver-two);         # False
say $spec-ver-zero.spec-matcher($spec-ver-oneplus);    # False
say $spec-ver-oneplus.spec-matcher($spec-ver-oneplus); # True
say $spec-ver-three.spec-matcher($spec-ver-oneplus);   # True
like image 109
ugexe Avatar answered Nov 15 '22 23:11

ugexe