famibeib/Wellknown.pm untested

filter: Statementstmt 0.0% 0 / 74 Branchbran 0.0% 0 / 14 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 0.0% 0 / 11 Podpod n/a totaltotal 0.0% 0 / 109 CC 1 SCAR 6.9
CC
1
Cov
0%
BEGIN
2.0
BEGIN
2.0
BEGIN
2.0
CRAP 2.0
1 # Copyright (c) 2025-2026 Philipp Schafft
2  
3 # licensed under Artistic License 2.0 (see LICENSE file)
4  
5 # ABSTRACT: database of famibeib words
6  
7  
8 package Lingua::famibeib::Wellknown;
9  
10 use v5.16;
11 use strict;
12 use warnings;
13  
14 use Carp;
15 use Lingua::famibeib::Word;
16 use Lingua::famibeib::Modifier;
17 use Lingua::famibeib::Prefix; # This will also load some prefixes
18 use Data::Identifier::Util;
19 use Data::Displaycolour v0.07;
20 use Data::IconText v0.06;
21  
22 our $VERSION = v0.07;
23  
24 use parent qw(Data::Identifier::Interface::Known);
25  
26 my @_wellknown_words = map {Lingua::famibeib::Word->new(from => $_)->register} (
27 (map {$_, $_.'ab'} qw(baba babe babi bafa bafe bafi bafo baka bake baki bako baku)), # Pronouns
28 (map {Lingua::famibeib::Word->new(number => $_)} -1 .. 32), # Numbers
29 (qw(fokiba fokibe fokibi fokifa fokife fokifi fokika fokike fokiki fokiko fokila)), # Colours
30 (qw(febaba febabo febasu febebe febeba febe febeto)), # Animals
31 (map {'tu'.$_, 'tu'.$_.'al'} qw(ba be bi bo ma me mi sa se si so su ta te ti to tu)), # Structure I
32 (map { $_, $_.'al'} qw(tusifa tusife tusifi tusifo)), # Structure II
33 (map { $_, $_.'ol'} qw(faba fabe fabi fabo fabu fafa fafe fafi fafo fafu faka fake faki fako faku fala fale fali falo falu
34 fama fame fami famo famu fasa fase fasi faso fasu fata fate fati fato fatu)), # Common Verbs
35 (map { $_, $_.'am'} qw(fababa fababe fababi fababo fababu fabafa fabafe fabafi fabaka fabake)), # Relatives
36 (map { $_, $_.'am'} qw(fabala fabale fabali fabalu fabama fabame fabasa fabase fabasi fabaso fabasu)), # Other Persons
37 );
38  
39 my @_wellknown_modifiers = map {Lingua::famibeib::Modifier->new(from => $_)->register} (
40 qw(ab eb ib ub af ef ak ek ok uk al il ol am em im),
41 );
42  
43 my @_wellknown_prefixs = map {Lingua::famibeib::Prefix->new(string => $_)->register} (
44 qw(ba be fa fe fi fo fu ta to tu),
45 );
46  
47 my %_concept = (
48 # Colours:
49 fokiba => 'c9ec3bea-558e-4992-9b76-91f128b6cf29',
50 fokibe => '5c41829f-5062-4868-9c31-2ec98414c53d',
51 fokibi => '2892c143-2ae7-48f1-95f4-279e059e7fc3',
52  
53 fokifa => 'c0e957d0-b5cf-4e53-8e8a-ff0f5f2f3f03',
54 # fokife
55 fokifi => 'abcbf48d-c302-4be1-8c5c-a8de4471bcbb',
56  
57 fokika => '3dcef9a3-2ecc-482d-a98b-afffbc2f64b9',
58 # fokike
59 # fokiki
60 fokiko => 'a30d070d-9909-40d4-a33a-474c89e5cd45',
61  
62 fokila => 'f2e45f11-b1a8-421f-9c03-61a30bd23e78',
63  
64 # Animals:
65 febaba => '571fe2aa-95f6-4b16-a8d2-1ff4f78bdad1',
66 febabo => '36297a27-0673-44ad-b2d8-0e4e97a9022d',
67 febasu => '838eede5-3f93-46a9-8e10-75165d10caa1',
68 febebe => '252314f9-1467-48bf-80fd-f8b74036189f',
69 febeba => '5d006ca0-c27b-4529-b051-ac39c784d5ee',
70 febe => '95f1b56e-c576-4f32-ac9b-bfdd397c36a6',
71 febeto => 'dcf8f4f0-c15e-44bd-ad76-0d483079db16',
72  
73 # Relatives:
74 fababaam => '3efce853-eae9-4429-9d5d-c4420f846005',
75 fababeam => 'a3e1528a-5258-420d-92aa-401d973c43a8',
76 fababiam => '2ef71908-a411-464d-9de2-53da0b3505ba',
77 fababoam => '30cc2c34-4296-4f9a-8ca6-dd139247dd3c',
78 fababuam => 'f4423fe9-b535-4f3b-8d7f-b0c863f6b525',
79  
80 fabafaam => 'e7c73208-81ea-4ac7-b937-87070bbb9126',
81 fabafeam => 'cf65827f-bc2b-49fa-a270-16fee39993a1',
82 fabafiam => 'b148ee3a-2547-4b0a-a7e2-a160024c4053',
83  
84 #fabakaam => '',
85 #fabakeam => '',
86 );
87  
88 my @_wellknown_extra = (
89 Lingua::famibeib::Word->natural_language, # force load
90 Data::Identifier::Util->register_generator(
91 'e2afa39e-fd57-45f8-89fd-8662b275cc68',
92 namespace => '10ce38bf-6238-4ed7-96ef-98ea9642a4c6',
93 style => 'id-based',
94 ),
95 Data::Identifier::Util->register_generator(
96 '306baa6e-e672-4327-a6b4-ba1d3de89a1e',
97 namespace => '5c2b24f0-e0d9-4746-bd72-0d07061d0dd7',
98 style => 'id-based',
99 ),
100 );
101  
102 foreach my Lingua::famibeib::Word $word (@_wellknown_words) {
103 my $id = $word->as('Data::Identifier')->register;
104 my $str = $word->as_string;
105 my $concept;
106  
107 $concept //= Data::Identifier->new(from => $_concept{$str}) if defined $_concept{$str};
108 $concept //= eval {$word->as_number('Data::Identifier')};
109  
110 next unless defined $concept;
111  
112 $concept->register;
113  
114 push(@_wellknown_extra, $concept);
115  
116 foreach my $obj ($word, $id) {
117 $obj->Data::Displaycolour::mark(for => $concept);
118 $obj->Data::IconText::mark(for => $concept);
119 }
120 }
121  
122 # ---- Private helpers ----
123  
124 sub _known_provider {
125 my ($pkg, $class, %opts) = @_;
126 croak 'Unsupported options passed' if scalar(keys %opts);
127 if ($class eq 'word') {
128 return (\@_wellknown_words, rawtype => 'Lingua::famibeib::Word');
129 } elsif ($class eq 'modifier') {
130 return (\@_wellknown_modifiers, rawtype => 'Lingua::famibeib::Modifier');
131 } elsif ($class eq 'prefix') {
132 return (\@_wellknown_prefixs, rawtype => 'Lingua::famibeib::Prefix');
133 } elsif ($class eq ':all') {
134 return ([@_wellknown_words, @_wellknown_modifiers, @_wellknown_prefixs, @_wellknown_extra], rawtype => 'Data::Identifier::Interface::Simple');
135 }
136 croak 'Unsupported class';
137 }
138  
139 1;
140  
141 __END__
142  
143 =pod
144  
145 =encoding UTF-8
146  
147 =head1 NAME
148  
149 Lingua::famibeib::Wellknown - database of famibeib words
150  
151 =head1 VERSION
152  
153 version v0.07
154  
155 =head1 SYNOPSIS
156  
157 use Lingua::famibeib::Wellknown;
158  
159 This package holds a number of well known famibeib words.
160 Those words will be automatically registered using L<Lingua::famibeib::Word/register>.
161 This is useful when working with long texts.
162 Also additional information may be provided by this package for individual words.
163  
164 This module inherits from L<Data::Identifier::Interface::Known>.
165  
166 B<Note:>
167 This package might also register L<Data::Identifier> objects related to the words.
168 Depending on the usecase results might improve if L<Data::Identifier::Wellknown> is also loaded.
169  
170 =head1 CLASSES
171  
172 The following classes are supported:
173  
174 =head2 :all
175  
176 All objects known by this module.
177 This includes all from the other classes.
178 It may also contain additional entries.
179  
180 =head2 word
181  
182 All words known to this module.
183  
184 =head2 modifier
185  
186 All modifiers known to this module.
187  
188 =head2 prefix
189  
190 All prefixes known to this module.
191  
192 =head1 AUTHOR
193  
194 Philipp Schafft <lion@cpan.org>
195  
196 =head1 COPYRIGHT AND LICENSE
197  
198 This software is Copyright (c) 2025-2026 by Philipp Schafft <lion@cpan.org>.
199  
200 This is free software, licensed under:
201  
202 The Artistic License 2.0 (GPL Compatible)
203  
204 =cut