Skip to content

Commit 05d87ea

Browse files
authored
fix Morpheme.from_segments
1 parent fa11cde commit 05d87ea

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/linse/typedsequence.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,10 @@ def from_string(cls, s, separator=None):
151151

152152
@classmethod
153153
def from_segments(cls, s, separator=None):
154-
return s.split(separator) if separator else s.split()
154+
if separator.strip(): # if the separator is something else than whitespaces in any form
155+
separator = "\s*" + re.escape(separator) + "\s*"
156+
segments = re.split(separator, s) if separator else s.split()
157+
return cls(segments)
155158

156159
def to_text(self):
157160
return ''.join(self)

0 commit comments

Comments
 (0)