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

Method conjugate

pattern/text/__init__.py:1396–1423  ·  view source on GitHub ↗

Inflects the verb and returns the given tense (or None). For example: be - Verbs.conjugate("is", INFINITVE) => be - Verbs.conjugate("be", PRESENT, 1, SINGULAR) => I am - Verbs.conjugate("be", PRESENT, 1, PLURAL) => we are - Verbs.conjugate

(self, verb, *args, **kwargs)

Source from the content-addressed store, hash-verified

1394 return u
1395
1396 def conjugate(self, verb, *args, **kwargs):
1397 """ Inflects the verb and returns the given tense (or None).
1398 For example: be
1399 - Verbs.conjugate("is", INFINITVE) => be
1400 - Verbs.conjugate("be", PRESENT, 1, SINGULAR) => I am
1401 - Verbs.conjugate("be", PRESENT, 1, PLURAL) => we are
1402 - Verbs.conjugate("be", PAST, 3, SINGULAR) => he was
1403 - Verbs.conjugate("be", PAST, aspect=PROGRESSIVE) => been
1404 - Verbs.conjugate("be", PAST, person=1, negated=True) => I wasn't
1405 """
1406 id = tense_id(*args, **kwargs)
1407 # Get the tense index from the format description (or a default).
1408 i1 = self._format.get(id)
1409 i2 = self._format.get(self._default.get(id))
1410 i3 = self._format.get(self._default.get(self._default.get(id)))
1411 b = self.lemma(verb, parse=kwargs.get("parse", True))
1412 v = []
1413 # Get the verb lexeme and return the requested index.
1414 if b in self:
1415 v = self[b]
1416 for i in (i1, i2, i3):
1417 if i is not None and 0 <= i < len(v) and v[i]:
1418 return v[i]
1419 if kwargs.get("parse", True) is True: # rule-based
1420 v = self.find_lexeme(b)
1421 for i in (i1, i2, i3):
1422 if i is not None and 0 <= i < len(v) and v[i]:
1423 return v[i]
1424
1425 def tenses(self, verb, parse=True):
1426 """ Returns a list of possible tenses for the given inflected verb.

Callers 7

test_conjugateMethod · 0.80
test_conjugateMethod · 0.80
test_conjugateMethod · 0.80
test_conjugateMethod · 0.80
test_conjugateMethod · 0.80
test_conjugateMethod · 0.80
test_tensesMethod · 0.80

Calls 5

lemmaMethod · 0.95
find_lexemeMethod · 0.95
tense_idFunction · 0.85
lenFunction · 0.85
getMethod · 0.45

Tested by 7

test_conjugateMethod · 0.64
test_conjugateMethod · 0.64
test_conjugateMethod · 0.64
test_conjugateMethod · 0.64
test_conjugateMethod · 0.64
test_conjugateMethod · 0.64
test_tensesMethod · 0.64