Returns the tense id for a given (tense, person, number, mood, aspect, negated). Aliases and compound forms (e.g., IMPERFECT) are disambiguated.
(*args, **kwargs)
| 1258 | # tense(tense=(PRESENT, 3, SINGULAR)) |
| 1259 | # tense(tense=PRESENT, person=3, number=SINGULAR, mood=INDICATIVE, aspect=IMPERFECTIVE, negated=False) |
| 1260 | def tense_id(*args, **kwargs): |
| 1261 | """ Returns the tense id for a given (tense, person, number, mood, aspect, negated). |
| 1262 | Aliases and compound forms (e.g., IMPERFECT) are disambiguated. |
| 1263 | """ |
| 1264 | # Unpack tense given as a tuple, e.g., tense((PRESENT, 1, SG)): |
| 1265 | if len(args) == 1 and isinstance(args[0], (list, tuple)): |
| 1266 | if args[0] not in ((PRESENT, PARTICIPLE), (PAST, PARTICIPLE)): |
| 1267 | args = args[0] |
| 1268 | # No parameters defaults to tense=INFINITIVE, tense=PRESENT otherwise. |
| 1269 | if len(args) == 0 and len(kwargs) == 0: |
| 1270 | t = INFINITIVE |
| 1271 | else: |
| 1272 | t = PRESENT |
| 1273 | # Set default values. |
| 1274 | tense = kwargs.get("tense" , args[0] if len(args) > 0 else t) |
| 1275 | person = kwargs.get("person" , args[1] if len(args) > 1 else 3) or None |
| 1276 | number = kwargs.get("number" , args[2] if len(args) > 2 else SINGULAR) |
| 1277 | mood = kwargs.get("mood" , args[3] if len(args) > 3 else INDICATIVE) |
| 1278 | aspect = kwargs.get("aspect" , args[4] if len(args) > 4 else IMPERFECTIVE) |
| 1279 | negated = kwargs.get("negated", args[5] if len(args) > 5 else False) |
| 1280 | # Disambiguate INFINITIVE. |
| 1281 | # Disambiguate PARTICIPLE, IMPERFECT, PRETERITE. |
| 1282 | # These are often considered to be tenses but are in fact tense + aspect. |
| 1283 | if tense == INFINITIVE: |
| 1284 | person = number = mood = aspect = None; negated=False |
| 1285 | if tense in ((PRESENT, PARTICIPLE), PRESENT+PARTICIPLE, PARTICIPLE, GERUND): |
| 1286 | tense, aspect = PRESENT, PROGRESSIVE |
| 1287 | if tense in ((PAST, PARTICIPLE), PAST+PARTICIPLE): |
| 1288 | tense, aspect = PAST, PROGRESSIVE |
| 1289 | if tense == IMPERFECT: |
| 1290 | tense, aspect = PAST, IMPERFECTIVE |
| 1291 | if tense == PRETERITE: |
| 1292 | tense, aspect = PAST, PERFECTIVE |
| 1293 | if aspect in (CONTINUOUS, PARTICIPLE, GERUND): |
| 1294 | aspect = PROGRESSIVE |
| 1295 | if aspect == PROGRESSIVE: |
| 1296 | person = number = None |
| 1297 | # Disambiguate CONDITIONAL. |
| 1298 | # In Spanish, the conditional is regarded as an indicative tense. |
| 1299 | if tense == CONDITIONAL and mood == INDICATIVE: |
| 1300 | tense, mood = PRESENT, CONDITIONAL |
| 1301 | # Disambiguate aliases: "pl" => |
| 1302 | # (PRESENT, None, PLURAL, INDICATIVE, IMPERFECTIVE, False). |
| 1303 | return TENSES_ID.get(tense.lower(), |
| 1304 | TENSES_ID.get((tense, person, number, mood, aspect, negated))) |
| 1305 | |
| 1306 | tense = tense_id |
| 1307 |
no test coverage detected
searching dependent graphs…