NAME

Lingua::TokiPona::Word - module to interact with the words of Toki Pona

VERSION

version v0.01

SYNOPSIS

use Lingua::TokiPona::Word;

my Lingua::TokiPona::Word $word = Lingua::TokiPona::Word->new(string => 'mi');

say $word->as_string;

This module inherits from Data::Identifier::Interface::Known, Data::Identifier::Interface::Simple, and Data::Identifier::Interface::Subobjects.

METHODS

new

my Lingua::TokiPona::Word $word = Lingua::TokiPona::Word->new($type => $value);
# e.g.:
my Lingua::TokiPona::Word $word = Lingua::TokiPona::Word->new(string => 'mi');

(since v0.01)

Constructs a new word. The word is normalised as part of this. This method deduplicate instances.

Currently the following types ($type) are supported:

from

(since v0.01)

Constructs a word from an object. $value should be a reference.

Currently references to the following types are supported: Lingua::TokiPona::Word, or anything "new" in Data::Identifier accepts via from. More types might be supported.

If $value is not a reference the value is parsed as per string if it looks like a word string (experimental since v0.01).

string

(since v0.01)

Constructs a word from it's (latin) string representation.

as_string

my $str = $word->as_string;

(since v0.01)

Returns the string representation of the word.

eq

my $bool = $word->eq($other); # $word must be non-undef
# or:
my $bool = Lingua::TokiPona::Word::eq($word, $other); # $word can be undef

(since v0.01)

Compares two words to be equal.

If both words are undef they are considered equal.

If $word or $other is not an instance of Lingua::TokiPona::Word or undef "new" with the type from is used.

The operators "eq" in perlop and "ne" in perlop are overloaded to this method.

cmp

my $val = $word->cmp($other); # $word must be non-undef
# or:
my $val = Lingua::TokiPona::Word::cmp($word, $other); # $word can be undef

(experimental since v0.01)

Compares the words similar to cmp. This method can be used to order words. To check for them to be equal see "eq".

The parameters are parsed the same way as "eq".

The operator "cmp" in perlop is overloaded to this method.

If this method is used for sorting the exact resulting order is not defined. However:

  • The order is stable

  • The order is the same for $a->cmp($b) as for - $b->cmp($a).

AUTHOR

Philipp Schafft <lion@cpan.org>

COPYRIGHT AND LICENSE

This software is Copyright (c) 2026 by Philipp Schafft <lion@cpan.org>.

This is free software, licensed under:

The Artistic License 2.0 (GPL Compatible)