mirror of
https://github.com/explosion/spaCy.git
synced 2024-12-27 18:36:36 +03:00
adc9745718
* Restructure tag maps for MorphAnalysis changes Prepare tag maps for upcoming MorphAnalysis changes that allow arbritrary features. * Use default tag map rather than duplicating for ca / uk / vi * Import tag map into defaults for ga * Modify tag maps so all morphological fields and features are strings * Move features from `"Other"` to the top level * Rewrite tuples as strings separated by `","` * Rewrite morph symbols for fr lemmatizer as strings * Export MorphAnalysis under spacy.tokens * Modify morphology to support arbitrary features Modify `Morphology` and `MorphAnalysis` so that arbitrary features are supported. * Modify `MorphAnalysisC` so that it can support arbitrary features and multiple values per field. `MorphAnalysisC` is redesigned to contain: * key: hash of UD FEATS string of morphological features * array of `MorphFeatureC` structs that each contain a hash of `Field` and `Field=Value` for a given morphological feature, which makes it possible to: * find features by field * represent multiple values for a given field * `get_field()` is renamed to `get_by_field()` and is no longer `nogil`. Instead a new helper function `get_n_by_field()` is `nogil` and returns `n` features by field. * `MorphAnalysis.get()` returns all possible values for a field as a list of individual features such as `["Tense=Pres", "Tense=Past"]`. * `MorphAnalysis`'s `str()` and `repr()` are the UD FEATS string. * `Morphology.feats_to_dict()` converts a UD FEATS string to a dict where: * Each field has one entry in the dict * Multiple values remain separated by a separator in the value string * `Token.morph_` returns the UD FEATS string and you can set `Token.morph_` with a UD FEATS string or with a tag map dict. * Modify get_by_field to use np.ndarray Modify `get_by_field()` to use np.ndarray. Remove `max_results` from `get_n_by_field()` and always iterate over all the fields. * Rewrite without MorphFeatureC * Add shortcut for existing feats strings as keys Add shortcut for existing feats strings as keys in `Morphology.add()`. * Check for '_' as empty analysis when adding morphs * Extend helper converters in Morphology Add and extend helper converters that convert and normalize between: * UD FEATS strings (`"Case=dat,gen|Number=sing"`) * per-field dict of feats (`{"Case": "dat,gen", "Number": "sing"}`) * list of individual features (`["Case=dat", "Case=gen", "Number=sing"]`) All converters sort fields and values where applicable.
286 lines
7.3 KiB
Python
286 lines
7.3 KiB
Python
from ...symbols import LEMMA, PRON_LEMMA
|
|
|
|
|
|
# Used the table of pronouns at https://sv.wiktionary.org/wiki/deras
|
|
MORPH_RULES = {
|
|
"PRP": {
|
|
"jag": {
|
|
LEMMA: PRON_LEMMA,
|
|
"PronType": "Prs",
|
|
"Person": "One",
|
|
"Number": "Sing",
|
|
"Case": "Nom",
|
|
},
|
|
"mig": {
|
|
LEMMA: PRON_LEMMA,
|
|
"PronType": "Prs",
|
|
"Person": "One",
|
|
"Number": "Sing",
|
|
"Case": "Acc",
|
|
},
|
|
"mej": {
|
|
LEMMA: PRON_LEMMA,
|
|
"PronType": "Prs",
|
|
"Person": "One",
|
|
"Number": "Sing",
|
|
"Case": "Acc",
|
|
},
|
|
"du": {
|
|
LEMMA: PRON_LEMMA,
|
|
"PronType": "Prs",
|
|
"Person": "Two",
|
|
"Number": "Sing",
|
|
"Case": "Nom",
|
|
},
|
|
"han": {
|
|
LEMMA: PRON_LEMMA,
|
|
"PronType": "Prs",
|
|
"Person": "Three",
|
|
"Number": "Sing",
|
|
"Gender": "Masc",
|
|
"Case": "Nom",
|
|
},
|
|
"honom": {
|
|
LEMMA: PRON_LEMMA,
|
|
"PronType": "Prs",
|
|
"Person": "Three",
|
|
"Number": "Sing",
|
|
"Gender": "Masc",
|
|
"Case": "Acc",
|
|
},
|
|
"hon": {
|
|
LEMMA: PRON_LEMMA,
|
|
"PronType": "Prs",
|
|
"Person": "Three",
|
|
"Number": "Sing",
|
|
"Gender": "Fem",
|
|
"Case": "Nom",
|
|
},
|
|
"henne": {
|
|
LEMMA: PRON_LEMMA,
|
|
"PronType": "Prs",
|
|
"Person": "Three",
|
|
"Number": "Sing",
|
|
"Gender": "Fem",
|
|
"Case": "Acc",
|
|
},
|
|
"det": {
|
|
LEMMA: PRON_LEMMA,
|
|
"PronType": "Prs",
|
|
"Person": "Three",
|
|
"Number": "Sing",
|
|
"Gender": "Neut",
|
|
},
|
|
"vi": {
|
|
LEMMA: PRON_LEMMA,
|
|
"PronType": "Prs",
|
|
"Person": "One",
|
|
"Number": "Plur",
|
|
"Case": "Nom",
|
|
},
|
|
"oss": {
|
|
LEMMA: PRON_LEMMA,
|
|
"PronType": "Prs",
|
|
"Person": "One",
|
|
"Number": "Plur",
|
|
"Case": "Acc",
|
|
},
|
|
"ni": {
|
|
LEMMA: PRON_LEMMA,
|
|
"PronType": "Prs",
|
|
"Person": "Two",
|
|
"Number": "Plur",
|
|
"Case": "Nom",
|
|
},
|
|
"er": {LEMMA: PRON_LEMMA, "PronType": "Prs", "Person": "Two", "Number": "Plur"},
|
|
"de": {
|
|
LEMMA: PRON_LEMMA,
|
|
"PronType": "Prs",
|
|
"Person": "Three",
|
|
"Number": "Plur",
|
|
"Case": "Nom",
|
|
},
|
|
"dom": {
|
|
LEMMA: PRON_LEMMA,
|
|
"PronType": "Prs",
|
|
"Person": "Three",
|
|
"Number": "Plur",
|
|
"Case": "Nom,Acc",
|
|
},
|
|
"dem": {
|
|
LEMMA: PRON_LEMMA,
|
|
"PronType": "Prs",
|
|
"Person": "Three",
|
|
"Number": "Plur",
|
|
"Case": "Acc",
|
|
},
|
|
"min": {
|
|
LEMMA: PRON_LEMMA,
|
|
"PronType": "Prs",
|
|
"Person": "One",
|
|
"Number": "Sing",
|
|
"Poss": "Yes",
|
|
"Reflex": "Yes",
|
|
},
|
|
"mitt": {
|
|
LEMMA: PRON_LEMMA,
|
|
"PronType": "Prs",
|
|
"Person": "One",
|
|
"Number": "Sing",
|
|
"Poss": "Yes",
|
|
"Reflex": "Yes",
|
|
},
|
|
"mina": {
|
|
LEMMA: PRON_LEMMA,
|
|
"PronType": "Prs",
|
|
"Person": "One",
|
|
"Number": "Plur",
|
|
"Poss": "Yes",
|
|
"Reflex": "Yes",
|
|
},
|
|
"din": {
|
|
LEMMA: PRON_LEMMA,
|
|
"PronType": "Prs",
|
|
"Person": "Two",
|
|
"Number": "Sing",
|
|
"Poss": "Yes",
|
|
"Reflex": "Yes",
|
|
},
|
|
"ditt": {
|
|
LEMMA: PRON_LEMMA,
|
|
"PronType": "Prs",
|
|
"Person": "Two",
|
|
"Number": "Sing",
|
|
"Poss": "Yes",
|
|
"Reflex": "Yes",
|
|
},
|
|
"dina": {
|
|
LEMMA: PRON_LEMMA,
|
|
"PronType": "Prs",
|
|
"Person": "Two",
|
|
"Number": "Plur",
|
|
"Poss": "Yes",
|
|
"Reflex": "Yes",
|
|
},
|
|
"hans": {
|
|
LEMMA: PRON_LEMMA,
|
|
"PronType": "Prs",
|
|
"Person": "Two",
|
|
"Number": "Sing,Plur",
|
|
"Gender": "Masc",
|
|
"Poss": "Yes",
|
|
"Reflex": "Yes",
|
|
},
|
|
"hennes": {
|
|
LEMMA: PRON_LEMMA,
|
|
"PronType": "Prs",
|
|
"Person": "Two",
|
|
"Number": "Sing,Plur",
|
|
"Gender": "Fem",
|
|
"Poss": "Yes",
|
|
"Reflex": "Yes",
|
|
},
|
|
"dess": {
|
|
LEMMA: PRON_LEMMA,
|
|
"PronType": "Prs",
|
|
"Person": "Two",
|
|
"Number": "Sing,Plur",
|
|
"Poss": "Yes",
|
|
"Reflex": "Yes",
|
|
},
|
|
"vår": {
|
|
LEMMA: PRON_LEMMA,
|
|
"PronType": "Prs",
|
|
"Person": "One",
|
|
"Number": "Plur",
|
|
"Poss": "Yes",
|
|
"Reflex": "Yes",
|
|
},
|
|
"våran": {
|
|
LEMMA: PRON_LEMMA,
|
|
"PronType": "Prs",
|
|
"Person": "One",
|
|
"Number": "Plur",
|
|
"Poss": "Yes",
|
|
"Reflex": "Yes",
|
|
},
|
|
"vårt": {
|
|
LEMMA: PRON_LEMMA,
|
|
"PronType": "Prs",
|
|
"Person": "One",
|
|
"Number": "Plur",
|
|
"Poss": "Yes",
|
|
"Reflex": "Yes",
|
|
},
|
|
"vårat": {
|
|
LEMMA: PRON_LEMMA,
|
|
"PronType": "Prs",
|
|
"Person": "One",
|
|
"Number": "Plur",
|
|
"Poss": "Yes",
|
|
"Reflex": "Yes",
|
|
},
|
|
"våra": {
|
|
LEMMA: PRON_LEMMA,
|
|
"PronType": "Prs",
|
|
"Person": "One",
|
|
"Number": "Plur",
|
|
"Poss": "Yes",
|
|
"Reflex": "Yes",
|
|
},
|
|
"eran": {
|
|
LEMMA: PRON_LEMMA,
|
|
"PronType": "Prs",
|
|
"Person": "Two",
|
|
"Number": "Plur",
|
|
"Poss": "Yes",
|
|
"Reflex": "Yes",
|
|
},
|
|
"ert": {
|
|
LEMMA: PRON_LEMMA,
|
|
"PronType": "Prs",
|
|
"Person": "Two",
|
|
"Number": "Plur",
|
|
"Poss": "Yes",
|
|
"Reflex": "Yes",
|
|
},
|
|
"erat": {
|
|
LEMMA: PRON_LEMMA,
|
|
"PronType": "Prs",
|
|
"Person": "Two",
|
|
"Number": "Plur",
|
|
"Poss": "Yes",
|
|
"Reflex": "Yes",
|
|
},
|
|
"era": {
|
|
LEMMA: PRON_LEMMA,
|
|
"PronType": "Prs",
|
|
"Person": "Two",
|
|
"Number": "Plur",
|
|
"Poss": "Yes",
|
|
"Reflex": "Yes",
|
|
},
|
|
"deras": {
|
|
LEMMA: PRON_LEMMA,
|
|
"PronType": "Prs",
|
|
"Person": "Three",
|
|
"Number": "Plur",
|
|
"Poss": "Yes",
|
|
"Reflex": "Yes",
|
|
},
|
|
},
|
|
"VBZ": {
|
|
"är": {
|
|
"VerbForm": "Fin",
|
|
"Person": "One,Two,Three",
|
|
"Tense": "Pres",
|
|
"Mood": "Ind",
|
|
}
|
|
},
|
|
"VBP": {"är": {"VerbForm": "Fin", "Tense": "Pres", "Mood": "Ind"}},
|
|
"VBD": {
|
|
"var": {"VerbForm": "Fin", "Tense": "Past", "Number": "Sing"},
|
|
"vart": {"VerbForm": "Fin", "Tense": "Past", "Number": "Plur"},
|
|
},
|
|
}
|