Marc Kupietz | 3e3e326 | 2022-04-12 23:11:45 +0200 | [diff] [blame] | 1 | use strict; |
| 2 | use warnings; |
Marc Kupietz | c82b15f | 2022-07-19 17:36:27 +0200 | [diff] [blame^] | 3 | use Test::TempFile; |
| 4 | use Test::More tests => 4; |
Marc Kupietz | 3e3e326 | 2022-04-12 23:11:45 +0200 | [diff] [blame] | 5 | use Mojo::JSON qw(decode_json encode_json to_json); |
| 6 | |
| 7 | use_ok('IDS::DeReKoVecs::Read'); |
| 8 | |
| 9 | IDS::DeReKoVecs::Read::init_net( |
| 10 | "example-models/wpd19_10000/wpd19_10000.vecs", |
| 11 | "example-models/wpd19_10000/wpd19_10000.net", |
| 12 | 0, 1 |
| 13 | ); |
| 14 | my $word = "Grund"; |
| 15 | my $dedupe = 0; |
| 16 | my $nosp = 0; |
| 17 | my $res; |
| 18 | my $cutoff = 50000; |
| 19 | |
| 20 | subtest '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 | |
| 26 | subtest '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 Kupietz | c82b15f | 2022-07-19 17:36:27 +0200 | [diff] [blame^] | 32 | subtest '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 Kupietz | 3e3e326 | 2022-04-12 23:11:45 +0200 | [diff] [blame] | 40 | done_testing; |