Skip to content

Add a morphological analysis converter to Features #20

Description

@PonteIneptique

Thanks to Alpheios funding, I was able to spend some time on this. I am thinking we should have a convert function that would allow to export to these Features or to Perseus Features :

class Converter:
    FEATURES = {
        "singulier": ("Number", "Sing"),
        "pluriel": ("Number", "Plur"),

        "passif": ("Voice", "Pass"),
        "actif": ("Voice", "Act"),

        "positif": ("Degree", "Pos"),
        "superlatif": ("Degree", "Sup"),


        "impératif": ("Mood", "Imp"),
        "indicatif": ("Mood", "Ind"),
        "subjonctif": ("Mood", "Sub"),

        "féminin": ("Gender", "Fem"),
        "neutre": ("Gender", "Neut"),
        "masculin": ("Gender", "Masc"),

        "accusatif": ("Case", "Acc"),
        "nominatif": ("Case", "Nom"),
        "ablatif": ("Case", "Abl"),
        "vocatif": ("Case", "Voc"),
        "datif": ("Case", "Dat"),
        "génitif": ("Case", "Gen"),

        "imparfait": [("Tense", "Past")],
        "parfait": [("Aspect", "Perf"), ("Tense", "Past")],
        "présent": ("Tense", "Pres"),
        "PQP": [("Aspect", "Imp"), ("Tense", "Past")],
        "futur": ("Tense", "Fut"),
        "futur_antérieur": ("Tense", "Fut"),

        "participe": ("VerbForm", "Part"),
        "infinitif": ("VerbForm", "Inf"),

        "1ère": ("Person", "1"),
        "2ème": ("Person", "2"),
        "3ème": ("Person", "3"),
}
    def morph(self, value):
        _morph = {}
        if value == "-":
            return None
        value = value.replace("futur antérieur", "futur_antérieur")
        features = value.split(" ")
        for feature in features:
            corresp = self.FEATURES.get(feature, ("Unknown", feature))
            if not isinstance(corresp, list):
                corresp = [corresp]
            for key, val in corresp:
                _morph[key] = val

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions