MCPcopy Index your code
hub / github.com/clips/pattern / tenses

Method tenses

pattern/text/__init__.py:1425–1452  ·  view source on GitHub ↗

Returns a list of possible tenses for the given inflected verb.

(self, verb, parse=True)

Source from the content-addressed store, hash-verified

1423 return v[i]
1424
1425 def tenses(self, verb, parse=True):
1426 """ Returns a list of possible tenses for the given inflected verb.
1427 """
1428 verb = verb.lower()
1429 a = set()
1430 b = self.lemma(verb, parse=parse)
1431 v = []
1432 if b in self:
1433 v = self[b]
1434 elif parse is True: # rule-based
1435 v = self.find_lexeme(b)
1436 # For each tense in the verb lexeme that matches the given tense,
1437 # 1) retrieve the tense tuple,
1438 # 2) retrieve the tense tuples for which that tense is a default.
1439 for i, tense in enumerate(v):
1440 if tense == verb:
1441 for id, index in self._format.items():
1442 if i == index:
1443 a.add(id)
1444 for id1, id2 in self._default.items():
1445 if id2 in a:
1446 a.add(id1)
1447 for id1, id2 in self._default.items():
1448 if id2 in a:
1449 a.add(id1)
1450 a = (TENSES[id][:-2] for id in a)
1451 a = Tenses(sorted(a))
1452 return a
1453
1454 def find_lemma(self, verb):
1455 # Must be overridden in a subclass.

Callers 6

test_tensesMethod · 0.45
test_tensesMethod · 0.45
test_tensesMethod · 0.45
test_tensesMethod · 0.45
test_tensesMethod · 0.45
test_tensesMethod · 0.45

Calls 5

lemmaMethod · 0.95
find_lexemeMethod · 0.95
TensesClass · 0.85
itemsMethod · 0.45
addMethod · 0.45

Tested by 6

test_tensesMethod · 0.36
test_tensesMethod · 0.36
test_tensesMethod · 0.36
test_tensesMethod · 0.36
test_tensesMethod · 0.36
test_tensesMethod · 0.36