Regexp::Pattern::License - Regular expressions for legal licenses
Version v3.9.3
use Regexp::Pattern::License;
use Regexp::Pattern;
my $string = 'GNU General Public License version 3 or later';
print "Found!\n" if $string =~ re( 'License::gpl_3' ); # prints "Found!"
the Regexp::Pattern::License manpage provides a hash of regular expression patterns
related to legal software licenses.
the Regexp::Pattern manpage is a convention for organizing reusable regex patterns.
Patterns each covering a single trait occuring in licenses.
Each of these patterns has the tag type:trait .
Patterns each covering a single license.
Each of these patterns has exactly one of these tags:
type:unversioned
type:versioned:decimal
type:singleversion:*
type:usage:*:*
.
Patterns each covering a combination of multiple licenses.
Each of these patterns has the tag type:combo .
Patterns each covering either of multiple licenses.
Each of these patterns has the tag type:group .
The regexp patterns follows the DefHash specification,
and more specifically the structure of the Regexp::Pattern manpage,
defining access to one pattern per DefHash object, as pat.
Additionally, (sub)patterns are available in plaintext form, as pat.alt.*.
Each pattern targets one or more subjects,
i.e. ways to directly or indirectly represent a license.
Beware that not all pattern objects fully cover all subjects.
- trait
-
Distinguishing trait or feature expressed in licensing strings,
e.g. an advertising clause or granting ``...or any later version.''
Coverage for this subject is currently rather weak.
- name
-
Distinguishing name, e.g. usable in license grant.
- grant
-
Text granting the license.
- license
-
Text containing licensing terms.
Texts containing both license grant and licensing terms
(e.g. BSD- and MIT-style licensing)
may be classified as either subject grant or subject license.
This may change, as needs for distinction is better understood.
Each pattern can process material within some scope,
i.e. a certain sample size of the full subject.
As an example, https://codesearch.debian.net/ use line-based processing,
where patterns spanning multiple lines are not applicable.
- line
-
Pattern typically found within a single line.
Typically this means less than 70 characters within scope.
- sentence
-
Pattern matching within a sentence.
May span multiple lines, but not across multiple sentences.
Typically this means no full-stop or colon within scope.
- paragraph
-
Pattern matching distinguishing paragraph.
May span multiple sentences, but not multiple paragraphs.
Typically this means no newline within scope.
- section
-
Pattern matching distinguishing section.
May span multiple paragraphs, but not multiple sections.
Typically this means blank line within scope.
- multisection
-
Pattern may span multiple sections.
License objects obsoleted by improved coverage of other objects,
and provided only as dummy objects.
Pattern defhashes optionally includes tags,
which may help in selecting multiple related patterns.
Tags are hierarchical,
with : as separator,
and may be extended without notice.
Therefore take care to permit sub-parts when tag-matching,
e.g. using a regex like /\Asome:tag(?:\z|:)/ .
- family:bsd
- family:cc
- family:gpl
- family:mit
- family:zlib
Pattern covers a license part of a family of licenses.
- license:contains:grant:*
License mentions a preferred form for granting the license.
This implies that license is commonly granted by use of a different (typically far shorter) text.
Fourth part (optional) is the key to corresponding license pattern,
for a grant belonging to a different license
(when omitted then a grant for same license is assumed).
- license:contains:license:*
License contains another license.
Wildcard is the key to corresponding license pattern.
- license:contains:name:*
License mentions name of another license.
- license:includes:license:*
License references coverage of another license.
Wildcard is the key to corresponding license pattern.
- license:is:grant
License is commonly granted by stating the whole license.
- license:published:*
License grant may include an ``as published by...'' reference.
Third part is the key to corresponding trait pattern.
- type:trait:publisher:*
Pattern covers an ``as published by ...'' license grant phrase.
Third part (optional) is the key to corresponding license pattern.
- type:usage:*:*
Pattern covers a specific usage of a license.
Third part is the key of the corresponding non-usage-specific pattern.
Fourth part is the key of the corresponding usage trait pattern.
- type:combo
Pattern covers a combination of multiple licenses.
- type:group
Pattern covers either of multiple licenses.
- type:singleversion:*
Pattern covers a specific version of a license.
Third part is the key of the corresponding non-version-specific pattern.
- type:trait
Pattern covers a single trait occuring in licenses.
- type:unversioned
Pattern covers a license without versioning scheme.
- type:versioned:decimal
Pattern covers a license using decimal number versioning scheme.
The ``official'' way to browse patterns is using the App::RegexpPatternUtils manpage:
show-regexp-pattern-module --page-result -- License
Unfortunately, the App::RegexpPatternUtils manpage has a deep dependency tree.
An alternative is to use the Data::Printer manpage and less:
perl -CS -MRegexp::Pattern::License -MDDP -e 'p %Regexp::Pattern::License::RE, fulldump => 1, output => stdout' | less -RS
Jonas Smedegaard <dr@jones.dk>
Copyright © 2016-2021 Jonas Smedegaard
Copyright © 2017-2021 Purism SPC
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 3, or (at your option) any
later version.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program. If not, see <https://www.gnu.org/licenses/>.
|