blob: c080f2fa67666965966e616d761c9debf6d30772 [file] [log] [blame]
Marc Kupietz3e3e3262022-04-12 23:11:45 +02001use strict;
2use warnings;
Marc Kupietzc82b15f2022-07-19 17:36:27 +02003use Test::TempFile;
4use Test::More tests => 4;
Marc Kupietz3e3e3262022-04-12 23:11:45 +02005use Mojo::JSON qw(decode_json encode_json to_json);
6
7use_ok('IDS::DeReKoVecs::Read');
8
9IDS::DeReKoVecs::Read::init_net(
10 "example-models/wpd19_10000/wpd19_10000.vecs",
11 "example-models/wpd19_10000/wpd19_10000.net",
12 0, 1
13);
14my $word = "Grund";
15my $dedupe = 0;
16my $nosp = 0;
17my $res;
18my $cutoff = 50000;
19
20subtest 'predictive neighbours' => sub {
21 $res = get_neighbours( $word, 100, 0, 0, $cutoff, $dedupe, $nosp );
22 is( $res->{paradigmatic}->[1]->{word}, "Reaktion", "primary paradigmatic neighbour of Grund" );
23 is( $res->{syntagmatic}->[0]->{word}, "Hitchcock", "primary syntagmatic neighbour of Grund" );
24};
25
26subtest 'count based collocates' => sub {
27 $res = IDS::DeReKoVecs::Read::getClassicCollocators( getWordNumber($word) );
28 $res = decode_json($res);
29 is( $res->{collocates}->[0]->{word}, "diesem", "primary collocate of Grund" );
30};
31
Marc Kupietzc82b15f2022-07-19 17:36:27 +020032subtest 'dump ascii vecs' => sub {
33 my $t = Test::TempFile->new();
34 $res = IDS::DeReKoVecs::Read::dump_vecs($t->path);
35 $t->exists_ok
36 ->content_like(qr/^10544 200.*/, 'ascii vecs dump')
37 ->content_like(qr/Wortzeichen -?[01]\.[0-9]/, 'ascii vecs dump contains some words');
38};
39
Marc Kupietz3e3e3262022-04-12 23:11:45 +020040done_testing;