Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added db_auto option, changed Lingua::JA::TFWebIDF dependency
- Loading branch information
Showing
5 changed files
with
135 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
use strict; | ||
use warnings; | ||
use utf8; | ||
use Lingua::JA::TermExtractor; | ||
use Test::More; | ||
use Test::Fatal; | ||
use Test::Requires qw/TokyoCabinet/; | ||
|
||
binmode Test::More->builder->$_ => ':utf8' | ||
for qw/output failure_output todo_output/; | ||
|
||
|
||
unlink './test.tch'; | ||
|
||
my %config = ( | ||
appid => 'test', | ||
fetch_df => 0, | ||
driver => 'TokyoCabinet', | ||
df_file => './test.tch', | ||
pos1_filter => [], | ||
pos2_filter => [], | ||
pos3_filter => [], | ||
ng_word => [], | ||
tf_min => 1, | ||
term_length_min => 1, | ||
term_length_max => 30, | ||
df_min => 0, | ||
db_auto => 0, | ||
); | ||
|
||
my $extractor = Lingua::JA::TermExtractor->new(\%config); | ||
my $exception = exception{ $extractor->extract('テスト'); }; | ||
like($exception, qr/not opened/, 'not opened'); | ||
|
||
$extractor->db_open('read'); | ||
$exception = exception{ $extractor->extract('テスト'); }; | ||
is($exception, undef, 'opened'); | ||
$extractor->db_close; | ||
|
||
$extractor = Lingua::JA::TermExtractor->new(\%config); | ||
$exception = exception{ $extractor->tfidf('テスト'); }; | ||
like($exception, qr/not opened/, 'not opened (tfidf)'); | ||
|
||
$extractor->db_open('read'); | ||
$exception = exception{ $extractor->tfidf('テスト'); }; | ||
is($exception, undef, 'opened (tfidf)'); | ||
$extractor->db_close; | ||
|
||
$config{'db_auto'} = 1; | ||
$extractor = Lingua::JA::TermExtractor->new(\%config); | ||
$exception = exception{ $extractor->tfidf('テスト'); }; | ||
is($exception, undef, 'tfidf auto db open'); | ||
|
||
unlink './test.tch'; | ||
|
||
done_testing; |