PonteIneptique / collatinus-python

Collatinus Python Lemmatizer
GNU General Public License v3.0
8 stars 1 forks source link

Add a morphological analysis converter to Features #20

Open PonteIneptique opened 6 years ago

PonteIneptique commented 6 years ago

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