-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Description
I just experimented with a very simple method to allow for character combinations with SEgmentGrouper. The idea is that we use brackets to combine segments, so we can express what we would express in several lines in one. Later, we use a rule-parser, to make several lines out of these statements. This can be handy for orthography profile creation, and I have tested it in the profiler for JavaScript.
The code in Python is very simple:
def parse_rule(rule, delimiter=" "):
# first a grouping after brackets
groups = [[""]]
in_bracket = False
for char in rule:
if char == "[":
if not groups[-1]:
groups += [""]
in_bracket = True
elif char == "]":
in_bracket = False
else:
if in_bracket:
if char == delimiter:
groups[-1] += [""]
else:
groups[-1][-1] += char
else:
if char == delimiter:
groups += [[""]]
else:
groups[-1][-1] += char
return groups
It can be extended by adding a character for diacritics, that is later replaced.
Metadata
Metadata
Assignees
Labels
No labels