File: 06-file_identification.t

package info (click to toggle)
liblingua-identify-perl 0.51-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 716 kB
  • sloc: perl: 7,791; makefile: 2
file content (37 lines) | stat: -rw-r--r-- 1,126 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/perl

use Test::More tests => 13 + 3 * 23;
BEGIN { use_ok('Lingua::Identify', qw/:language_identification :language_manipulation/) };

for my $language (get_all_languages()) {
    die "**** Text file for $language language not available" unless -f "t/files/$language";

    my @lang = langof_file("t/files/$language");
    is($lang[0], $language, "Checking identified language is $language.");
    cmp_ok($lang[1],'>','0.16', "Checking probability for $language");
    cmp_ok(confidence(@lang),'>','0.51', "Checking confidence for $language");
}

# Some extra tests

my @pt = langof_file({method=>'smallwords'},'t/files/pt_big');
is($pt[0],'pt');
cmp_ok($pt[1],'>','0.14');
cmp_ok(confidence(@pt),'>','0.50');

@pt = langof_file('t/files/pt_big');
is($pt[0],'pt');
cmp_ok($pt[1],'>','0.18');
cmp_ok(confidence(@pt),'>','0.51');

@pt = langof_file('t/files/en', 't/files/pt_big');
is($pt[0],'pt');
cmp_ok($pt[1],'>','0.13');
cmp_ok(confidence(@pt),'>','0.50');

# Encoding

@pt = langof_file({encoding=>'ISO-8859-1'},'t/files/pt_lt1');
is($pt[0],'pt');
cmp_ok($pt[1],'>','0.16');
cmp_ok(confidence(@pt),'>','0.51');