You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
20 lines
590 B
Python
20 lines
590 B
Python
5 years ago
|
from extracted_text import *
|
||
|
|
||
|
def test_text():
|
||
|
test1 = ExtractedText([
|
||
|
ExtractedTextSegment('s0', 'foo'),
|
||
|
ExtractedTextSegment('s1', 'bar'),
|
||
|
ExtractedTextSegment('s2', 'bazinga')
|
||
|
], ' ')
|
||
|
|
||
|
|
||
|
assert test1.text == 'foo bar bazinga'
|
||
|
assert test1.segment_id_for_pos(0) == 's0'
|
||
|
assert test1.segment_id_for_pos(3) is None
|
||
|
assert test1.segment_id_for_pos(10) == 's2'
|
||
|
|
||
|
# TODO handle grapheme cluster positions?
|
||
|
|
||
|
# ExtractedTextSegment('foo', unicodedata.normalize('NFD', 'Schlyñ'))
|
||
|
ExtractedTextSegment('foo', unicodedata.normalize('NFC', 'Schlyñ'))
|