This repository has been archived by the owner on Dec 16, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 176
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Handles mismatched token annotation better (#24)
* Handles mismatched token annotation better * add some tests * Fixed documentation * fix tests Co-authored-by: epwalsh <[email protected]>
- Loading branch information
Showing
2 changed files
with
34 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import pytest | ||
|
||
from allennlp_models.rc.common.reader_utils import char_span_to_token_span | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"token_offsets, character_span, expected_result", | ||
[ | ||
([(0, 3), (4, 4), (5, 8)], (5, 8), ((2, 2), False)), | ||
([(0, 3), (4, 4), (5, 8)], (4, 8), ((1, 2), False)), | ||
([(0, 3), (4, 4), (5, 8)], (0, 8), ((0, 2), False)), | ||
([(0, 3), (4, 4), (5, 8)], (1, 8), ((0, 2), True)), | ||
([(0, 3), (4, 4), (5, 8)], (7, 8), ((2, 2), True)), | ||
], | ||
) | ||
def test_char_span_to_token_span(token_offsets, character_span, expected_result): | ||
assert char_span_to_token_span(token_offsets, character_span) == expected_result |