| 1 | # Copyright (c) 2026 Philipp Schafft | ||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||
| 3 | # licensed under Artistic License 2.0 (see LICENSE file) | ||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||
| 5 | # ABSTRACT: module to interact with the words of Toki Pona | ||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||
| 8 | package Lingua::TokiPona::Word; | ||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||
| 10 | 1 | ▶ | use v5.20; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 11 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 12 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||
| 14 | 1 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 15 | 1 | ▶ | use Data::Identifier v0.34; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 16 | 1 | ▶ | use Data::Identifier::Generate; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 17 | 1 | ▶ | use Data::Displaycolour; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||
| 19 | 1 | our $VERSION = v0.03; | |||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||
| 21 | 1 | ▶ | use parent qw(Data::Identifier::Interface::Known Lingua::Generic::Interface::Word); | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||
| 23 | use constant { | ||||||||||||||||||||||||||||||||||||||
| 24 | 1 | WK_WORD_GENERATOR => Data::Identifier->new(uuid => '45823114-5f38-47d8-a749-2e7f3ec819c3', tagname => 'toki-pona-word-generator')->register, | |||||||||||||||||||||||||||||||||||||
| 25 | WK_WORD_NAMESPACE => Data::Identifier->new(uuid => '8d043e5e-b7da-4a37-a87a-26bb361288a1', tagname => 'toki-pona-word-namespace')->register, | ||||||||||||||||||||||||||||||||||||||
| 26 | WK_WORD_TYPE => Data::Identifier->new(uuid => 'baf7bee1-0889-4a84-afc2-4904857d0571', tagname => 'toki-pona-word')->register, | ||||||||||||||||||||||||||||||||||||||
| 27 | WK_LT_TOK => Data::Identifier->new(uuid => 'f21986c8-baa1-5b7e-b357-2a76285c4778', displayname => 'Toki Pona', request => 'tok')->register, | ||||||||||||||||||||||||||||||||||||||
| 28 | 1 | ▶ | }; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||
| 30 | 1 | my %_words; | |||||||||||||||||||||||||||||||||||||
| 31 | my %_by_ise; | ||||||||||||||||||||||||||||||||||||||
| 32 | 1 | my %_by_ucsur; | |||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||
| 34 | 1 | __PACKAGE__->_new($_) foreach ( | |||||||||||||||||||||||||||||||||||||
| 35 | # NOTE: Each list only contains the words not already in one of the lists above it. | ||||||||||||||||||||||||||||||||||||||
| 36 | qw( | ||||||||||||||||||||||||||||||||||||||
| 37 | a kin akesi ala alasa ale ali anpa ante anu awen e en esun ijo ike ilo insa jaki jan | ||||||||||||||||||||||||||||||||||||||
| 38 | jelo jo kala kalama kama kasi ken kepeken kili kiwen ko kon kule kulupu kute la lape | ||||||||||||||||||||||||||||||||||||||
| 39 | laso lawa len lete li lili linja lipu loje lon luka lukin oko lupa ma mama mani meli | ||||||||||||||||||||||||||||||||||||||
| 40 | mi mije moku moli monsi mu mun musi mute nanpa nasa nasin nena ni nimi noka o olin ona | ||||||||||||||||||||||||||||||||||||||
| 41 | open pakala pali palisa pan pana pi pilin pimeja pini pipi poka poki pona pu sama seli | ||||||||||||||||||||||||||||||||||||||
| 42 | selo seme sewi sijelo sike sin namako sina sinpin sitelen sona soweli suli suno supa suwi | ||||||||||||||||||||||||||||||||||||||
| 43 | tan taso tawa telo tenpo toki tomo tu unpa uta utala walo wan waso wawa weka wile | ||||||||||||||||||||||||||||||||||||||
| 44 | ), | ||||||||||||||||||||||||||||||||||||||
| 45 | qw(kijetesantakalu kin kipisi ku leko misikeke monsuta n soko tonsi), # Common | ||||||||||||||||||||||||||||||||||||||
| 46 | qw(epiku jasima lanpan linluwi majuna meso nimisin su), # Uncommon | ||||||||||||||||||||||||||||||||||||||
| 47 | qw( | ||||||||||||||||||||||||||||||||||||||
| 48 | apeja isipin jami kamalawala kapesi kiki kokosila konwe kulijo melome mijomi misa nja | ||||||||||||||||||||||||||||||||||||||
| 49 | ojuta oke omekapo owe pake penpo pika po powe puwa san soto sutopatikuna taki te teje | ||||||||||||||||||||||||||||||||||||||
| 50 | to unu usawi wa wasoweli wekama wuwojiti yupekosi | ||||||||||||||||||||||||||||||||||||||
| 51 | ), # Obscure | ||||||||||||||||||||||||||||||||||||||
| 52 | qw(suke toma), # Typo | ||||||||||||||||||||||||||||||||||||||
| 53 | qw(ete ewe kan ke kese kuntu likujo loka mulapisu neja pata peto polinpin pomotolo samu tuli umesu waleja), # nimi ku lili | ||||||||||||||||||||||||||||||||||||||
| 54 | qw(ju lu nu u), # Reserved words | ||||||||||||||||||||||||||||||||||||||
| 55 | ); | ||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||
| 57 | 1 | __PACKAGE__->new(string => $_)->{class}{stopword} = 1 foreach qw(a kin anu e en la li o pi seme); | |||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||
| 59 | 1 | __PACKAGE__->new(string => 'loje' )->Data::Displaycolour::mark(for => Data::Identifier->new(uuid => 'c9ec3bea-558e-4992-9b76-91f128b6cf29')); # red | |||||||||||||||||||||||||||||||||||||
| 60 | 1 | __PACKAGE__->new(string => 'jelo' )->Data::Displaycolour::mark(for => Data::Identifier->new(uuid => '2892c143-2ae7-48f1-95f4-279e059e7fc3')); # yellow | |||||||||||||||||||||||||||||||||||||
| 61 | 1 | __PACKAGE__->new(string => 'laso' )->Data::Displaycolour::mark(for => Data::Identifier->new(uuid => 'abcbf48d-c302-4be1-8c5c-a8de4471bcbb')); # cyan | |||||||||||||||||||||||||||||||||||||
| 62 | 1 | __PACKAGE__->new(string => 'walo' )->Data::Displaycolour::mark(for => Data::Identifier->new(uuid => '1a2c23fa-2321-47ce-bf4f-5f08934502de')); # white | |||||||||||||||||||||||||||||||||||||
| 63 | 1 | __PACKAGE__->new(string => 'pimeja')->Data::Displaycolour::mark(for => Data::Identifier->new(uuid => 'fade296d-c34f-4ded-abd5-d9adaf37c284')); # black | |||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||
| 65 | { | ||||||||||||||||||||||||||||||||||||||
| 66 | 1 | my %ucsur = ( | |||||||||||||||||||||||||||||||||||||
| 67 | 0xF1900 => 'SITELEN PONA IDEOGRAPH A', | ||||||||||||||||||||||||||||||||||||||
| 68 | 0xF1901 => 'SITELEN PONA IDEOGRAPH AKESI', | ||||||||||||||||||||||||||||||||||||||
| 69 | 0xF1902 => 'SITELEN PONA IDEOGRAPH ALA', | ||||||||||||||||||||||||||||||||||||||
| 70 | 0xF1903 => 'SITELEN PONA IDEOGRAPH ALASA', | ||||||||||||||||||||||||||||||||||||||
| 71 | 0xF1904 => 'SITELEN PONA IDEOGRAPH ALE', | ||||||||||||||||||||||||||||||||||||||
| 72 | 0xF1905 => 'SITELEN PONA IDEOGRAPH ANPA', | ||||||||||||||||||||||||||||||||||||||
| 73 | 0xF1906 => 'SITELEN PONA IDEOGRAPH ANTE', | ||||||||||||||||||||||||||||||||||||||
| 74 | 0xF1907 => 'SITELEN PONA IDEOGRAPH ANU', | ||||||||||||||||||||||||||||||||||||||
| 75 | 0xF1908 => 'SITELEN PONA IDEOGRAPH AWEN', | ||||||||||||||||||||||||||||||||||||||
| 76 | 0xF1909 => 'SITELEN PONA IDEOGRAPH E', | ||||||||||||||||||||||||||||||||||||||
| 77 | 0xF190A => 'SITELEN PONA IDEOGRAPH EN', | ||||||||||||||||||||||||||||||||||||||
| 78 | 0xF190B => 'SITELEN PONA IDEOGRAPH ESUN', | ||||||||||||||||||||||||||||||||||||||
| 79 | 0xF190C => 'SITELEN PONA IDEOGRAPH IJO', | ||||||||||||||||||||||||||||||||||||||
| 80 | 0xF190D => 'SITELEN PONA IDEOGRAPH IKE', | ||||||||||||||||||||||||||||||||||||||
| 81 | 0xF190E => 'SITELEN PONA IDEOGRAPH ILO', | ||||||||||||||||||||||||||||||||||||||
| 82 | 0xF190F => 'SITELEN PONA IDEOGRAPH INSA', | ||||||||||||||||||||||||||||||||||||||
| 83 | 0xF1910 => 'SITELEN PONA IDEOGRAPH JAKI', | ||||||||||||||||||||||||||||||||||||||
| 84 | 0xF1911 => 'SITELEN PONA IDEOGRAPH JAN', | ||||||||||||||||||||||||||||||||||||||
| 85 | 0xF1912 => 'SITELEN PONA IDEOGRAPH JELO', | ||||||||||||||||||||||||||||||||||||||
| 86 | 0xF1913 => 'SITELEN PONA IDEOGRAPH JO', | ||||||||||||||||||||||||||||||||||||||
| 87 | 0xF1914 => 'SITELEN PONA IDEOGRAPH KALA', | ||||||||||||||||||||||||||||||||||||||
| 88 | 0xF1915 => 'SITELEN PONA IDEOGRAPH KALAMA', | ||||||||||||||||||||||||||||||||||||||
| 89 | 0xF1916 => 'SITELEN PONA IDEOGRAPH KAMA', | ||||||||||||||||||||||||||||||||||||||
| 90 | 0xF1917 => 'SITELEN PONA IDEOGRAPH KASI', | ||||||||||||||||||||||||||||||||||||||
| 91 | 0xF1918 => 'SITELEN PONA IDEOGRAPH KEN', | ||||||||||||||||||||||||||||||||||||||
| 92 | 0xF1919 => 'SITELEN PONA IDEOGRAPH KEPEKEN', | ||||||||||||||||||||||||||||||||||||||
| 93 | 0xF191A => 'SITELEN PONA IDEOGRAPH KILI', | ||||||||||||||||||||||||||||||||||||||
| 94 | 0xF191B => 'SITELEN PONA IDEOGRAPH KIWEN', | ||||||||||||||||||||||||||||||||||||||
| 95 | 0xF191C => 'SITELEN PONA IDEOGRAPH KO', | ||||||||||||||||||||||||||||||||||||||
| 96 | 0xF191D => 'SITELEN PONA IDEOGRAPH KON', | ||||||||||||||||||||||||||||||||||||||
| 97 | 0xF191E => 'SITELEN PONA IDEOGRAPH KULE', | ||||||||||||||||||||||||||||||||||||||
| 98 | 0xF191F => 'SITELEN PONA IDEOGRAPH KULUPU', | ||||||||||||||||||||||||||||||||||||||
| 99 | 0xF1920 => 'SITELEN PONA IDEOGRAPH KUTE', | ||||||||||||||||||||||||||||||||||||||
| 100 | 0xF1921 => 'SITELEN PONA IDEOGRAPH LA', | ||||||||||||||||||||||||||||||||||||||
| 101 | 0xF1922 => 'SITELEN PONA IDEOGRAPH LAPE', | ||||||||||||||||||||||||||||||||||||||
| 102 | 0xF1923 => 'SITELEN PONA IDEOGRAPH LASO', | ||||||||||||||||||||||||||||||||||||||
| 103 | 0xF1924 => 'SITELEN PONA IDEOGRAPH LAWA', | ||||||||||||||||||||||||||||||||||||||
| 104 | 0xF1925 => 'SITELEN PONA IDEOGRAPH LEN', | ||||||||||||||||||||||||||||||||||||||
| 105 | 0xF1926 => 'SITELEN PONA IDEOGRAPH LETE', | ||||||||||||||||||||||||||||||||||||||
| 106 | 0xF1927 => 'SITELEN PONA IDEOGRAPH LI', | ||||||||||||||||||||||||||||||||||||||
| 107 | 0xF1928 => 'SITELEN PONA IDEOGRAPH LILI', | ||||||||||||||||||||||||||||||||||||||
| 108 | 0xF1929 => 'SITELEN PONA IDEOGRAPH LINJA', | ||||||||||||||||||||||||||||||||||||||
| 109 | 0xF192A => 'SITELEN PONA IDEOGRAPH LIPU', | ||||||||||||||||||||||||||||||||||||||
| 110 | 0xF192B => 'SITELEN PONA IDEOGRAPH LOJE', | ||||||||||||||||||||||||||||||||||||||
| 111 | 0xF192C => 'SITELEN PONA IDEOGRAPH LON', | ||||||||||||||||||||||||||||||||||||||
| 112 | 0xF192D => 'SITELEN PONA IDEOGRAPH LUKA', | ||||||||||||||||||||||||||||||||||||||
| 113 | 0xF192E => 'SITELEN PONA IDEOGRAPH LUKIN', | ||||||||||||||||||||||||||||||||||||||
| 114 | 0xF192F => 'SITELEN PONA IDEOGRAPH LUPA', | ||||||||||||||||||||||||||||||||||||||
| 115 | 0xF1930 => 'SITELEN PONA IDEOGRAPH MA', | ||||||||||||||||||||||||||||||||||||||
| 116 | 0xF1931 => 'SITELEN PONA IDEOGRAPH MAMA', | ||||||||||||||||||||||||||||||||||||||
| 117 | 0xF1932 => 'SITELEN PONA IDEOGRAPH MANI', | ||||||||||||||||||||||||||||||||||||||
| 118 | 0xF1933 => 'SITELEN PONA IDEOGRAPH MELI', | ||||||||||||||||||||||||||||||||||||||
| 119 | 0xF1934 => 'SITELEN PONA IDEOGRAPH MI', | ||||||||||||||||||||||||||||||||||||||
| 120 | 0xF1935 => 'SITELEN PONA IDEOGRAPH MIJE', | ||||||||||||||||||||||||||||||||||||||
| 121 | 0xF1936 => 'SITELEN PONA IDEOGRAPH MOKU', | ||||||||||||||||||||||||||||||||||||||
| 122 | 0xF1937 => 'SITELEN PONA IDEOGRAPH MOLI', | ||||||||||||||||||||||||||||||||||||||
| 123 | 0xF1938 => 'SITELEN PONA IDEOGRAPH MONSI', | ||||||||||||||||||||||||||||||||||||||
| 124 | 0xF1939 => 'SITELEN PONA IDEOGRAPH MU', | ||||||||||||||||||||||||||||||||||||||
| 125 | 0xF193A => 'SITELEN PONA IDEOGRAPH MUN', | ||||||||||||||||||||||||||||||||||||||
| 126 | 0xF193B => 'SITELEN PONA IDEOGRAPH MUSI', | ||||||||||||||||||||||||||||||||||||||
| 127 | 0xF193C => 'SITELEN PONA IDEOGRAPH MUTE', | ||||||||||||||||||||||||||||||||||||||
| 128 | 0xF193D => 'SITELEN PONA IDEOGRAPH NANPA', | ||||||||||||||||||||||||||||||||||||||
| 129 | 0xF193E => 'SITELEN PONA IDEOGRAPH NASA', | ||||||||||||||||||||||||||||||||||||||
| 130 | 0xF193F => 'SITELEN PONA IDEOGRAPH NASIN', | ||||||||||||||||||||||||||||||||||||||
| 131 | 0xF1940 => 'SITELEN PONA IDEOGRAPH NENA', | ||||||||||||||||||||||||||||||||||||||
| 132 | 0xF1941 => 'SITELEN PONA IDEOGRAPH NI', | ||||||||||||||||||||||||||||||||||||||
| 133 | 0xF1942 => 'SITELEN PONA IDEOGRAPH NIMI', | ||||||||||||||||||||||||||||||||||||||
| 134 | 0xF1943 => 'SITELEN PONA IDEOGRAPH NOKA', | ||||||||||||||||||||||||||||||||||||||
| 135 | 0xF1944 => 'SITELEN PONA IDEOGRAPH O', | ||||||||||||||||||||||||||||||||||||||
| 136 | 0xF1945 => 'SITELEN PONA IDEOGRAPH OLIN', | ||||||||||||||||||||||||||||||||||||||
| 137 | 0xF1946 => 'SITELEN PONA IDEOGRAPH ONA', | ||||||||||||||||||||||||||||||||||||||
| 138 | 0xF1947 => 'SITELEN PONA IDEOGRAPH OPEN', | ||||||||||||||||||||||||||||||||||||||
| 139 | 0xF1948 => 'SITELEN PONA IDEOGRAPH PAKALA', | ||||||||||||||||||||||||||||||||||||||
| 140 | 0xF1949 => 'SITELEN PONA IDEOGRAPH PALI', | ||||||||||||||||||||||||||||||||||||||
| 141 | 0xF194A => 'SITELEN PONA IDEOGRAPH PALISA', | ||||||||||||||||||||||||||||||||||||||
| 142 | 0xF194B => 'SITELEN PONA IDEOGRAPH PAN', | ||||||||||||||||||||||||||||||||||||||
| 143 | 0xF194C => 'SITELEN PONA IDEOGRAPH PANA', | ||||||||||||||||||||||||||||||||||||||
| 144 | 0xF194D => 'SITELEN PONA IDEOGRAPH PI', | ||||||||||||||||||||||||||||||||||||||
| 145 | 0xF194E => 'SITELEN PONA IDEOGRAPH PILIN', | ||||||||||||||||||||||||||||||||||||||
| 146 | 0xF194F => 'SITELEN PONA IDEOGRAPH PIMEJA', | ||||||||||||||||||||||||||||||||||||||
| 147 | 0xF1950 => 'SITELEN PONA IDEOGRAPH PINI', | ||||||||||||||||||||||||||||||||||||||
| 148 | 0xF1951 => 'SITELEN PONA IDEOGRAPH PIPI', | ||||||||||||||||||||||||||||||||||||||
| 149 | 0xF1952 => 'SITELEN PONA IDEOGRAPH POKA', | ||||||||||||||||||||||||||||||||||||||
| 150 | 0xF1953 => 'SITELEN PONA IDEOGRAPH POKI', | ||||||||||||||||||||||||||||||||||||||
| 151 | 0xF1954 => 'SITELEN PONA IDEOGRAPH PONA', | ||||||||||||||||||||||||||||||||||||||
| 152 | 0xF1955 => 'SITELEN PONA IDEOGRAPH PU', | ||||||||||||||||||||||||||||||||||||||
| 153 | 0xF1956 => 'SITELEN PONA IDEOGRAPH SAMA', | ||||||||||||||||||||||||||||||||||||||
| 154 | 0xF1957 => 'SITELEN PONA IDEOGRAPH SELI', | ||||||||||||||||||||||||||||||||||||||
| 155 | 0xF1958 => 'SITELEN PONA IDEOGRAPH SELO', | ||||||||||||||||||||||||||||||||||||||
| 156 | 0xF1959 => 'SITELEN PONA IDEOGRAPH SEME', | ||||||||||||||||||||||||||||||||||||||
| 157 | 0xF195A => 'SITELEN PONA IDEOGRAPH SEWI', | ||||||||||||||||||||||||||||||||||||||
| 158 | 0xF195B => 'SITELEN PONA IDEOGRAPH SIJELO', | ||||||||||||||||||||||||||||||||||||||
| 159 | 0xF195C => 'SITELEN PONA IDEOGRAPH SIKE', | ||||||||||||||||||||||||||||||||||||||
| 160 | 0xF195D => 'SITELEN PONA IDEOGRAPH SIN', | ||||||||||||||||||||||||||||||||||||||
| 161 | 0xF195E => 'SITELEN PONA IDEOGRAPH SINA', | ||||||||||||||||||||||||||||||||||||||
| 162 | 0xF195F => 'SITELEN PONA IDEOGRAPH SINPIN', | ||||||||||||||||||||||||||||||||||||||
| 163 | 0xF1960 => 'SITELEN PONA IDEOGRAPH SITELEN', | ||||||||||||||||||||||||||||||||||||||
| 164 | 0xF1961 => 'SITELEN PONA IDEOGRAPH SONA', | ||||||||||||||||||||||||||||||||||||||
| 165 | 0xF1962 => 'SITELEN PONA IDEOGRAPH SOWELI', | ||||||||||||||||||||||||||||||||||||||
| 166 | 0xF1963 => 'SITELEN PONA IDEOGRAPH SULI', | ||||||||||||||||||||||||||||||||||||||
| 167 | 0xF1964 => 'SITELEN PONA IDEOGRAPH SUNO', | ||||||||||||||||||||||||||||||||||||||
| 168 | 0xF1965 => 'SITELEN PONA IDEOGRAPH SUPA', | ||||||||||||||||||||||||||||||||||||||
| 169 | 0xF1966 => 'SITELEN PONA IDEOGRAPH SUWI', | ||||||||||||||||||||||||||||||||||||||
| 170 | 0xF1967 => 'SITELEN PONA IDEOGRAPH TAN', | ||||||||||||||||||||||||||||||||||||||
| 171 | 0xF1968 => 'SITELEN PONA IDEOGRAPH TASO', | ||||||||||||||||||||||||||||||||||||||
| 172 | 0xF1969 => 'SITELEN PONA IDEOGRAPH TAWA', | ||||||||||||||||||||||||||||||||||||||
| 173 | 0xF196A => 'SITELEN PONA IDEOGRAPH TELO', | ||||||||||||||||||||||||||||||||||||||
| 174 | 0xF196B => 'SITELEN PONA IDEOGRAPH TENPO', | ||||||||||||||||||||||||||||||||||||||
| 175 | 0xF196C => 'SITELEN PONA IDEOGRAPH TOKI', | ||||||||||||||||||||||||||||||||||||||
| 176 | 0xF196D => 'SITELEN PONA IDEOGRAPH TOMO', | ||||||||||||||||||||||||||||||||||||||
| 177 | 0xF196E => 'SITELEN PONA IDEOGRAPH TU', | ||||||||||||||||||||||||||||||||||||||
| 178 | 0xF196F => 'SITELEN PONA IDEOGRAPH UNPA', | ||||||||||||||||||||||||||||||||||||||
| 179 | 0xF1970 => 'SITELEN PONA IDEOGRAPH UTA', | ||||||||||||||||||||||||||||||||||||||
| 180 | 0xF1971 => 'SITELEN PONA IDEOGRAPH UTALA', | ||||||||||||||||||||||||||||||||||||||
| 181 | 0xF1972 => 'SITELEN PONA IDEOGRAPH WALO', | ||||||||||||||||||||||||||||||||||||||
| 182 | 0xF1973 => 'SITELEN PONA IDEOGRAPH WAN', | ||||||||||||||||||||||||||||||||||||||
| 183 | 0xF1974 => 'SITELEN PONA IDEOGRAPH WASO', | ||||||||||||||||||||||||||||||||||||||
| 184 | 0xF1975 => 'SITELEN PONA IDEOGRAPH WAWA', | ||||||||||||||||||||||||||||||||||||||
| 185 | 0xF1976 => 'SITELEN PONA IDEOGRAPH WEKA', | ||||||||||||||||||||||||||||||||||||||
| 186 | 0xF1977 => 'SITELEN PONA IDEOGRAPH WILE', | ||||||||||||||||||||||||||||||||||||||
| 187 | 0xF1978 => 'SITELEN PONA IDEOGRAPH NAMAKO', | ||||||||||||||||||||||||||||||||||||||
| 188 | 0xF1979 => 'SITELEN PONA IDEOGRAPH KIN', | ||||||||||||||||||||||||||||||||||||||
| 189 | 0xF197A => 'SITELEN PONA IDEOGRAPH OKO', | ||||||||||||||||||||||||||||||||||||||
| 190 | 0xF197B => 'SITELEN PONA IDEOGRAPH KIPISI', | ||||||||||||||||||||||||||||||||||||||
| 191 | 0xF197C => 'SITELEN PONA IDEOGRAPH LEKO', | ||||||||||||||||||||||||||||||||||||||
| 192 | 0xF197D => 'SITELEN PONA IDEOGRAPH MONSUTA', | ||||||||||||||||||||||||||||||||||||||
| 193 | 0xF197E => 'SITELEN PONA IDEOGRAPH TONSI', | ||||||||||||||||||||||||||||||||||||||
| 194 | 0xF197F => 'SITELEN PONA IDEOGRAPH JASIMA', | ||||||||||||||||||||||||||||||||||||||
| 195 | 0xF1980 => 'SITELEN PONA IDEOGRAPH KIJETESANTAKALU', | ||||||||||||||||||||||||||||||||||||||
| 196 | 0xF1981 => 'SITELEN PONA IDEOGRAPH SOKO', | ||||||||||||||||||||||||||||||||||||||
| 197 | 0xF1982 => 'SITELEN PONA IDEOGRAPH MESO', | ||||||||||||||||||||||||||||||||||||||
| 198 | 0xF1983 => 'SITELEN PONA IDEOGRAPH EPIKU', | ||||||||||||||||||||||||||||||||||||||
| 199 | 0xF1984 => 'SITELEN PONA IDEOGRAPH KOKOSILA', | ||||||||||||||||||||||||||||||||||||||
| 200 | 0xF1985 => 'SITELEN PONA IDEOGRAPH LANPAN', | ||||||||||||||||||||||||||||||||||||||
| 201 | 0xF1986 => 'SITELEN PONA IDEOGRAPH N', | ||||||||||||||||||||||||||||||||||||||
| 202 | 0xF1987 => 'SITELEN PONA IDEOGRAPH MISIKEKE', | ||||||||||||||||||||||||||||||||||||||
| 203 | 0xF1988 => 'SITELEN PONA IDEOGRAPH KU', | ||||||||||||||||||||||||||||||||||||||
| 204 | 0xF1989 => 'SITELEN PONA IDEOGRAPH LEFTWARDS NI', | ||||||||||||||||||||||||||||||||||||||
| 205 | 0xF198A => 'SITELEN PONA IDEOGRAPH UPWARDS NI', | ||||||||||||||||||||||||||||||||||||||
| 206 | 0xF198B => 'SITELEN PONA IDEOGRAPH RIGHTWARDS NI', | ||||||||||||||||||||||||||||||||||||||
| 207 | 0xF198C => 'SITELEN PONA IDEOGRAPH ALTERNATE SEWI', | ||||||||||||||||||||||||||||||||||||||
| 208 | 0xF1990 => 'SITELEN PONA START OF CARTOUCHE', | ||||||||||||||||||||||||||||||||||||||
| 209 | 0xF1991 => 'SITELEN PONA END OF CARTOUCHE', | ||||||||||||||||||||||||||||||||||||||
| 210 | 0xF1992 => 'SITELEN PONA COMBINING CARTOUCHE EXTENSION', | ||||||||||||||||||||||||||||||||||||||
| 211 | 0xF1993 => 'SITELEN PONA START OF LONG PI', | ||||||||||||||||||||||||||||||||||||||
| 212 | 0xF1994 => 'SITELEN PONA COMBINING LONG PI EXTENSION', | ||||||||||||||||||||||||||||||||||||||
| 213 | 0xF1995 => 'SITELEN PONA STACKING JOINER', | ||||||||||||||||||||||||||||||||||||||
| 214 | 0xF1996 => 'SITELEN PONA SCALING JOINER', | ||||||||||||||||||||||||||||||||||||||
| 215 | 0xF1997 => 'SITELEN PONA START OF LONG GLYPH', | ||||||||||||||||||||||||||||||||||||||
| 216 | 0xF1998 => 'SITELEN PONA END OF LONG GLYPH', | ||||||||||||||||||||||||||||||||||||||
| 217 | 0xF1999 => 'SITELEN PONA COMBINING LONG GLYPH EXTENSION', | ||||||||||||||||||||||||||||||||||||||
| 218 | 0xF199A => 'SITELEN PONA START OF REVERSE LONG GLYPH', | ||||||||||||||||||||||||||||||||||||||
| 219 | 0xF199B => 'SITELEN PONA END OF REVERSE LONG GLYPH', | ||||||||||||||||||||||||||||||||||||||
| 220 | 0xF199C => 'SITELEN PONA MIDDLE DOT', | ||||||||||||||||||||||||||||||||||||||
| 221 | 0xF199D => 'SITELEN PONA COLON', | ||||||||||||||||||||||||||||||||||||||
| 222 | 0xF199E => 'SITELEN PONA COMBINING TALLY MARK', | ||||||||||||||||||||||||||||||||||||||
| 223 | 0xF19A0 => 'SITELEN PONA IDEOGRAPH PAKE', | ||||||||||||||||||||||||||||||||||||||
| 224 | 0xF19A1 => 'SITELEN PONA IDEOGRAPH APEJA', | ||||||||||||||||||||||||||||||||||||||
| 225 | 0xF19A2 => 'SITELEN PONA IDEOGRAPH MAJUNA', | ||||||||||||||||||||||||||||||||||||||
| 226 | 0xF19A3 => 'SITELEN PONA IDEOGRAPH POWE', | ||||||||||||||||||||||||||||||||||||||
| 227 | 0xF19A4 => 'SITELEN PONA IDEOGRAPH LINLUWI', | ||||||||||||||||||||||||||||||||||||||
| 228 | 0xF19A5 => 'SITELEN PONA IDEOGRAPH KIKI', | ||||||||||||||||||||||||||||||||||||||
| 229 | 0xF19A6 => 'SITELEN PONA IDEOGRAPH SU', | ||||||||||||||||||||||||||||||||||||||
| 230 | 0xF19A7 => 'SITELEN PONA IDEOGRAPH ISIPIN', | ||||||||||||||||||||||||||||||||||||||
| 231 | 0xF19A8 => 'SITELEN PONA IDEOGRAPH KAMALAWALA', | ||||||||||||||||||||||||||||||||||||||
| 232 | 0xF19A9 => 'SITELEN PONA IDEOGRAPH KAPESI', | ||||||||||||||||||||||||||||||||||||||
| 233 | 0xF19AA => 'SITELEN PONA IDEOGRAPH MELOME', | ||||||||||||||||||||||||||||||||||||||
| 234 | 0xF19AB => 'SITELEN PONA IDEOGRAPH MIJOMI', | ||||||||||||||||||||||||||||||||||||||
| 235 | 0xF19AC => 'SITELEN PONA IDEOGRAPH MISA', | ||||||||||||||||||||||||||||||||||||||
| 236 | 0xF19AD => 'SITELEN PONA IDEOGRAPH NIMISIN', | ||||||||||||||||||||||||||||||||||||||
| 237 | 0xF19AE => 'SITELEN PONA IDEOGRAPH NJA', | ||||||||||||||||||||||||||||||||||||||
| 238 | 0xF19AF => 'SITELEN PONA IDEOGRAPH OKE', | ||||||||||||||||||||||||||||||||||||||
| 239 | 0xF19B0 => 'SITELEN PONA IDEOGRAPH OMEKAPO', | ||||||||||||||||||||||||||||||||||||||
| 240 | 0xF19B1 => 'SITELEN PONA IDEOGRAPH PUWA', | ||||||||||||||||||||||||||||||||||||||
| 241 | 0xF19B2 => 'SITELEN PONA IDEOGRAPH SAN', | ||||||||||||||||||||||||||||||||||||||
| 242 | 0xF19B3 => 'SITELEN PONA IDEOGRAPH TAKI', | ||||||||||||||||||||||||||||||||||||||
| 243 | 0xF19B4 => 'SITELEN PONA IDEOGRAPH TE', | ||||||||||||||||||||||||||||||||||||||
| 244 | 0xF19B5 => 'SITELEN PONA IDEOGRAPH TO', | ||||||||||||||||||||||||||||||||||||||
| 245 | 0xF19B6 => 'SITELEN PONA IDEOGRAPH UNU', | ||||||||||||||||||||||||||||||||||||||
| 246 | 0xF19B7 => 'SITELEN PONA IDEOGRAPH USAWI', | ||||||||||||||||||||||||||||||||||||||
| 247 | 0xF19B8 => 'SITELEN PONA IDEOGRAPH WA', | ||||||||||||||||||||||||||||||||||||||
| 248 | 0xF19B9 => 'SITELEN PONA IDEOGRAPH WUWOJITI', | ||||||||||||||||||||||||||||||||||||||
| 249 | 0xF19BA => 'SITELEN PONA IDEOGRAPH YUPEKOSI', | ||||||||||||||||||||||||||||||||||||||
| 250 | ); | ||||||||||||||||||||||||||||||||||||||
| 251 | 1 | foreach my $cp (keys %ucsur) { | |||||||||||||||||||||||||||||||||||||
| 252 | 183 | ▶ | my ($str) = $ucsur{$cp} =~ /^SITELEN PONA IDEOGRAPH ([A-Z]+)\z/ or next; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 253 | 164 | ▶ | my $word = $_words{lc $str} // next; | ||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$_words{lc $str} // (next)
MC/DC0%0/1
$_words{lc $str} // (next)
$_words{lc $str}
Truth table50%1/2
A
A= $_words{lc $str}
| |||||||||||||||||||||||||||||||||||||||
| 254 | 164 | $word->{ucsur} = int $cp; | |||||||||||||||||||||||||||||||||||||
| 255 | 164 | $_by_ucsur{$cp} = $word; | |||||||||||||||||||||||||||||||||||||
| 256 | } | ||||||||||||||||||||||||||||||||||||||
| 257 | } | ||||||||||||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||||||||||||
| 259 | |||||||||||||||||||||||||||||||||||||||
| 260 | # Not our actual constructor, see _new(). This is for the public API only | ||||||||||||||||||||||||||||||||||||||
| 261 | sub new { | ||||||||||||||||||||||||||||||||||||||
| 262 | 15 | ▶ | my ($pkg, $type, $value, @opts) = @_; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=19 SCAR=52.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||||||||||||
| 264 | 15 | ▶ | croak 'No type given' unless defined $type; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 265 | 15 | ▶ | croak 'No value given' unless defined $value; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 266 | 15 | ▶ | croak 'Stray options passed' if scalar @opts; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 267 | |||||||||||||||||||||||||||||||||||||||
| 268 | 15 | ▶ | if ($type eq 'from') { | ||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||
| 269 | 0 | ▶ | if (ref $value) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 270 | 0 | ▶ | if ($value->isa(__PACKAGE__)) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||
| 271 | 0 | return $value; | |||||||||||||||||||||||||||||||||||||
| 272 | } elsif ($value->isa('Data::Identifier')) { | ||||||||||||||||||||||||||||||||||||||
| 273 | 0 | $type = 'Data::Identifier'; | |||||||||||||||||||||||||||||||||||||
| 274 | } elsif ($value->isa('Lingua::famibeib::Word')) { | ||||||||||||||||||||||||||||||||||||||
| 275 | 0 | $value = $value->as(__PACKAGE__); | |||||||||||||||||||||||||||||||||||||
| 276 | 0 | ▶ | return $value if scalar(@opts) == 0; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 277 | 0 | $value = $value->as('Data::Identifier'); | |||||||||||||||||||||||||||||||||||||
| 278 | 0 | $type = 'Data::Identifier'; | |||||||||||||||||||||||||||||||||||||
| 279 | } else { | ||||||||||||||||||||||||||||||||||||||
| 280 | 0 | $type = 'Data::Identifier'; | |||||||||||||||||||||||||||||||||||||
| 281 | 0 | $value = Data::Identifier->new(from => $value); | |||||||||||||||||||||||||||||||||||||
| 282 | } | ||||||||||||||||||||||||||||||||||||||
| 283 | } else { | ||||||||||||||||||||||||||||||||||||||
| 284 | 0 | $type = 'string'; | |||||||||||||||||||||||||||||||||||||
| 285 | } | ||||||||||||||||||||||||||||||||||||||
| 286 | } elsif ($type eq 'ise') { | ||||||||||||||||||||||||||||||||||||||
| 287 | 0 | $type = 'Data::Identifier'; | |||||||||||||||||||||||||||||||||||||
| 288 | 0 | $value = Data::Identifier->new(ise => $value); | |||||||||||||||||||||||||||||||||||||
| 289 | } | ||||||||||||||||||||||||||||||||||||||
| 290 | |||||||||||||||||||||||||||||||||||||||
| 291 | 15 | ▶ | if ($type eq 'string') { | ||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||
| 292 | 15 | ▶ | return $_words{lc $value} // croak 'No such word'; | ||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$_words{lc $value} // croak("No such word")
MC/DC0%0/2
$_words{lc $value} // croak("No such word")
$_words{lc $value}
croak("No such word")
Truth table33%1/3
A // B
A= $_words{lc $value}B= croak("No such word")
| |||||||||||||||||||||||||||||||||||||||
| 293 | } elsif ($type eq 'ucsur') { | ||||||||||||||||||||||||||||||||||||||
| 294 | 0 | ▶ | if ($value =~ /^U\+([0-9a-fA-F]{4,6})\z/) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 295 | 0 | $value = hex($1); | |||||||||||||||||||||||||||||||||||||
| 296 | } | ||||||||||||||||||||||||||||||||||||||
| 297 | 0 | ▶ | return $_by_ucsur{$value} // croak 'No such word'; | ||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$_by_ucsur{$value} // croak("No such word")
MC/DC0%0/2
$_by_ucsur{$value} // croak("No such word")
$_by_ucsur{$value}
croak("No such word")
Truth table0%0/3
A // B
A= $_by_ucsur{$value}B= croak("No such word")
| |||||||||||||||||||||||||||||||||||||||
| 298 | } elsif ($type eq 'Data::Identifier') { | ||||||||||||||||||||||||||||||||||||||
| 299 | 0 | ▶ | return $_by_ise{$value->uuid(default => undef, no_defaults => 1) // $value->ise} // croak 'No such word'; | ||||||||||||||||||||||||||||||||||||
|
Condition0%0/6
$_by_ise{$value->uuid("default", undef, "no_defaults", 1) // $value->ise} // croak("No such word")
$value->uuid("default", undef, "no_defaults", 1) // $value->ise
MC/DC0%0/2
$_by_ise{$value->uuid("default", undef, "no_defaults", 1) // $value->ise} // croak("No such word")
$_by_ise{$value->uuid("default", undef, "no_defaults", 1) // $value->ise}
croak("No such word")
MC/DC0%0/2
$value->uuid("default", undef, "no_defaults", 1) // $value->ise
$value->uuid("default", undef, "no_defaults", 1)
$value->ise
Truth table0%0/3
A // B
A= $_by_ise{$value->uuid("default", undef, "no_defaults", 1) // $value->ise}B= croak("No such word")
Truth table0%0/3
A // B
A= $value->uuid("default", undef, "no_defaults", 1)B= $value->ise
| |||||||||||||||||||||||||||||||||||||||
| 300 | } else { | ||||||||||||||||||||||||||||||||||||||
| 301 | 0 | croak 'Bad type: '.$type; | |||||||||||||||||||||||||||||||||||||
| 302 | } | ||||||||||||||||||||||||||||||||||||||
| 303 | } | ||||||||||||||||||||||||||||||||||||||
| 304 | |||||||||||||||||||||||||||||||||||||||
| 305 | |||||||||||||||||||||||||||||||||||||||
| 306 | # NOTE: Implemented via Lingua::Generic::Interface::Word | ||||||||||||||||||||||||||||||||||||||
| 307 | |||||||||||||||||||||||||||||||||||||||
| 308 | |||||||||||||||||||||||||||||||||||||||
| 309 | sub ucsur { | ||||||||||||||||||||||||||||||||||||||
| 310 | 0 | ▶ | my ($self, %opts) = @_; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
ucsur: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 311 | 0 | my $has_default = exists $opts{default}; | |||||||||||||||||||||||||||||||||||||
| 312 | 0 | my $default = delete $opts{default}; | |||||||||||||||||||||||||||||||||||||
| 313 | 0 | my $as = delete $opts{as}; | |||||||||||||||||||||||||||||||||||||
| 314 | 0 | my $ucsur = $self->{ucsur}; | |||||||||||||||||||||||||||||||||||||
| 315 | |||||||||||||||||||||||||||||||||||||||
| 316 | 0 | delete $opts{no_defaults}; | |||||||||||||||||||||||||||||||||||||
| 317 | |||||||||||||||||||||||||||||||||||||||
| 318 | 0 | ▶ | croak 'Stray options passed' if scalar keys %opts; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 319 | |||||||||||||||||||||||||||||||||||||||
| 320 | 0 | ▶ | unless (defined $ucsur) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 321 | 0 | ▶ | return $opts{default} if exists $opts{default}; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 322 | 0 | croak 'No value found'; | |||||||||||||||||||||||||||||||||||||
| 323 | } | ||||||||||||||||||||||||||||||||||||||
| 324 | |||||||||||||||||||||||||||||||||||||||
| 325 | 0 | ▶ | return $ucsur unless defined $as; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 326 | |||||||||||||||||||||||||||||||||||||||
| 327 | 0 | ▶ | $self->{ucsur_id} //= Data::Identifier::Generate->unicode_character(unicode => $ucsur)->register; | ||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$self->{"ucsur_id"} //= "Data::Identifier::Generate"->unicode_character("unicode", $ucsur)->register
MC/DC0%0/2
$self->{"ucsur_id"} //= "Data::Identifier::Generate"->unicode_character("unicode", $ucsur)->register
$self->{"ucsur_id"}
"Data::Identifier::Generate"->unicode_character("unicode", $ucsur)->register
Truth table0%0/3
A //= B
A= $self->{"ucsur_id"}B= "Data::Identifier::Generate"->unicode_character("unicode", $ucsur)->register
| |||||||||||||||||||||||||||||||||||||||
| 328 | |||||||||||||||||||||||||||||||||||||||
| 329 | 0 | return $self->{ucsur_id}->as($as, so => $self); | |||||||||||||||||||||||||||||||||||||
| 330 | } | ||||||||||||||||||||||||||||||||||||||
| 331 | |||||||||||||||||||||||||||||||||||||||
| 332 | |||||||||||||||||||||||||||||||||||||||
| 333 | # NOTE: Implemented via Lingua::Generic::Interface::Word | ||||||||||||||||||||||||||||||||||||||
| 334 | |||||||||||||||||||||||||||||||||||||||
| 335 | |||||||||||||||||||||||||||||||||||||||
| 336 | # NOTE: Implemented via Lingua::Generic::Interface::Word | ||||||||||||||||||||||||||||||||||||||
| 337 | |||||||||||||||||||||||||||||||||||||||
| 338 | |||||||||||||||||||||||||||||||||||||||
| 339 | sub has_type { | ||||||||||||||||||||||||||||||||||||||
| 340 | 0 | ▶ | my ($self, %opts) = @_; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
has_type: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 341 | 0 | my $as = delete $opts{as}; | |||||||||||||||||||||||||||||||||||||
| 342 | |||||||||||||||||||||||||||||||||||||||
| 343 | 0 | delete $opts{default}; | |||||||||||||||||||||||||||||||||||||
| 344 | 0 | delete $opts{no_defaults}; | |||||||||||||||||||||||||||||||||||||
| 345 | |||||||||||||||||||||||||||||||||||||||
| 346 | 0 | ▶ | croak 'Stray options passed' if scalar keys %opts; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 347 | |||||||||||||||||||||||||||||||||||||||
| 348 | 0 | ▶ | return WK_WORD_TYPE if !defined($as) || WK_WORD_TYPE->isa($as); | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not defined $as or ${my $v = bless( {"id" => "baf7bee1-0889-4a84-afc2-4904857d0571","id_cache" => {"a8d1637d-af19-49e9-9ef8-6bc1fbcf6439" => "urn:uuid:baf7bee1-0889-4a84-afc2-4904857d0571","d08dc905-bbf6-4183-b219-67723c3c8374" => "2.25.248522776026855569129824334546621760881"},"tagname" => ["toki-pona-word"],"type" => bless( {"id" => "8be115d2-dc2f-4a98-91e1-a6e3075cbc31","id_cache" => {"039e0bb7-5dd3-40ee-a98c-596ff6cce405" => 119,"a8d1637d-af19-49e9-9ef8-6bc1fbcf6439" => "urn:uuid:8be115d2-dc2f-4a98-91e1-a6e3075cbc31","d08dc905-bbf6-4183-b219-67723c3c8374" => "2.25.185931400843933321174392841337080429617","f87a38cb-fd13-4e15-866c-e49901adbec5" => 2},"tagname" => ["uuid"],"type" => {},"validate" => qr/^[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}\z/u}, 'Data::Identifier' )}, 'Data::Identifier' );$v->{"type"}{"type"} = $v->{"type"}; \$v}->isa($as)
MC/DC0%0/2
not defined $as or ${my $v = bless( {"id" => "baf7bee1-0889-4a84-afc2-4904857d0571","id_cache" => {"a8d1637d-af19-49e9-9ef8-6bc1fbcf6439" => "urn:uuid:baf7bee1-0889-4a84-afc2-4904857d0571","d08dc905-bbf6-4183-b219-67723c3c8374" => "2.25.248522776026855569129824334546621760881"},"tagname" => ["toki-pona-word"],"type" => bless( {"id" => "8be115d2-dc2f-4a98-91e1-a6e3075cbc31","id_cache" => {"039e0bb7-5dd3-40ee-a98c-596ff6cce405" => 119,"a8d1637d-af19-49e9-9ef8-6bc1fbcf6439" => "urn:uuid:8be115d2-dc2f-4a98-91e1-a6e3075cbc31","d08dc905-bbf6-4183-b219-67723c3c8374" => "2.25.185931400843933321174392841337080429617","f87a38cb-fd13-4e15-866c-e49901adbec5" => 2},"tagname" => ["uuid"],"type" => {},"validate" => qr/^[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}\z/u}, 'Data::Identifier' )}, 'Data::Identifier' );$v->{"type"}{"type"} = $v->{"type"}; \$v}->isa($as)
not defined $as
${my $v = bless( {"id" => "baf7bee1-0889-4a84-afc2-4904857d0571","id_cache" => {"a8d1637d-af19-49e9-9ef8-6bc1fbcf6439" => "urn:uuid:baf7bee1-0889-4a84-afc2-4904857d0571","d08dc905-bbf6-4183-b219-67723c3c8374" => "2.25.248522776026855569129824334546621760881"},"tagname" => ["toki-pona-word"],"type" => bless( {"id" => "8be115d2-dc2f-4a98-91e1-a6e3075cbc31","id_cache" => {"039e0bb7-5dd3-40ee-a98c-596ff6cce405" => 119,"a8d1637d-af19-49e9-9ef8-6bc1fbcf6439" => "urn:uuid:8be115d2-dc2f-4a98-91e1-a6e3075cbc31","d08dc905-bbf6-4183-b219-67723c3c8374" => "2.25.185931400843933321174392841337080429617","f87a38cb-fd13-4e15-866c-e49901adbec5" => 2},"tagname" => ["uuid"],"type" => {},"validate" => qr/^[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}\z/u}, 'Data::Identifier' )}, 'Data::Identifier' );$v->{"type"}{"type"} = $v->{"type"}; \$v}->isa($as)
Truth table0%0/3
not(A) or B
A= not defined $asB= ${my $v = bless( {"id" => "baf7bee1-0889-4a84-afc2-4904857d0571","id_cache" => {"a8d1637d-af19-49e9-9ef8-6bc1fbcf6439" => "urn:uuid:baf7bee1-0889-4a84-afc2-4904857d0571","d08dc905-bbf6-4183-b219-67723c3c8374" => "2.25.248522776026855569129824334546621760881"},"tagname" => ["toki-pona-word"],"type" => bless( {"id" => "8be115d2-dc2f-4a98-91e1-a6e3075cbc31","id_cache" => {"039e0bb7-5dd3-40ee-a98c-596ff6cce405" => 119,"a8d1637d-af19-49e9-9ef8-6bc1fbcf6439" => "urn:uuid:8be115d2-dc2f-4a98-91e1-a6e3075cbc31","d08dc905-bbf6-4183-b219-67723c3c8374" => "2.25.185931400843933321174392841337080429617","f87a38cb-fd13-4e15-866c-e49901adbec5" => 2},"tagname" => ["uuid"],"type" => {},"validate" => qr/^[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}\z/u}, 'Data::Identifier' )}, 'Data::Identifier' );$v->{"type"}{"type"} = $v->{"type"}; \$v}->isa($as)
| |||||||||||||||||||||||||||||||||||||||
| 349 | |||||||||||||||||||||||||||||||||||||||
| 350 | 0 | return WK_WORD_TYPE->as($as, so => $self); | |||||||||||||||||||||||||||||||||||||
| 351 | } | ||||||||||||||||||||||||||||||||||||||
| 352 | |||||||||||||||||||||||||||||||||||||||
| 353 | |||||||||||||||||||||||||||||||||||||||
| 354 | sub natural_language { | ||||||||||||||||||||||||||||||||||||||
| 355 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
natural_language: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 356 | 0 | return WK_LT_TOK; | |||||||||||||||||||||||||||||||||||||
| 357 | } | ||||||||||||||||||||||||||||||||||||||
| 358 | |||||||||||||||||||||||||||||||||||||||
| 359 | # ---- Overridden methods ---- | ||||||||||||||||||||||||||||||||||||||
| 360 | |||||||||||||||||||||||||||||||||||||||
| 361 | |||||||||||||||||||||||||||||||||||||||
| 362 | |||||||||||||||||||||||||||||||||||||||
| 363 | # ---- Private helpers ---- | ||||||||||||||||||||||||||||||||||||||
| 364 | |||||||||||||||||||||||||||||||||||||||
| 365 | #@returns __PACKAGE__ | ||||||||||||||||||||||||||||||||||||||
| 366 | sub _new { | ||||||||||||||||||||||||||||||||||||||
| 367 | 203 | ▶ | my ($pkg, $str) = @_; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
_new: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 368 | 203 | my $self = bless {class => {}}, $pkg; | |||||||||||||||||||||||||||||||||||||
| 369 | 203 | my $id; | |||||||||||||||||||||||||||||||||||||
| 370 | |||||||||||||||||||||||||||||||||||||||
| 371 | 203 | $str = lc($str); # just to be on the safe side | |||||||||||||||||||||||||||||||||||||
| 372 | |||||||||||||||||||||||||||||||||||||||
| 373 | 203 | $self->{string} = $str; | |||||||||||||||||||||||||||||||||||||
| 374 | |||||||||||||||||||||||||||||||||||||||
| 375 | 203 | $id = Data::Identifier::Generate->generic( | |||||||||||||||||||||||||||||||||||||
| 376 | request => $str, | ||||||||||||||||||||||||||||||||||||||
| 377 | displayname => $str, | ||||||||||||||||||||||||||||||||||||||
| 378 | tagname => $str, | ||||||||||||||||||||||||||||||||||||||
| 379 | style => 'id-based', | ||||||||||||||||||||||||||||||||||||||
| 380 | namespace => WK_WORD_NAMESPACE, | ||||||||||||||||||||||||||||||||||||||
| 381 | generator => WK_WORD_GENERATOR, | ||||||||||||||||||||||||||||||||||||||
| 382 | )->register; | ||||||||||||||||||||||||||||||||||||||
| 383 | |||||||||||||||||||||||||||||||||||||||
| 384 | 203 | $self->{id} = $id; | |||||||||||||||||||||||||||||||||||||
| 385 | |||||||||||||||||||||||||||||||||||||||
| 386 | 203 | $_words{$str} = $self; | |||||||||||||||||||||||||||||||||||||
| 387 | 203 | $_by_ise{$id->uuid} = $self; | |||||||||||||||||||||||||||||||||||||
| 388 | 203 | return $self; | |||||||||||||||||||||||||||||||||||||
| 389 | } | ||||||||||||||||||||||||||||||||||||||
| 390 | |||||||||||||||||||||||||||||||||||||||
| 391 | sub as { | ||||||||||||||||||||||||||||||||||||||
| 392 | 0 | ▶ | my ($self, $as, @opts) = @_; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
as: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 393 | 0 | my Data::Identifier $id = $self->{id}; | |||||||||||||||||||||||||||||||||||||
| 394 | |||||||||||||||||||||||||||||||||||||||
| 395 | 0 | ▶ | if (scalar(@opts) == 0) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 396 | 0 | ▶ | return $self if $self->isa($as); | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 397 | 0 | ▶ | return $id if $as eq 'Data::Identifier'; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 398 | |||||||||||||||||||||||||||||||||||||||
| 399 | 0 | ▶ | if ($as eq 'Lingua::famibeib::Word') { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 400 | 0 | require Lingua::famibeib::Word; | |||||||||||||||||||||||||||||||||||||
| 401 | 0 | return Lingua::famibeib::Word->new(from => $self); | |||||||||||||||||||||||||||||||||||||
| 402 | } | ||||||||||||||||||||||||||||||||||||||
| 403 | } | ||||||||||||||||||||||||||||||||||||||
| 404 | |||||||||||||||||||||||||||||||||||||||
| 405 | 0 | return $id->as($as, @opts); | |||||||||||||||||||||||||||||||||||||
| 406 | } | ||||||||||||||||||||||||||||||||||||||
| 407 | |||||||||||||||||||||||||||||||||||||||
| 408 | 0 | ▶ | sub ise { goto &Data::Identifier::Interface::Simple::ise } # overridden using tail-call | ||||||||||||||||||||||||||||||||||||
|
Subroutine
ise: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 409 | |||||||||||||||||||||||||||||||||||||||
| 410 | sub _known_provider { | ||||||||||||||||||||||||||||||||||||||
| 411 | 0 | ▶ | my ($pkg, $class, %opts) = @_; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
_known_provider: not called CC=6 SCAR=37.4
| |||||||||||||||||||||||||||||||||||||||
| 412 | |||||||||||||||||||||||||||||||||||||||
| 413 | 0 | ▶ | croak 'Unsupported options passed' if scalar(keys %opts); | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 414 | |||||||||||||||||||||||||||||||||||||||
| 415 | 0 | ▶ | if ($class eq 'word' || $class eq 'words') { | ||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition0%0/3
$class eq "word" or $class eq "words"
MC/DC0%0/2
$class eq "word" or $class eq "words"
$class eq "word"
$class eq "words"
Truth table0%0/3
A or B
A= $class eq "word"B= $class eq "words"
| |||||||||||||||||||||||||||||||||||||||
| 416 | 0 | return ([values %_words], rawtype => __PACKAGE__); | |||||||||||||||||||||||||||||||||||||
| 417 | } elsif ($class eq 'stopword') { | ||||||||||||||||||||||||||||||||||||||
| 418 | 0 | return ([grep {$_->{class}{$class}} values %_words], rawtype => __PACKAGE__); | |||||||||||||||||||||||||||||||||||||
| 419 | } elsif ($class eq ':all') { | ||||||||||||||||||||||||||||||||||||||
| 420 | return ([ | ||||||||||||||||||||||||||||||||||||||
| 421 | 0 | values(%_words), | |||||||||||||||||||||||||||||||||||||
| 422 | WK_WORD_GENERATOR, WK_WORD_NAMESPACE, | ||||||||||||||||||||||||||||||||||||||
| 423 | WK_WORD_TYPE, | ||||||||||||||||||||||||||||||||||||||
| 424 | WK_LT_TOK, | ||||||||||||||||||||||||||||||||||||||
| 425 | ], rawtype => 'Data::Identifier::Interface::Simple'); | ||||||||||||||||||||||||||||||||||||||
| 426 | } | ||||||||||||||||||||||||||||||||||||||
| 427 | |||||||||||||||||||||||||||||||||||||||
| 428 | 0 | croak 'Unsupported class'; | |||||||||||||||||||||||||||||||||||||
| 429 | } | ||||||||||||||||||||||||||||||||||||||
| 430 | |||||||||||||||||||||||||||||||||||||||
| 431 | 1 | 1; | |||||||||||||||||||||||||||||||||||||
| 432 | |||||||||||||||||||||||||||||||||||||||
| 433 | __END__ | ||||||||||||||||||||||||||||||||||||||
| 434 | |||||||||||||||||||||||||||||||||||||||
| 435 | =pod | ||||||||||||||||||||||||||||||||||||||
| 436 | |||||||||||||||||||||||||||||||||||||||
| 437 | =encoding UTF-8 | ||||||||||||||||||||||||||||||||||||||
| 438 | |||||||||||||||||||||||||||||||||||||||
| 439 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||
| 440 | |||||||||||||||||||||||||||||||||||||||
| 441 | Lingua::TokiPona::Word - module to interact with the words of Toki Pona | ||||||||||||||||||||||||||||||||||||||
| 442 | |||||||||||||||||||||||||||||||||||||||
| 443 | =head1 VERSION | ||||||||||||||||||||||||||||||||||||||
| 444 | |||||||||||||||||||||||||||||||||||||||
| 445 | version v0.03 | ||||||||||||||||||||||||||||||||||||||
| 446 | |||||||||||||||||||||||||||||||||||||||
| 447 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||
| 448 | |||||||||||||||||||||||||||||||||||||||
| 449 | use Lingua::TokiPona::Word; | ||||||||||||||||||||||||||||||||||||||
| 450 | |||||||||||||||||||||||||||||||||||||||
| 451 | my Lingua::TokiPona::Word $word = Lingua::TokiPona::Word->new(string => 'mi'); | ||||||||||||||||||||||||||||||||||||||
| 452 | |||||||||||||||||||||||||||||||||||||||
| 453 | say $word->as_string; | ||||||||||||||||||||||||||||||||||||||
| 454 | |||||||||||||||||||||||||||||||||||||||
| 455 | This module inherits from | ||||||||||||||||||||||||||||||||||||||
| 456 | L<Lingua::Generic::Interface::Word> (since v0.03), | ||||||||||||||||||||||||||||||||||||||
| 457 | L<Data::Identifier::Interface::Known> (since v0.01), | ||||||||||||||||||||||||||||||||||||||
| 458 | L<Data::Identifier::Interface::Simple> (since v0.01), | ||||||||||||||||||||||||||||||||||||||
| 459 | and L<Data::Identifier::Interface::Subobjects> (since v0.01). | ||||||||||||||||||||||||||||||||||||||
| 460 | |||||||||||||||||||||||||||||||||||||||
| 461 | =head1 OVERVIEW | ||||||||||||||||||||||||||||||||||||||
| 462 | |||||||||||||||||||||||||||||||||||||||
| 463 | Toki Pona is a constructed language that features a specifically small set of vocables. | ||||||||||||||||||||||||||||||||||||||
| 464 | This module abstracts those words. It aims to contain all known words (as of v0.02: which is currently not yet fully true). | ||||||||||||||||||||||||||||||||||||||
| 465 | |||||||||||||||||||||||||||||||||||||||
| 466 | As the vocabulary is so limited, this module does hold all the words in memory at all times. | ||||||||||||||||||||||||||||||||||||||
| 467 | This means that there are never two different object instances for the same words. | ||||||||||||||||||||||||||||||||||||||
| 468 | (Note that this may limit the usefulness of L<Data::Identifier::Interface::Subobjects>). | ||||||||||||||||||||||||||||||||||||||
| 469 | |||||||||||||||||||||||||||||||||||||||
| 470 | That said, synonyms are consider different words. | ||||||||||||||||||||||||||||||||||||||
| 471 | So this is round-trip safe (you always get the word you asked for, not one of it's synonyms). | ||||||||||||||||||||||||||||||||||||||
| 472 | |||||||||||||||||||||||||||||||||||||||
| 473 | To get a list of all known words use L</known>. | ||||||||||||||||||||||||||||||||||||||
| 474 | |||||||||||||||||||||||||||||||||||||||
| 475 | =head1 METHODS | ||||||||||||||||||||||||||||||||||||||
| 476 | |||||||||||||||||||||||||||||||||||||||
| 477 | =head2 new | ||||||||||||||||||||||||||||||||||||||
| 478 | |||||||||||||||||||||||||||||||||||||||
| 479 | my Lingua::TokiPona::Word $word = Lingua::TokiPona::Word->new($type => $value); | ||||||||||||||||||||||||||||||||||||||
| 480 | # e.g.: | ||||||||||||||||||||||||||||||||||||||
| 481 | my Lingua::TokiPona::Word $word = Lingua::TokiPona::Word->new(string => 'mi'); | ||||||||||||||||||||||||||||||||||||||
| 482 | |||||||||||||||||||||||||||||||||||||||
| 483 | (since v0.01) | ||||||||||||||||||||||||||||||||||||||
| 484 | |||||||||||||||||||||||||||||||||||||||
| 485 | Constructs a new word. | ||||||||||||||||||||||||||||||||||||||
| 486 | The word is normalised as part of this. | ||||||||||||||||||||||||||||||||||||||
| 487 | This method deduplicate instances. | ||||||||||||||||||||||||||||||||||||||
| 488 | |||||||||||||||||||||||||||||||||||||||
| 489 | Currently the following types (C<$type>) are supported: | ||||||||||||||||||||||||||||||||||||||
| 490 | |||||||||||||||||||||||||||||||||||||||
| 491 | =over | ||||||||||||||||||||||||||||||||||||||
| 492 | |||||||||||||||||||||||||||||||||||||||
| 493 | =item C<from> | ||||||||||||||||||||||||||||||||||||||
| 494 | |||||||||||||||||||||||||||||||||||||||
| 495 | (since v0.01) | ||||||||||||||||||||||||||||||||||||||
| 496 | |||||||||||||||||||||||||||||||||||||||
| 497 | Constructs a word from an object. | ||||||||||||||||||||||||||||||||||||||
| 498 | C<$value> should be a reference. | ||||||||||||||||||||||||||||||||||||||
| 499 | |||||||||||||||||||||||||||||||||||||||
| 500 | Currently references to the following types are supported: | ||||||||||||||||||||||||||||||||||||||
| 501 | L<Lingua::TokiPona::Word>, | ||||||||||||||||||||||||||||||||||||||
| 502 | or anything L<Data::Identifier/new> accepts via C<from>. | ||||||||||||||||||||||||||||||||||||||
| 503 | More types might be supported. | ||||||||||||||||||||||||||||||||||||||
| 504 | |||||||||||||||||||||||||||||||||||||||
| 505 | If C<$value> is not a reference the value is parsed as per C<string> if it looks like a word string (experimental since v0.01). | ||||||||||||||||||||||||||||||||||||||
| 506 | |||||||||||||||||||||||||||||||||||||||
| 507 | =item C<ise> | ||||||||||||||||||||||||||||||||||||||
| 508 | |||||||||||||||||||||||||||||||||||||||
| 509 | (since v0.02) | ||||||||||||||||||||||||||||||||||||||
| 510 | |||||||||||||||||||||||||||||||||||||||
| 511 | Constructs a word from a ISE (such as returned by L<Data::Identifier::Interface::Simple/ise>). | ||||||||||||||||||||||||||||||||||||||
| 512 | |||||||||||||||||||||||||||||||||||||||
| 513 | =item C<string> | ||||||||||||||||||||||||||||||||||||||
| 514 | |||||||||||||||||||||||||||||||||||||||
| 515 | (since v0.01) | ||||||||||||||||||||||||||||||||||||||
| 516 | |||||||||||||||||||||||||||||||||||||||
| 517 | Constructs a word from it's (latin) string representation. | ||||||||||||||||||||||||||||||||||||||
| 518 | |||||||||||||||||||||||||||||||||||||||
| 519 | =item C<ucsur> | ||||||||||||||||||||||||||||||||||||||
| 520 | |||||||||||||||||||||||||||||||||||||||
| 521 | (since v0.02) | ||||||||||||||||||||||||||||||||||||||
| 522 | |||||||||||||||||||||||||||||||||||||||
| 523 | Constructs a word from the UCSUR code point. | ||||||||||||||||||||||||||||||||||||||
| 524 | |||||||||||||||||||||||||||||||||||||||
| 525 | See L</ucsur> for details. | ||||||||||||||||||||||||||||||||||||||
| 526 | |||||||||||||||||||||||||||||||||||||||
| 527 | Accepts the numerical code point or standard Unicode notation (C<U+xxxx>). | ||||||||||||||||||||||||||||||||||||||
| 528 | |||||||||||||||||||||||||||||||||||||||
| 529 | =back | ||||||||||||||||||||||||||||||||||||||
| 530 | |||||||||||||||||||||||||||||||||||||||
| 531 | =head2 as_string | ||||||||||||||||||||||||||||||||||||||
| 532 | |||||||||||||||||||||||||||||||||||||||
| 533 | my $str = $word->as_string; | ||||||||||||||||||||||||||||||||||||||
| 534 | |||||||||||||||||||||||||||||||||||||||
| 535 | (since v0.01) | ||||||||||||||||||||||||||||||||||||||
| 536 | |||||||||||||||||||||||||||||||||||||||
| 537 | Returns the string representation of the word. | ||||||||||||||||||||||||||||||||||||||
| 538 | |||||||||||||||||||||||||||||||||||||||
| 539 | See also: L<Lingua::Generic::Interface::Word/as_string>. | ||||||||||||||||||||||||||||||||||||||
| 540 | |||||||||||||||||||||||||||||||||||||||
| 541 | =head2 ucsur | ||||||||||||||||||||||||||||||||||||||
| 542 | |||||||||||||||||||||||||||||||||||||||
| 543 | my $ucsur = $word->ucsur( [ %opts ] ); | ||||||||||||||||||||||||||||||||||||||
| 544 | |||||||||||||||||||||||||||||||||||||||
| 545 | (since v0.02) | ||||||||||||||||||||||||||||||||||||||
| 546 | |||||||||||||||||||||||||||||||||||||||
| 547 | Returns the Under-ConScript Unicode Registry (UCSUR) code point of the word or C<die>s if there is none. | ||||||||||||||||||||||||||||||||||||||
| 548 | |||||||||||||||||||||||||||||||||||||||
| 549 | Returns the numerical Unicode code point unless C<as> is given. | ||||||||||||||||||||||||||||||||||||||
| 550 | |||||||||||||||||||||||||||||||||||||||
| 551 | The following options are supported: | ||||||||||||||||||||||||||||||||||||||
| 552 | |||||||||||||||||||||||||||||||||||||||
| 553 | =over | ||||||||||||||||||||||||||||||||||||||
| 554 | |||||||||||||||||||||||||||||||||||||||
| 555 | =item C<as> | ||||||||||||||||||||||||||||||||||||||
| 556 | |||||||||||||||||||||||||||||||||||||||
| 557 | Returns the value as the passed type. | ||||||||||||||||||||||||||||||||||||||
| 558 | All types supported by L<Data::Identifier/as> are supported. | ||||||||||||||||||||||||||||||||||||||
| 559 | |||||||||||||||||||||||||||||||||||||||
| 560 | =item C<default> | ||||||||||||||||||||||||||||||||||||||
| 561 | |||||||||||||||||||||||||||||||||||||||
| 562 | The default value to return if no other value is available. | ||||||||||||||||||||||||||||||||||||||
| 563 | This can be set to C<undef> to let this method return C<undef> (not C<die>). | ||||||||||||||||||||||||||||||||||||||
| 564 | |||||||||||||||||||||||||||||||||||||||
| 565 | =item C<no_defaults> | ||||||||||||||||||||||||||||||||||||||
| 566 | |||||||||||||||||||||||||||||||||||||||
| 567 | This option is accepted but ignored. | ||||||||||||||||||||||||||||||||||||||
| 568 | |||||||||||||||||||||||||||||||||||||||
| 569 | =back | ||||||||||||||||||||||||||||||||||||||
| 570 | |||||||||||||||||||||||||||||||||||||||
| 571 | =head2 eq | ||||||||||||||||||||||||||||||||||||||
| 572 | |||||||||||||||||||||||||||||||||||||||
| 573 | my $bool = $word->eq($other); # $word must be non-undef | ||||||||||||||||||||||||||||||||||||||
| 574 | # or: | ||||||||||||||||||||||||||||||||||||||
| 575 | my $bool = Lingua::TokiPona::Word::eq($word, $other); # $word can be undef | ||||||||||||||||||||||||||||||||||||||
| 576 | |||||||||||||||||||||||||||||||||||||||
| 577 | (since v0.01) | ||||||||||||||||||||||||||||||||||||||
| 578 | |||||||||||||||||||||||||||||||||||||||
| 579 | Compares two words to be equal. | ||||||||||||||||||||||||||||||||||||||
| 580 | |||||||||||||||||||||||||||||||||||||||
| 581 | If both words are C<undef> they are considered equal. | ||||||||||||||||||||||||||||||||||||||
| 582 | |||||||||||||||||||||||||||||||||||||||
| 583 | If C<$word> or C<$other> is not an instance of L<Lingua::TokiPona::Word> or C<undef> | ||||||||||||||||||||||||||||||||||||||
| 584 | L</new> with the type C<from> is used. | ||||||||||||||||||||||||||||||||||||||
| 585 | |||||||||||||||||||||||||||||||||||||||
| 586 | The operators L<perlop/eq> and L<perlop/ne> are overloaded to this method. | ||||||||||||||||||||||||||||||||||||||
| 587 | |||||||||||||||||||||||||||||||||||||||
| 588 | See also: L<Lingua::Generic::Interface::Word/eq>. | ||||||||||||||||||||||||||||||||||||||
| 589 | |||||||||||||||||||||||||||||||||||||||
| 590 | =head2 cmp | ||||||||||||||||||||||||||||||||||||||
| 591 | |||||||||||||||||||||||||||||||||||||||
| 592 | my $val = $word->cmp($other); # $word must be non-undef | ||||||||||||||||||||||||||||||||||||||
| 593 | # or: | ||||||||||||||||||||||||||||||||||||||
| 594 | my $val = Lingua::TokiPona::Word::cmp($word, $other); # $word can be undef | ||||||||||||||||||||||||||||||||||||||
| 595 | |||||||||||||||||||||||||||||||||||||||
| 596 | (experimental since v0.01) | ||||||||||||||||||||||||||||||||||||||
| 597 | |||||||||||||||||||||||||||||||||||||||
| 598 | Compares the words similar to C<cmp>. This method can be used to order words. | ||||||||||||||||||||||||||||||||||||||
| 599 | To check for them to be equal see L</eq>. | ||||||||||||||||||||||||||||||||||||||
| 600 | |||||||||||||||||||||||||||||||||||||||
| 601 | The parameters are parsed the same way as L</eq>. | ||||||||||||||||||||||||||||||||||||||
| 602 | |||||||||||||||||||||||||||||||||||||||
| 603 | The operator L<perlop/cmp> is overloaded to this method. | ||||||||||||||||||||||||||||||||||||||
| 604 | |||||||||||||||||||||||||||||||||||||||
| 605 | If this method is used for sorting the exact resulting order is not defined. However: | ||||||||||||||||||||||||||||||||||||||
| 606 | |||||||||||||||||||||||||||||||||||||||
| 607 | =over | ||||||||||||||||||||||||||||||||||||||
| 608 | |||||||||||||||||||||||||||||||||||||||
| 609 | =item * | ||||||||||||||||||||||||||||||||||||||
| 610 | |||||||||||||||||||||||||||||||||||||||
| 611 | The order is stable | ||||||||||||||||||||||||||||||||||||||
| 612 | |||||||||||||||||||||||||||||||||||||||
| 613 | =item * | ||||||||||||||||||||||||||||||||||||||
| 614 | |||||||||||||||||||||||||||||||||||||||
| 615 | The order is the same for C<$a-E<gt>cmp($b)> as for C<- $b-E<gt>cmp($a)>. | ||||||||||||||||||||||||||||||||||||||
| 616 | |||||||||||||||||||||||||||||||||||||||
| 617 | =back | ||||||||||||||||||||||||||||||||||||||
| 618 | |||||||||||||||||||||||||||||||||||||||
| 619 | See also: L<Lingua::Generic::Interface::Word/cmp>. | ||||||||||||||||||||||||||||||||||||||
| 620 | |||||||||||||||||||||||||||||||||||||||
| 621 | =head2 has_type | ||||||||||||||||||||||||||||||||||||||
| 622 | |||||||||||||||||||||||||||||||||||||||
| 623 | my $type = $word->has_type( [ %opts ] ); | ||||||||||||||||||||||||||||||||||||||
| 624 | |||||||||||||||||||||||||||||||||||||||
| 625 | (since v0.02) | ||||||||||||||||||||||||||||||||||||||
| 626 | |||||||||||||||||||||||||||||||||||||||
| 627 | Returns the type of the word which will always be the same for all words: a Toki Pona word. | ||||||||||||||||||||||||||||||||||||||
| 628 | |||||||||||||||||||||||||||||||||||||||
| 629 | B<Note:> | ||||||||||||||||||||||||||||||||||||||
| 630 | If you want to know about other roles (e.g. particle vs. noun) this is the wrong method for you. | ||||||||||||||||||||||||||||||||||||||
| 631 | |||||||||||||||||||||||||||||||||||||||
| 632 | The following options are accepted: | ||||||||||||||||||||||||||||||||||||||
| 633 | |||||||||||||||||||||||||||||||||||||||
| 634 | =over | ||||||||||||||||||||||||||||||||||||||
| 635 | |||||||||||||||||||||||||||||||||||||||
| 636 | =item C<as> | ||||||||||||||||||||||||||||||||||||||
| 637 | |||||||||||||||||||||||||||||||||||||||
| 638 | Returns the value as the passed type. | ||||||||||||||||||||||||||||||||||||||
| 639 | All types supported by L<Data::Identifier/as> are supported. | ||||||||||||||||||||||||||||||||||||||
| 640 | |||||||||||||||||||||||||||||||||||||||
| 641 | =item C<default> | ||||||||||||||||||||||||||||||||||||||
| 642 | |||||||||||||||||||||||||||||||||||||||
| 643 | This option is accepted but ignored. | ||||||||||||||||||||||||||||||||||||||
| 644 | |||||||||||||||||||||||||||||||||||||||
| 645 | =item C<no_defaults> | ||||||||||||||||||||||||||||||||||||||
| 646 | |||||||||||||||||||||||||||||||||||||||
| 647 | This option is accepted but ignored. | ||||||||||||||||||||||||||||||||||||||
| 648 | |||||||||||||||||||||||||||||||||||||||
| 649 | =back | ||||||||||||||||||||||||||||||||||||||
| 650 | |||||||||||||||||||||||||||||||||||||||
| 651 | =head2 natural_language | ||||||||||||||||||||||||||||||||||||||
| 652 | |||||||||||||||||||||||||||||||||||||||
| 653 | my Data::Identifier $natural_language = $word->natural_language; | ||||||||||||||||||||||||||||||||||||||
| 654 | |||||||||||||||||||||||||||||||||||||||
| 655 | (since v0.03) | ||||||||||||||||||||||||||||||||||||||
| 656 | |||||||||||||||||||||||||||||||||||||||
| 657 | Returns the natural language this word is in. | ||||||||||||||||||||||||||||||||||||||
| 658 | |||||||||||||||||||||||||||||||||||||||
| 659 | For Toki Pona words it will always return Toki Pona. | ||||||||||||||||||||||||||||||||||||||
| 660 | However this method might be useful together with other modules from the C<Lingua> namespace. | ||||||||||||||||||||||||||||||||||||||
| 661 | |||||||||||||||||||||||||||||||||||||||
| 662 | See also: L<Lingua::Generic::Interface::Word/natural_language>. | ||||||||||||||||||||||||||||||||||||||
| 663 | |||||||||||||||||||||||||||||||||||||||
| 664 | =head2 known | ||||||||||||||||||||||||||||||||||||||
| 665 | |||||||||||||||||||||||||||||||||||||||
| 666 | my @list = Lingua::TokiPona::Word->known($class [, %opts ] ); | ||||||||||||||||||||||||||||||||||||||
| 667 | |||||||||||||||||||||||||||||||||||||||
| 668 | (since v0.01) | ||||||||||||||||||||||||||||||||||||||
| 669 | |||||||||||||||||||||||||||||||||||||||
| 670 | Returns the known items for the given class. | ||||||||||||||||||||||||||||||||||||||
| 671 | |||||||||||||||||||||||||||||||||||||||
| 672 | For details and supported options see L<Data::Identifier::Interface::Known/known>. | ||||||||||||||||||||||||||||||||||||||
| 673 | |||||||||||||||||||||||||||||||||||||||
| 674 | The following classes are supported: | ||||||||||||||||||||||||||||||||||||||
| 675 | |||||||||||||||||||||||||||||||||||||||
| 676 | =over | ||||||||||||||||||||||||||||||||||||||
| 677 | |||||||||||||||||||||||||||||||||||||||
| 678 | =item C<:all> | ||||||||||||||||||||||||||||||||||||||
| 679 | |||||||||||||||||||||||||||||||||||||||
| 680 | (since v0.01) | ||||||||||||||||||||||||||||||||||||||
| 681 | |||||||||||||||||||||||||||||||||||||||
| 682 | Returns all known things. | ||||||||||||||||||||||||||||||||||||||
| 683 | |||||||||||||||||||||||||||||||||||||||
| 684 | =item C<word> | ||||||||||||||||||||||||||||||||||||||
| 685 | |||||||||||||||||||||||||||||||||||||||
| 686 | (since v0.03) | ||||||||||||||||||||||||||||||||||||||
| 687 | |||||||||||||||||||||||||||||||||||||||
| 688 | Returns all known words. | ||||||||||||||||||||||||||||||||||||||
| 689 | |||||||||||||||||||||||||||||||||||||||
| 690 | =item C<words> | ||||||||||||||||||||||||||||||||||||||
| 691 | |||||||||||||||||||||||||||||||||||||||
| 692 | (since v0.02, deprecated since 0.03) | ||||||||||||||||||||||||||||||||||||||
| 693 | |||||||||||||||||||||||||||||||||||||||
| 694 | Deprecated alias for C<word>. | ||||||||||||||||||||||||||||||||||||||
| 695 | |||||||||||||||||||||||||||||||||||||||
| 696 | =item C<stopword> | ||||||||||||||||||||||||||||||||||||||
| 697 | |||||||||||||||||||||||||||||||||||||||
| 698 | (since v0.02) | ||||||||||||||||||||||||||||||||||||||
| 699 | |||||||||||||||||||||||||||||||||||||||
| 700 | Returns all known stopwords. | ||||||||||||||||||||||||||||||||||||||
| 701 | |||||||||||||||||||||||||||||||||||||||
| 702 | =back | ||||||||||||||||||||||||||||||||||||||
| 703 | |||||||||||||||||||||||||||||||||||||||
| 704 | =head1 AUTHOR | ||||||||||||||||||||||||||||||||||||||
| 705 | |||||||||||||||||||||||||||||||||||||||
| 706 | Philipp Schafft <lion@cpan.org> | ||||||||||||||||||||||||||||||||||||||
| 707 | |||||||||||||||||||||||||||||||||||||||
| 708 | =head1 COPYRIGHT AND LICENSE | ||||||||||||||||||||||||||||||||||||||
| 709 | |||||||||||||||||||||||||||||||||||||||
| 710 | This software is Copyright (c) 2026 by Philipp Schafft <lion@cpan.org>. | ||||||||||||||||||||||||||||||||||||||
| 711 | |||||||||||||||||||||||||||||||||||||||
| 712 | This is free software, licensed under: | ||||||||||||||||||||||||||||||||||||||
| 713 | |||||||||||||||||||||||||||||||||||||||
| 714 | The Artistic License 2.0 (GPL Compatible) | ||||||||||||||||||||||||||||||||||||||
| 715 | |||||||||||||||||||||||||||||||||||||||
| 716 | =cut | ||||||||||||||||||||||||||||||||||||||