Acme-ID-CompanyName
view release on metacpan or search on metacpan
lib/Acme/ID/CompanyName.pm view on Meta::CPAN
xcel
xmas
xpres
xsis
xtra
#yahya-christianish
yasa
#yobel-christianish
zaitun
zaman
zeta
zeus
zona
);
my %Per_Letter_Words;
for my $letter ("a".."z") {
for (@Words) {
/(.).+/ or die;
push @{ $Per_Letter_Words{$1} }, $_;
}
}
our @Prefixes = qw(
adi
dana
dwi
eka
indo
inti
media
mega
mitra
multi
nara
oto
panca
prima
sapta
swa
tekno
tetra
trans
tri
);
our @Suffixes = qw(
indo
jaya
tama
);
$SPEC{gen_generic_ind_company_names} = {
v => 1.1,
summary => 'Generate nice-sounding, generic Indonesian company names',
args => {
type => {
schema => 'str*',
default => 'PT',
summary => 'Just a string to be prepended before the name',
cmdline_aliases => {t=>{}},
},
num_names => {
schema => ['int*', min=>0],
default => 1,
cmdline_aliases => {n=>{}},
pos => 0,
},
num_words => {
schema => ['int*', min=>1],
default => 3,
cmdline_aliases => {w=>{}},
},
add_prefixes => {
schema => ['bool*'],
default => 1,
},
add_suffixes => {
schema => ['bool*'],
default => 1,
},
# XXX option to use some more specific words & suffixes/prefixes
desired_initials => {
schema => ['str*', min_len=>1, match=>qr/\A[A-Za-z]+\z/],
},
},
result_naked => 1,
examples => [
{
summary => 'Generate five random PT names',
argv => [qw/5/],
test => 0,
},
{
summary => 'Generate three PT names with desired initials "ACME"',
argv => [qw/-n3 --desired-initials ACME/],
test => 0,
},
],
};
sub gen_generic_ind_company_names {
my %args = @_;
my $type = $args{type} // 'PT';
my $num_names = $args{num_names} // 1;
my $num_words = $args{num_words} // 3;
my $desired_initials = lc($args{desired_initials} // "");
my $add_prefixes = $args{add_prefixes} // 1;
my $add_suffixes = $args{add_suffixes} // 1;
$num_words = length($desired_initials)
if $num_words < length($desired_initials);
my @res;
my $name_tries = 0;
for my $i (1..$num_names) {
die "Can't produce that many unique company names"
if ++$name_tries > 5*$num_names;
my @words;
my $word_tries = 0;
my $has_added_prefix;
my $has_added_suffix;
WORD:
for my $j (1..$num_words) {
die "Can't produce a company name that satisfies requirements"
if ++$word_tries > 1000;
my $will_add_prefix =
!$add_prefixes ? 0 :
$has_added_prefix ? 0 :
rand()*$num_words*6 > 1 ? 0 : 1;
my $word;
my $desired_initial = length($desired_initials) >= $j ?
substr($desired_initials, $j-1, 1) : undef;
if (!$will_add_prefix && $desired_initial) {
die "There are no words that start with '$desired_initial'"
unless $Per_Letter_Words{$desired_initial};
lib/Acme/ID/CompanyName.pm view on Meta::CPAN
__END__
=pod
=encoding UTF-8
=head1 NAME
Acme::ID::CompanyName - Generate nice-sounding, generic Indonesian company names
=head1 VERSION
This document describes version 0.007 of Acme::ID::CompanyName (from Perl distribution Acme-ID-CompanyName), released on 2021-05-07.
=head1 DESCRIPTION
=head1 FUNCTIONS
=head2 gen_generic_ind_company_names
Usage:
gen_generic_ind_company_names(%args) -> any
Generate nice-sounding, generic Indonesian company names.
Examples:
=over
=item * Generate five random PT names:
gen_generic_ind_company_names( num_names => 5);
Result:
[
"PT Hulu Humania Harmoni",
"PT Jaya Cipta Indoakurasi",
"PT Baru Berjaya Legenda",
"PT Normal Zona Gempita",
"PT Multi Gelora Baswara",
]
=item * Generate three PT names with desired initials "ACME":
gen_generic_ind_company_names( num_names => 3, desired_initials => "ACME");
Result:
[
"PT Aksara Catur Mekar Elektronik",
"PT Anugerah Cendrawasih Mandala Esa",
"PT Asaindo Cakra Mandala Elang",
]
=back
This function is not exported by default, but exportable.
Arguments ('*' denotes required arguments):
=over 4
=item * B<add_prefixes> => I<bool> (default: 1)
=item * B<add_suffixes> => I<bool> (default: 1)
=item * B<desired_initials> => I<str>
=item * B<num_names> => I<int> (default: 1)
=item * B<num_words> => I<int> (default: 3)
=item * B<type> => I<str> (default: "PT")
Just a string to be prepended before the name.
=back
Return value: (any)
=head1 HOMEPAGE
Please visit the project's homepage at L<https://metacpan.org/release/Acme-ID-CompanyName>.
=head1 SOURCE
Source repository is at L<https://github.com/perlancar/perl-Acme-ID-CompanyName>.
=head1 BUGS
Please report any bugs or feature requests on the bugtracker website L<https://rt.cpan.org/Public/Dist/Display.html?Name=Acme-ID-CompanyName>
When submitting a bug or request, please include a test-file or a
patch to an existing test-file that illustrates the bug or desired
feature.
=head1 AUTHOR
perlancar <perlancar@cpan.org>
=head1 COPYRIGHT AND LICENSE
This software is copyright (c) 2021, 2017 by perlancar@cpan.org.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
=cut
( run in 0.827 second using v1.01-cache-2.11-cpan-140bd7fdf52 )