NAME

Lingua::famibeib::Word - module to interact with the famibeib words

VERSION

version v0.01

SYNOPSIS

use Lingua::famibeib::Word;

my Lingua::famibeib::Word $word = Lingua::famibeib::Word->new(string => 'baba');

my $str = $word->as_string;

This package is used to store individual famibeib words and query them about their properties.

This module inherits from Data::Identifier::Interface::Simple, and Data::Identifier::Interface::Subobjects. Instances are overloaded so they will stringify to their string representation as per "as_string".

new

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

(since v0.01)

Constructs a new word. The word is normalised as part of this. This method might deduplicate instances. So not all instances might be new objects. This is done to support working with large texts in an efficient manner.

Currently the following types ($type) are supported:

from

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

Currently references to the following types are supported: Data::Identifier, Data::Identifier::Interface::Simple, Data::URIID::Base, and Lingua::famibeib::Word. 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

Constructs a word from it's string representation.

as_string

my $str = $word->as_string;

(since v0.01)

Returns the string representation of the word.

stem

my Lingua::famibeib::Word $stem = $word->stem;

(since v0.01)

Returns the stem of a word. If this word is already a stem it returns itself.

modifiers

my @modifiers = $word->modifiers;

(since v0.01)

Returns the list of the modifiers of the word.

Note: The list is not sorted in any way.

get_modifier_by_master_mora

my Lingua::famibeib::Modifier $modifier = $word->get_modifier_by_master_mora($mora [, %opts]);

(experimental since v0.01)

Returns a modifier based on a master mora. See "master_mora" in Lingua::famibeib::Modifier for details.

Optionally the following options might be passed:

default

The default value to return if the modifier is not used. This can be set to undef to switch the method from dieing to returning undef if no such modifier is part of the word.

eq

my $bool = $word->eq($other); # $word must be non-undef
# or:
my $bool = Lingua::famibeib::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::famibeib::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::famibeib::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:

  • If the words differ in stems they are sorted by stem first

  • The order is stable

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

is_verb

my $bool = $word->is_verb;

(since v0.01)

Returns true-ish if the current word is a verb or false-ish if it is not.

is_negative

my $bool = $word->is_negative;

(since v0.01)

Returns true-ish if the current word is negative or false-ish if it is not.

is_application

my $bool = $word->is_application;

(since v0.01)

Returns true-ish if the current word is in application form or false-ish if it is not.

register

$word->register;

(since v0.01)

Registers the word with this module. A registered word will be kept in memory indefinitely. It is used for deduplication and some types of lookups.

This method will return $word. This can be used to build constants.

Note: Calling this multiple times on the same word is fine. However, doing so might waste some time.

Note: If this word is not a stem itself it's stem is also registered.

AUTHOR

Löwenfelsen UG (haftungsbeschränkt) <support@loewenfelsen.net>

COPYRIGHT AND LICENSE

This software is Copyright (c) 2025 by Löwenfelsen UG (haftungsbeschränkt) <support@loewenfelsen.net>.

This is free software, licensed under:

The Artistic License 2.0 (GPL Compatible)