| 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 any language | ||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | package Lingua::Generic::Interface::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 | |||||||||||||||||||||||||||||
| 17 | 1 | our $VERSION = v0.03; | |||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | 1 | ▶ | use parent 'Lingua::Generic::Interface::Element'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | 0 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: not called CC=9 SCAR=45.0
Pod
documented
| |||||||||||||||||||||||||||||
| 23 | 0 | my ($pkg, $type, $value, @opts) = @_; | |||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | 0 | ▶ | croak 'No type given' unless defined $type; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 26 | 0 | ▶ | croak 'No value given' unless defined $value; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 27 | 0 | ▶ | croak 'Stray options passed' if scalar @opts; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | 0 | ▶ | if ($type eq 'from') { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 30 | 0 | ▶ | if (ref $value) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 31 | 0 | ▶ | if ($value->isa(__PACKAGE__)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 32 | 0 | return $value; | |||||||||||||||||||||||||||
| 33 | } else { | ||||||||||||||||||||||||||||
| 34 | ... | ||||||||||||||||||||||||||||
| 35 | 0 | } | |||||||||||||||||||||||||||
| 36 | } else { | ||||||||||||||||||||||||||||
| 37 | 0 | $type = 'string'; | |||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||
| 39 | } elsif ($type eq 'ise') { | ||||||||||||||||||||||||||||
| 40 | ... | ||||||||||||||||||||||||||||
| 41 | 0 | } | |||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | 0 | ▶ | if ($type eq 'string') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 44 | 0 | return bless { | |||||||||||||||||||||||||||
| 45 | string => $value, | ||||||||||||||||||||||||||||
| 46 | }, $pkg; | ||||||||||||||||||||||||||||
| 47 | } else { | ||||||||||||||||||||||||||||
| 48 | 0 | croak 'Bad type: '.$type; | |||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | 0 | ▶ | sub eq { | ||||||||||||||||||||||||||
|
Subroutine
eq: not called CC=9 SCAR=45.0
Pod
documented
| |||||||||||||||||||||||||||||
| 54 | 0 | my ($self, $other, @opts) = @_; | |||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | 0 | ▶ | croak 'Stray options passed' if scalar @opts; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | 0 | ▶ | return 1 if !defined($self) && !defined($other); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $self or defined $other
MC/DC0%0/2
defined $self or defined $other
defined $self
defined $other
Truth table0%0/3
A or B
A= defined $selfB= defined $other
| |||||||||||||||||||||||||||||
| 59 | 0 | ▶ | return undef unless defined($self) && defined($other); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $self and defined $other
MC/DC0%0/2
defined $self and defined $other
defined $self
defined $other
Truth table0%0/3
A and B
A= defined $selfB= defined $other
| |||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | 0 | ▶ | $self = __PACKAGE__->new(from => $self) unless eval {$self->isa(__PACKAGE__)}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 62 | 0 | ▶ | $other = __PACKAGE__->new(from => $other) unless eval {$other->isa(__PACKAGE__)}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||
| 64 | 0 | ▶ | return undef unless ref($self) eq ref($other); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||
| 66 | 0 | return $self->as_string eq $other->as_string; | |||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||
| 70 | 0 | ▶ | sub cmp { | ||||||||||||||||||||||||||
|
Subroutine
cmp: not called CC=9 SCAR=45.0
Pod
documented
| |||||||||||||||||||||||||||||
| 71 | 0 | my ($self, $other, @opts) = @_; | |||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | 0 | ▶ | croak 'Stray options passed' if scalar @opts; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||
| 75 | 0 | ▶ | return 1 if !defined($self) && !defined($other); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $self or defined $other
MC/DC0%0/2
defined $self or defined $other
defined $self
defined $other
Truth table0%0/3
A or B
A= defined $selfB= defined $other
| |||||||||||||||||||||||||||||
| 76 | 0 | ▶ | return undef unless defined($self) && defined($other); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $self and defined $other
MC/DC0%0/2
defined $self and defined $other
defined $self
defined $other
Truth table0%0/3
A and B
A= defined $selfB= defined $other
| |||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||
| 78 | 0 | ▶ | $self = __PACKAGE__->new(from => $self) unless eval {$self->isa(__PACKAGE__)}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 79 | 0 | ▶ | $other = __PACKAGE__->new(from => $other) unless eval {$other->isa(__PACKAGE__)}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||
| 81 | { | ||||||||||||||||||||||||||||
| 82 | 0 | my $v = ref($self) cmp ref($other); | |||||||||||||||||||||||||||
| 83 | 0 | ▶ | return $v if $v != 0; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||
| 86 | { | ||||||||||||||||||||||||||||
| 87 | 0 | my $str_self = $self->as_string; | |||||||||||||||||||||||||||
| 88 | 0 | my $str_other = $other->as_string; | |||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||
| 90 | 0 | return $str_self cmp $str_other; | |||||||||||||||||||||||||||
| 91 | } | ||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||
| 93 | 0 | croak 'BUG!'; | |||||||||||||||||||||||||||
| 94 | } | ||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||
| 100 | # ---- Private helpers ---- | ||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||
| 102 | 1 | 1; | |||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||
| 104 | __END__ | ||||||||||||||||||||||||||||