Skip to content

Commit 702c0b2

Browse files
committed
added two more tests of constructing a document with text validation
1 parent a14339b commit 702c0b2

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

pynlpl/tests/folia.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3642,6 +3642,45 @@ def test013e_correction(self):
36423642
</FoLiA>""".format(version=folia.FOLIAVERSION, generator='pynlpl.formats.folia-v' + folia.LIBVERSION)
36433643
doc = folia.Document(string=xml, textvalidation=True)
36443644

3645+
def test013f_correction(self):
3646+
"""Validation - Text Validation with redundancy on construction"""
3647+
#NOTE: Current library implementation won't be able to validate nested layers and will just skip those!
3648+
doc = folia.Document(id='example',textvalidation=True)
3649+
3650+
text = folia.Text(doc, id=doc.id + '.text.1')
3651+
3652+
text.append(
3653+
folia.Sentence(doc,id=doc.id + '.s.1', text="De site staat online . ", contents=[
3654+
folia.Word(doc,id=doc.id + '.s.1.w.1', text="De"),
3655+
folia.Word(doc,id=doc.id + '.s.1.w.2', text="site"),
3656+
folia.Word(doc,id=doc.id + '.s.1.w.3', text="staat"),
3657+
folia.Word(doc,id=doc.id + '.s.1.w.4', text="online"),
3658+
folia.Word(doc,id=doc.id + '.s.1.w.5', text=".")
3659+
])
3660+
)
3661+
doc.xmlstring() #serialisation forces validation
3662+
3663+
def test013g_correction(self):
3664+
"""Validation - Text Validation with redundancy on partial construction"""
3665+
#NOTE: Current library implementation won't be able to validate nested layers and will just skip those!
3666+
doc = folia.Document(id='example',textvalidation=True)
3667+
3668+
text = folia.Text(doc, id=doc.id + '.text.1')
3669+
3670+
raised = False
3671+
try:
3672+
text.append(
3673+
folia.Sentence(doc,id=doc.id + '.s.1', text="De site staat online . ", contents=[
3674+
folia.Word(doc,id=doc.id + '.s.1.w.1', text="De"),
3675+
folia.Word(doc,id=doc.id + '.s.1.w.2', text="site"),
3676+
folia.Word(doc,id=doc.id + '.s.1.w.3', text="staat"),
3677+
])
3678+
)
3679+
except folia.InconsistentText:
3680+
raised = True
3681+
self.assertTrue(raised)
3682+
3683+
36453684
with io.open(FOLIAPATH + '/test/example.xml', 'r',encoding='utf-8') as foliaexample_f:
36463685
FOLIAEXAMPLE = foliaexample_f.read()
36473686

0 commit comments

Comments
 (0)