| 1 | # -*- perl -*- | ||
| 2 | # Before `make install' is performed this script should be runnable with | ||
| 3 | # `make test'. After `make install' it should work as `perl 1.t' | ||
| 4 | |||
| 5 | ######################### | ||
| 6 | |||
| 7 | # change 'tests => 1' to 'tests => last_test_to_print'; | ||
| 8 | |||
| 9 | 1 | ▶ | use Test::More tests => 15; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 10 | 1 | ▶ | BEGIN { |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 11 | #01 | ||
| 12 | 1 | ▶ | use_ok('Lingua::Treebank::Const'); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 13 | }; | ||
| 14 | |||
| 15 | ######################### | ||
| 16 | |||
| 17 | # Insert your test code below, the Test::More module is use()ed here so read | ||
| 18 | # its man page ( perldoc Test::More ) for help writing this test script. | ||
| 19 | |||
| 20 | 1 | ▶ | use constant PACK => 'Lingua::Treebank::Const'; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 21 | |||
| 22 | #2 | ||
| 23 | 1 | can_ok(PACK, qw( from_penn_string as_penn_text ) ); | |
| 24 | |||
| 25 | 1 | my $d = PACK->new(); | |
| 26 | #3 | ||
| 27 | 1 | ok( defined $d, "new() returned something" ); | |
| 28 | #4 | ||
| 29 | 1 | isa_ok($d, PACK, "and it's a " . PACK); | |
| 30 | |||
| 31 | 1 | my $ex1 = <<EOEX1; | |
| 32 | (S | ||
| 33 | (NP | ||
| 34 | (NNP Joe) | ||
| 35 | ) | ||
| 36 | (VP | ||
| 37 | (VB likes) | ||
| 38 | (NP | ||
| 39 | (NNP Bach) | ||
| 40 | ) | ||
| 41 | ) | ||
| 42 | (. .) | ||
| 43 | ) | ||
| 44 | EOEX1 | ||
| 45 | |||
| 46 | 1 | $d->from_penn_string($ex1); | |
| 47 | |||
| 48 | #5 | ||
| 49 | 1 | ok(1, "passed from_penn_string"); | |
| 50 | |||
| 51 | 1 | my $ex2 = <<EOEX2; | |
| 52 | (S (NP (NNP Joe) ) (VP (VB likes) (NP (NNP Bach) ) ) (. .)) | ||
| 53 | EOEX2 | ||
| 54 | |||
| 55 | 1 | my $d2 = PACK->new(); | |
| 56 | |||
| 57 | #6 | ||
| 58 | 1 | isa_ok($d2, PACK); | |
| 59 | |||
| 60 | 1 | $d2->from_penn_string($ex2); | |
| 61 | |||
| 62 | #7 | ||
| 63 | 1 | ok(1, "passed second from_penn_string"); | |
| 64 | |||
| 65 | #8 | ||
| 66 | 1 | ok( ( $d->equiv_to($d2) ) , 'trees are equivalent'); | |
| 67 | |||
| 68 | # Put in TODO tests for malformed data here | ||
| 69 | |||
| 70 | |||
| 71 | # put in handling cases for writing data out as well | ||
| 72 | # my $ex1prime = $d->as_text(); | ||
| 73 | #9 | ||
| 74 | 1 | is ( $d->as_penn_text(), $d2->as_penn_text(), 'tree texts match'); | |
| 75 | |||
| 76 | # diag ( $d->as_penn_text() ); | ||
| 77 | |||
| 78 | # parens | ||
| 79 | 1 | my $ex3 = <<EOEX3; | |
| 80 | (S (NP (-LRB- ()(NNP Joe)(-RRB- )))(VP (VB likes)(NP (NNP Bach)))(. .)) | ||
| 81 | EOEX3 | ||
| 82 | 1 | my $d3 = PACK->new(); | |
| 83 | 1 | $d3->from_penn_string($ex3); | |
| 84 | #10 | ||
| 85 | 1 | isa_ok($d3, PACK); | |
| 86 | #11 | ||
| 87 | 1 | is ($d3->as_penn_text(0, '', '', '') . "\n", $ex3, 'tree text w/ parens matches'); | |
| 88 | |||
| 89 | # UNBALANCED parens | ||
| 90 | 1 | my $ex4 = <<EOEX4; | |
| 91 | (S (NP (-LRB- ()(NNP Joe))(VP (VB likes)(NP (NNP Bach)))(. .)) | ||
| 92 | EOEX4 | ||
| 93 | 1 | my $d4 = PACK->new(); | |
| 94 | 1 | $d4->from_penn_string($ex4); | |
| 95 | #12 | ||
| 96 | 1 | isa_ok($d4, PACK); | |
| 97 | #13 | ||
| 98 | 1 | is ($d4->as_penn_text(0, '', '', '') . "\n", $ex4, 'tree text w/ unbalanced parens matches'); | |
| 99 | |||
| 100 | |||
| 101 | # UNBALANCED parens -- not first item | ||
| 102 | 1 | my $ex5 = <<EOEX5; | |
| 103 | (S (NP (PRP I)(-LRB- ()(NNP Joe))(VP (VB likes)(NP (NNP Bach)))(. .)) | ||
| 104 | EOEX5 | ||
| 105 | 1 | my $d5 = PACK->new(); | |
| 106 | 1 | $d5->from_penn_string($ex5); | |
| 107 | # 14 | ||
| 108 | 1 | isa_ok($d5, PACK); | |
| 109 | #15 | ||
| 110 | 1 | is ($d5->as_penn_text(0, '', '', '') . "\n", $ex5, 'tree text w/ unbalanced parens matches'); | |