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

Function subjunctive

pattern/text/en/modality.py:161–200  ·  view source on GitHub ↗

The subjunctive mood is a classical mood used to express a wish, judgment or opinion. It is marked by the verb wish/were, or infinitive form of a verb preceded by an "it is"-statement: "It is recommended that he bring his own computer."

(sentence, classical=True, **kwargs)

Source from the content-addressed store, hash-verified

159 subjunctive1.append(w.rstrip("e")+"ed")
160
161def subjunctive(sentence, classical=True, **kwargs):
162 """ The subjunctive mood is a classical mood used to express a wish, judgment or opinion.
163 It is marked by the verb wish/were, or infinitive form of a verb
164 preceded by an "it is"-statement:
165 "It is recommended that he bring his own computer."
166 """
167 S = sentence
168 if not (hasattr(S, "words") and hasattr(S, "parse_token")):
169 raise TypeError, "%s object is not a parsed Sentence" % repr(S.__class__.__name__)
170 if question(S):
171 return False
172 for i, w in enumerate(S):
173 b = False
174 if w.type.startswith("VB"):
175 if s(w).startswith("wish"):
176 # "I wish I knew."
177 return True
178 if s(w) == "were" and i > 0 and (s(S[i-1]) in ("i", "it", "he", "she") or S[i-1].type == "NN"):
179 # "It is as though she were here." => counterfactual.
180 return True
181 if s(w) in subjunctive1:
182 # "I propose that you be on time."
183 b = True
184 elif s(w) == "is" and 0 < i < len(S)-1 and s(S[i-1]) == "it" \
185 and s(S[i+1]) in subjunctive2:
186 # "It is important that you be there." => but you aren't (yet).
187 b = True
188 elif s(w) == "is" and 0 < i < len(S)-3 and s(S[i-1]) == "it" \
189 and s(S[i+2]) in ("good", "bad") and s(S[i+3]) == "idea":
190 # "It is a good idea that you be there."
191 b = True
192 if b:
193 # With classical=False, "It is important that you are there." passes.
194 # This is actually an informal error: it states a fact, not a wish.
195 v = find(lambda w: w.type.startswith("VB"), S[i+1:])
196 if v and classical is True and v and v.type == "VB":
197 return True
198 if v and classical is False:
199 return True
200 return False
201
202#from __init__ import parse, Sentence
203#

Callers 2

test_subjunctiveMethod · 0.90
moodFunction · 0.85

Calls 4

questionFunction · 0.85
sFunction · 0.85
lenFunction · 0.85
findFunction · 0.70

Tested by 1

test_subjunctiveMethod · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…