Skip to content

Character Combinations for Segment Grouper #30

@LinguList

Description

@LinguList

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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions