in reply to Re^2: Namespace/advice for new CPAN modules for Thai & Lao
in thread Namespace/advice for new CPAN modules for Thai & Lao

good chance of displeasing the majority
Well, there hopefully is a difference between not pleasing them and explicitly displeasing.
That said, what about Regexp::UTF8::Thai (Update: or Regexp::Thai::UTF8)?

Replies are listed 'Best First'.
Re^4: Namespace/advice for new CPAN modules for Thai & Lao ( Regexp::CharProps::Thai )
by Anonymous Monk on Mar 23, 2015 at 23:22 UTC

    Regexp is definitely not the place to post character sets, definitely ... except that it is :) um, I changed my mind

    well actually UTF8 definitely belongs nowhere , characters ranges aren't UTF8, this module doesn't deal with UTF8 ... sure the OP wrote

    $char = "..."; # some UTF8 string
    but he meant some unicode string

    So after some more research

    Regexp::Cherokee - Regular Expressions Support for Cherokee Script. Regexp::Ethiopic - Regular Expressions Support for Ethiopic Script. Regexp::CharClasses - Provide character classes Regexp::EN::NumVerbage - Regex pattern to match English number verbage + in text Regexp::CharClasses - Provide character classes

    I propose the one new namespace to rule them all Regexp::CharProps - User Defined Character Properties like \p{InKona}

    So for the OP Regexp::CharProps::Thai - \p(InThaiDigit} and other thai language character properties definitions

      So maybe

      #!/usr/bin/perl -- =head1 NAME Regexp::CharProps - User Defined Character Properties =head1 SYNOPSIS use Regexp::CharProps qw/ Thai /; ## like use Regexp::CharProps::T +hai qw/ :all /; ## imports all exports like sub +InThaiPunct... print "\$_ has got Thai" if m{ \p{InThai} |\p{InThaiCons} |\p{InThaiHCons} |\p{InThaiMCons} |\p{InThaiLCons} |\p{InThaiVowel} |\p{InThaiPreVowel} |\p{InThaiPostVowel} |\p{InThaiCompVowel} |\p{InThaiDigit} |\p{InThaiTone} |\p{InThaiPunct} }x; use Regexp::CharProps::Thai qw/ InThaiPunct /; ## not import :all +just sub InThaiPunct print "got Thai punctuation\n" if m/\p{InThaiPunct}/; =cut package Regexp::CharProps; sub import { my( $class, @modsforall ) = @_; return if not @modsforall; my $target = scalar caller; require Import::Into; for my $mod( @modsforall ){ my $package = $class."::".$mod; $package ->import::into( $target , ':all' ); } } 1;

      with accompanying EXPORT_TAGS

        "but he meant some unicode string"

        Yes. It definitely wouldn't work on an upper-ascii-type encoding such as Thai originally began with, without some form of encoding/decoding going on. I guess I put "UTF8" because that is what gets used most with Thai, and what I knew would work having developed strictly with that. I presume any Unicode type should work equally well, though I don't claim to be an expert on Unicode.

        In your code example:

        print "\$_ has got Thai" if m{ \p{InThai} |\p{InThaiCons} |\p{InThaiHCons} |\p{InThaiMCons} |\p{InThaiLCons} |\p{InThaiVowel} |\p{InThaiPreVowel} |\p{InThaiPostVowel} |\p{InThaiCompVowel} |\p{InThaiDigit} |\p{InThaiTone} |\p{InThaiPunct} }x;
        ...only the first item in the OR'ed list should ever see action. All of the subsequent categories are already "InThai", and the "InThai" token already comes standard with Perl, AFAIK (see pg. 172 of "Programming Perl, Third Edition"), so that code would do little to test additional functionality. If the first line (\p{InThai}) failed, none of the others should succeed either.

        NOTE: I've updated my list to reflect your proposed name, but I've adapted it slightly to one that seems a better fit to me.

        Blessings,

        ~Polyglot~