5

I'm working on a static analysis tool for the documentation in the Python programming language (PEP257). For this, I need to check if the first word in a documentation string is a verb in the imperative mood.

Our current check is that the word should not end with an "s", except if it ends with a double "s". So "Pass" is okay, but "Passes" is not. The problem with the current test is that it has false negatives, e.g., "Focus".

Is there a way to check for this? Assuming that the word is already a verb is fine. If the check can sometimes fail, I rather it failed on passing the test (concluding that a verb is in the imperative mood) than vice-versa.

7
  • 4
    You cannot check this automatically. It must be done manually. There's no non-manual way that would check an imperative, but not a past tense, gerund, present tense (outside the third singular), subjunctive, or infinitive. That's why all the big text corpora are manually tagged. – Janus Bahs Jacquet Dec 20 '14 at 17:22
  • Why not look at the exclamation mark at the end? – Affable Geek Dec 20 '14 at 17:22
  • 2
    @Affable Geek: Remember that commands don't have to end in exclamation points. – Peter Shor Dec 20 '14 at 17:26
  • And imperatives express not only direct commands, but also prohibitions and requests. In many circumstances, using the imperative mood may sound blunt or even rude, so it is often used with care. Examples: "Paul, do your homework now". "Do not clean soot off the window." "Turn your phones off, please." "Run down to the shop, will you, Peter." An imperative is used to tell someone to do something [/refrain from doing something] without argument. [Wikipedia; augmented] – Edwin Ashworth Dec 20 '14 at 17:32
  • 4
    There is no "imperative mood" in English. There are imperative uses of infinitive verb forms (Be kind, Get out of here, Look at that), but they can only be distinguished in context, because there's nothing grammatical about them that distinguishes them from other infinitives. So you'd have to do a full pragmatic parse and then choose the ones you thought were true imperatives. This would leave out, for instance, constructions like Buy ten and save!, which can be shown not to be imperative constructions. – John Lawler Dec 20 '14 at 18:19
4

To determine if a verb is a command just from its spelling seems problematic. Start with the basic rule: "In English, the imperative is formed using the bare infinitive form of the verb. This is usually also the same as the second-person present indicative form...." (from Wikipedia) So it seems what you're really trying to check is whether the verb that starts the sentence is in the present tense, second person. Since you're only concerned with false negatives, then you need to spot verbs ending in "s" that should be exceptions to your first rule (can't end in "s"). Someone suggested you remove the "s" and analyze what you get. Instead, I would recommend that you add "es" and see if you still have a verb. If so, it has a high probability that the original is something you want. So if you encounter "guess", then check "guesses" (still a verb). If you encounter "guesses", check "guesseses" (not a verb).

1
  • Just adding 'es' is a terrible idea; Activate, Add, Copy, Extract, Get, Move all fail that test. – TamaMcGlinn yesterday
1

I don't know whether your task is feasible, but it would help to make the test look at whether the verb ends with an inflection (rather than whether it ends with "s"). One property of English inflections is that when you remove them, you get a word that is the base form. So your example "focus" would clearly not pass this test, since "focu" is not a verb.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.