
Lingua::JA::Summarize - A keyword extractor / summary generator

# Functional style
use Lingua::JA::Summarize qw(:all);
@keywords = keyword_summary('You need longer text to get keywords', {
minwords => 3,
maxwords => 5,
});
print join(' ', @keywords) . "\n";
@keywords = file_keywords_summary('filename_to_analyze.txt', {
minwords => 3,
maxwords => 5,
});
print join(' ', @keywords) . "\n";
# OO style
use Lingua::JA::Summarize;
$s = Lingua::JA::Summarize->new;
$s->analyze('You need longer text to obtain keywords');
$s->analyze_file('filename_to_analyze.txt');
@keywords = $s->keywords({ minwords => 3, maxwords => 5 });
print join(' ', @keywords) . "\n";

Lingua::JA::Summarize is a keyword extractor / summary generator for Japanese texts. By using MeCab, the module extracts keywords from Japanese texts.

You may provide behaviour parameters through a hashref.
ex. new({ mecab => '/usr/local/mecab/bin/mecab' })

Use either of the function to analyze text. The functions throw an error if failed.

Returns an array of keywords. Following parameters are available for controlling the output.

Use the descibed member functions to control the behaviour of the analyzer.
Sets or retrives a flag indicating whether or not, not to split a word consisting of alphabets and numerics. Also controls the splitting of apostrophies.
If set to false, "O'Reilly" would be treated as "o reilly", "30boxes" as "30 boxes".
The default is true.
Sets or retrieves the default cost applied for unknown words. The default is 1.0.
Sets or retrieves a flag indicating whether or not to consider consecutive ascii word and Japanese word as a single word. The default is true.
If set to true, strings like "ǧ¾Úapi" and "lamda´Ø¿ô" are treated as single words.
Sets or retrieves mecab path. The default is "mecab".
Sets or retrieves a hash array listing omitted words. Default hash is generated by Lingua::JA::Summarize::NG function.
Sets or retrieves a flag indicating whether or not to omit numbers.
Sets or retrieves a factor value to be used for calculating weight of single-character words. The default is 0.5.
Returns list of statistics.
Sets or retrieves a flag indicating whether or not to treat URLs as single words.
Returns number of the words analyzed.

The default properties can be modified by setting %Lingua::JA::Summarize::LJS_Defaults or by setting environment variable with the property names uppercased and with LJS_ prefix.
For example, to set the mecab_charset property,
use Lingua::JA::Summarize qw(:all);
$LJS_Defaults{mecab_charset} = 'sjis' unless defined $LJS_Defaults{mecab_charset};
% LJS_MECAB_CHARSET=sjis perl -Ilib t/02-keyword.t

Given a text or a filename to analyze, returns an array of keywords. Either any properties described in the CONTROLLING THE BEHAVIOUR section or the parameters of the keywords member function could be set as parameters.
Returns a default hashref containing NG words.

Kazuho Oku <kazuhooku ___at___ gmail.com>

Thanks to Takesako-san for writing the prototype.

Copyright (C) 2006-2008 Cybozu Labs, Inc.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.7 or, at your option, any later version of Perl 5 you may have available.