| use strict; |
| use warnings; |
| use Test::TempFile; |
| use Test::More tests => 4; |
| use Mojo::JSON qw(decode_json encode_json to_json); |
| |
| use_ok('IDS::DeReKoVecs::Read'); |
| |
| IDS::DeReKoVecs::Read::init_net( |
| "example-models/wpd19_10000/wpd19_10000.vecs", |
| "example-models/wpd19_10000/wpd19_10000.net", |
| 0, 1 |
| ); |
| my $word = "Grund"; |
| my $dedupe = 0; |
| my $nosp = 0; |
| my $res; |
| my $cutoff = 50000; |
| |
| subtest 'predictive neighbours' => sub { |
| $res = get_neighbours( $word, 100, 0, 0, $cutoff, $dedupe, $nosp ); |
| is( $res->{paradigmatic}->[1]->{word}, "Reaktion", "primary paradigmatic neighbour of Grund" ); |
| is( $res->{syntagmatic}->[0]->{word}, "Hitchcock", "primary syntagmatic neighbour of Grund" ); |
| }; |
| |
| subtest 'count based collocates' => sub { |
| $res = IDS::DeReKoVecs::Read::getClassicCollocators( getWordNumber($word) ); |
| $res = decode_json($res); |
| is( $res->{collocates}->[0]->{word}, "diesem", "primary collocate of Grund" ); |
| }; |
| |
| subtest 'dump ascii vecs' => sub { |
| my $t = Test::TempFile->new(); |
| $res = IDS::DeReKoVecs::Read::dump_vecs($t->path); |
| $t->exists_ok |
| ->content_like(qr/^10544 200.*/, 'ascii vecs dump') |
| ->content_like(qr/Wortzeichen -?[01]\.[0-9]/, 'ascii vecs dump contains some words'); |
| }; |
| |
| done_testing; |