File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed
tests/utils/data_model_utils Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -141,3 +141,25 @@ def test_get_horz_ngrams(doc_setup):
141
141
"orange" ,
142
142
"." ,
143
143
]
144
+
145
+
146
+ def test_get_ngrams_that_match_in_string (doc_setup ):
147
+ """Test if ngrams can be obtained even if they match mention's span in string."""
148
+ doc = doc_setup
149
+ sentence : Sentence = doc .sentences [0 ]
150
+ # Assert this sentence is visual.
151
+ assert sentence .is_visual ()
152
+ # Assert this sentence is not tabular.
153
+ assert not sentence .is_tabular ()
154
+
155
+ # Create 1-gram span mentions
156
+ space = MentionNgrams (n_min = 1 , n_max = 1 )
157
+ mentions = [tc for tc in space .apply (doc )]
158
+ assert len (mentions ) == len ([word for sent in doc .sentences for word in sent .words ])
159
+
160
+ # Pick "is" from the apple sentence that matches "is" in the orange sentence.
161
+ mention = mentions [1 ]
162
+ assert mention .get_span () == "is"
163
+ # Check if the "is" in the orange sentence can be obtained.
164
+ ngrams = list (get_horz_ngrams (mention , from_sentence = False ))
165
+ assert "is" in ngrams
You can’t perform that action at this time.
0 commit comments