The imperative mood is used to give orders, commands, warnings, instructions, or to make requests (if used with "please"). It is marked by the infinitive form of the verb, without "to": "For goodness sake, just stop it!"
(sentence, **kwargs)
| 33 | return [w for w in sentence[i:j or len(sentence)] if verb(w)] |
| 34 | |
| 35 | def imperative(sentence, **kwargs): |
| 36 | """ The imperative mood is used to give orders, commands, warnings, instructions, |
| 37 | or to make requests (if used with "please"). |
| 38 | It is marked by the infinitive form of the verb, without "to": |
| 39 | "For goodness sake, just stop it!" |
| 40 | """ |
| 41 | S = sentence |
| 42 | if not (hasattr(S, "words") and hasattr(S, "parse_token")): |
| 43 | raise TypeError, "%s object is not a parsed Sentence" % repr(S.__class__.__name__) |
| 44 | if question(S): |
| 45 | return False |
| 46 | if S.subjects and s(S.subjects[0]) not in ("you", "yourself"): |
| 47 | # The subject can only identify as "you" (2sg): "Control yourself!". |
| 48 | return False |
| 49 | r = s(S).rstrip(" .!") |
| 50 | for cc in ("if", "assuming", "provided that", "given that"): |
| 51 | # A conjunction can also indicate conditional mood. |
| 52 | if cc+" " in r: |
| 53 | return False |
| 54 | for i, w in enumerate(S): |
| 55 | if verb(w): |
| 56 | if s(w) in ("do", "let") and w == verbs(S)[0]: |
| 57 | # "Do your homework!" |
| 58 | return True |
| 59 | if s(w) in ("do", "let"): |
| 60 | # "Let's not argue." |
| 61 | continue |
| 62 | if s(w) in ("would", "should", "'d", "could", "can", "may", "might"): |
| 63 | # "You should leave." => conditional. |
| 64 | return False |
| 65 | if s(w) in ("will", "shall") and i > 0 and s(S[i-1]) == "you" and not verbs(S,0,i): |
| 66 | # "You will eat your dinner." |
| 67 | continue |
| 68 | if w.type == "VB" and (i == 0 or s(S[i-1]) != "to"): |
| 69 | # "Come here!" |
| 70 | return True |
| 71 | # Break on any other verb form. |
| 72 | return False |
| 73 | return False |
| 74 | |
| 75 | #from __init__ import parse, Sentence |
| 76 | # |
searching dependent graphs…