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

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

  • Comment on Re^4: Namespace/advice for new CPAN modules for Thai & Lao ( Regexp::CharProps::Thai )
  • Select or Download Code

Replies are listed 'Best First'.
Re^5: Namespace/advice for new CPAN modules for Thai & Lao ( Regexp::CharProps - User Defined Character Properties )
by Anonymous Monk on Mar 24, 2015 at 00:06 UTC

    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~

        In your code example: ...only the first item in the OR'ed list should ever see action...

        SYNOPSIS only shows whats possible, it can be repetitive and incorrect as long as the syntax is valid. And when the exports are few, might as well show them all instead of "..."

        Regexp::CharProps

        My suggestion was that you call yours Regexp::CharProps::Thai not Regexp::CharProps. Also to distribute a helper parent module Regexp::CharProps with it, so that others can add Regexp::CharProps::AnonyRands or whatever ... a new well named place for these definitions to live

        Regexp::Thai::CharClasses

        So are you're going to have more Thai Regexp's that aren't CharSlasses?

        I think you got that backwards, it should be Regexp::CharClasses::Thai :)

        Or it should go into Lingua::Thai::RegexpCharClasses? In case you're going to have more Lingua::Thai things that aren't RegexpCharClasses

        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.

        Right :) the numbers are unicode code points , independent of encoding