The Perl Toolchain Summit 2025 Needs You: You can help ๐Ÿ™ Learn more

NAME

Text::Lorem::JA - Japanese Lorem Ipsum generator

SYNOPSIS

# Generated text are represented in Perl internal format (Unicode).
binmode \*STDOUT, ':encoding(UTF-8)';
my $lorem = Text::Lorem::JA->new();
# Generate a string of text with 10 characters.
print $lorem->word(10), "\n";
# => ๅฅฝใใชๅผทใฟใจใ‚’่€ƒใˆใฆ
# Generate a string of text with 10 tokens.
print $lorem->words(10), "\n";
# => ไธป่ฆใช็ด ่ณชใซใ—ใฐใ—ใฐใ‚ใ‚‹ใพใ„ใพใงใฏใฃใใ‚Šใคใ‹ใพใˆใ‚‹
# Generate a string of text with 3 sentences.
# Invoking via class methods are also allowed.
print Text::Lorem::JA->sentences(3), "\n";
# => ใ„ใกใฐใ‚“้ข็™ฝใ„ใ„ใ„ๆ–นใ‚’ใฏใฃใใ‚Šใ•ใ›ใชใ„ไผš็คพใŒใ‚ใฃใฆใ‚‚ใ€
# ใ‚„ใŒใฆใ‹ใ‚ใฃใฆใ€่จฑใ•ใ‚Œใชใ„ใ€‚ไบบ็‰ฉใฎ็”Ÿใใฆใ„ใ‚‹ใ€ใปใ“ใ‚Šใ€
# ๅ“ไฝใฎใ‚ใ‚‰ใ‚ใ‚Œใงใ‚ใ‚‹ใ€‚ๆ–‡ๆ˜Ž็คพไผšใฏใ€ๆญฃใ—ใใใ†ใ„ใ†็ซ‹ๅ ดใซ
# ใ„ใชใŒใ‚‰ใ€ๆฑ‚ใ‚ใฆไธ€ๅกŠใฎๅฒฉ็คใซ่† ็€ใ—ใฆใฟใ‚‹ใ€‚

DESCRIPTION

Text::Lorem::JA generates fake Japanese text via Markov chain.

METHODS

Most of instance methods can be called as class methods. Generated strings are in Perl's internal format (Unicode).

new
$lorem = Text::Lorem::JA->new();
$lorem = Text::Lorem::JA->new( dictionary => ..., chains => ... );

Creates a new Text::Lorem::JA generator object.

Can specify dictionary file and chains for generating sentences.

word
$word = $lorem->word($length);

Returns a exact given $length string.

Argument length represents number of Unicode characters. Not bytes.

words
$words = $lorem->words($number_of_morphems);

Generates a string composed from morphemes of given number.

At Japanese language, words are not delimited by whitespaces in normal style.

sentence
$sentence = $lorem->sentence();

Generates a single sentence.

sentences
$sentences = $lorem->sentences($number_of_sentences);

Generates sentences.

TOOL

You can use lorem_ja executable for generating Japanese Lorem text from CLI.

LICENSE

Copyright (C) ITO Nobuaki.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

AUTHOR

ITO Nobuaki <dayflower@cpan.org>