Александр Сапожников > Lingua-RU-Inflect-0.04 > Lingua::RU::Inflect

Download:
Lingua-RU-Inflect-0.04.tar.gz

Dependencies

Annotate this POD

CPAN RT

New  1
Open  0
View/Report Bugs
Module Version: 0.04   Source   Latest Release: Lingua-RU-Inflect-0.05

NAME ^

Lingua::RU::Inflect - Inflect russian names.

VERSION ^

Version 0.04

DESCRIPTION ^

Lingua::RU::Inflect is a perl module that provides Russian linguistic procedures such as declension of given names (with some nouns and adjectives too), and gender detection by given name.

Choosing of proper forms of varying prepositions which added in 0.02 now DEPRECATED, use Lingua::RU::Preposition instead.

SYNOPSIS ^

Inflects russian names which represented in UTF-8.

Perhaps a little code snippet.

    use Lingua::RU::Inflect;

    my @name = qw/Петрова Любовь Степановна/;
    # Transliteration of above line is: Petrova Lyubov' Stepanovna

    my $gender = detect_gender_by_given_name(@name);
    # $gender == FEMININE

    my @genitive = inflect_given_name(GENITIVE, @name);
    # $genitive == qw/Петровой Любови Степановны/;
    # Transliteration of above line is: Petrovoy Lyubovi Stepanovny

TO DO ^

1. Inflect any nouns, any words, anything... 2. Move preposition related function to Lingua::RU::Preposition

EXPORT ^

Function detect_gender_by_given_name and detect_gender_by_given_name are exported by default.

Also you can export only case names:

    use Lingua::RU::Inflect qw/:cases/;

Or only subs and genders

    use Lingua::RU::Inflect qw/:subs :genders/;

Or only short aliases for subs

    use Lingua::RU::Inflect qw/:short/;

Or everything: subs, aliases, genders and case names:

    use Lingua::RU::Inflect qw/:all/; # or
    use Lingua::RU::Inflect qw/:cases :genders :subs :short/;

FUNCTIONS ^

detect_gender_by_given_name

Try to detect gender by name. Up to three arguments expected: lastname, firstname, patronym.

Return MASCULINE, FEMININE for successful detection or undef when function can't detect gender.

Detection rules

When name match some rule, rest of rules are ignored.

  1. Patronym (russian отчество — otchestvo), if presented, gives unambiguous detection rules: feminine patronyms ends with “na”, masculine ones ends with “ich” and “ych”.
  2. Most of russian feminine firstnames ends to vowels “a” and “ya”. Most of russian masculine firstnames ends to consonants.

    There's exists exceptions for both rules: feminine names such as russian name Lubov' (Любовь) and foreign names Ruf' (Руфь), Rachil' (Рахиль) etc. Masculine names also often have affectionate diminutive forms: Alyosha (Алёша) for Alexey (Алексей), Kolya (Коля) for Nickolay (Николай) etc. Some affectionate diminutive names are ambiguous: Sasha (Саша) is diminutive name for feminine name Alexandra (Александра) and for masculine name Alexander (Александр), Zhenya (Женя) is diminutive name for feminine name Eugenia (Евгения) and for masculine name Eugene (Евгений) etc.

    These exceptions are processed.

    When got ambiguous result, function try to use next rule.

  3. Most of russian lastnames derived from possessive nouns (and names). Feminine forms of these lastnames ends to “a”. Some lastnames derived from adjectives. Feminine forms of these lastnames ends to “ya”.

_inflect_given_name

Inflects name of given gender to given case. Up to 5 arguments expected: gender, case, lastname, firstname, patronym. Lastname, firstname, patronym must be in Nominative.

Returns list which contains inflected lastname, firstname, patronym.

inflect_given_name

Detects gender by given name and inflect parts of this name.

Expects for up to 4 arguments: case, lastname, firstname, patronym

Available cases are: NOMINATIVE, GENITIVE, DATIVE, ACCUSATIVE, INSTRUMENTAL, PREPOSITIONAL.

It returns list which contains inflected lastname, firstname, patronym

choose_preposition_by_next_word

Chooses preposition by next word and returns chosen preposition.

Expects 2 arguments: preposition and next_word. Preposition should be string with shortest of possible values. Available values of preposition are: 'в', 'из', 'к', 'над', 'о', 'от', 'пред', 'перед', 'под' and 'с'.

There is an aliases for calling this subroutine with common preposition:

izo

izo is an alias for choose_preposition_by_next_word 'из',

ko

ko is an alias for choose_preposition_by_next_word 'к',

nado

nado is an alias for choose_preposition_by_next_word 'над',

ob

ob is an alias for choose_preposition_by_next_word 'о',

oto

oto is an alias for choose_preposition_by_next_word 'от',

podo

podo is an alias for choose_preposition_by_next_word 'под',

predo

predo is an alias for choose_preposition_by_next_word 'пред',

peredo

peredo is an alias for choose_preposition_by_next_word 'перед',

so

so is an alias for choose_preposition_by_next_word 'с',

vo

vo is an alias for choose_preposition_by_next_word 'в',

These aliases are not exported by default. They can be expored with tags :short or :all.

Examples of code with these aliases:

    use Lingua::RU::Inflect qw/:short/;

    map {
        print ob, $_;
    } qw(
        арбузе баране всём Елене ёлке игле йоде
        мне многом огне паре ухе юге яблоке
    );

    map {
        print so, $_;
    } qw(
        огнём водой
        зарёй зноем зрением зябликом
        садом светом слоном спичками ссылкой
        Стёпой стаканом сухарём сэром топором
        жарой жбаном жратвой жуком
        шаром шкафом шлангом шубой
    );

AUTHOR ^

Alexander Sapozhnikov, <shoorick at cpan.org>

BUGS ^

Please report any bugs or feature requests to bug-lingua-ru-inflect at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Lingua-RU-Inflect. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT ^

You can find documentation for this module with the perldoc command.

    perldoc Lingua::RU::Inflect

You can also look for information at:

SEE ALSO ^

Russian translation of this documentation available at RU/Lingua/RU/Inflect.pod

ACKNOWLEDGEMENTS ^

http://www.imena.org/declension.html (in Russian) for rules of declension.

COPYRIGHT & LICENSE ^

Copyright 2009-2012 Alexander Sapozhnikov.

This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.

See http://dev.perl.org/licenses/ for more information.

syntax highlighting: