Skip to content

Commit

Permalink
Added fix for Text validation error (Sentence.TEXTDELIMITER issue) #34
Browse files Browse the repository at this point in the history
  • Loading branch information
proycon committed Oct 10, 2017
1 parent 9784938 commit 817858d
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion pynlpl/formats/folia.py
Original file line number Diff line number Diff line change
Expand Up @@ -5810,8 +5810,14 @@ def insertwordleft(self, newword, nextword, **kwargs):
def gettextdelimiter(self, retaintokenisation=False):
#no text delimiter of itself, recurse into children to inherit delimiter
for child in reversed(self):
if isinstance(child, Linebreak) or isinstance(child, Whitespace):
if isinstance(child, (Linebreak, Whitespace)):
return "" #if a sentence ends in a linebreak, we don't want any delimiter
elif isinstance(child, Word) and not child.space:
return "" #if a sentence ends in a word with space=no, then we don't delimit either
elif isinstance(child, AbstractStructureElement):
#recurse? if the child is hidden in another element (part for instance?)
return child.gettextdelimiter(retaintokenisation) #if a sentence ends in a word with space=no, then we don't delimit either
#TODO: what about corrections?
else:
break
return self.TEXTDELIMITER
Expand Down

0 comments on commit 817858d

Please sign in to comment.