Is it possible to verify if sentence is grammatically correct automatically.

E.g. for sentence

Lemon yellow.

verb (predicate) is missing  

or for sentence

If it will rain, we will not go to the cinema tonight.

future after /if/ is not correct

or for sentence

Jim want to buy new car.

/s/ for Present Simple, 3rd face, singular is missing; /a/ article is missing before a new car.

This I need to construct web-helper for English learners to highlight, at least some, obvious grammatical errors.

  • There are many commercial English proofreaders. For a freely available one, I'd recommend Ginger, which highlights mistakes and gives corrections. There's also this one, which is not bad, but it's done on a volunteer basis, so it's lacking compared to most. – user3898238 Dec 27 '14 at 8:57

The only coherent meaning of grammatical/ungrammatical I know of is 'complying/not complying with the rules of grammar G for language L'. If you accept that point of view, provided you formally specify an explicit, complete, and consistent grammar G of L, you will, by definition, be able to tell whether a certain string of symbols is or is not 'grammatical' in L modulo G (= whether or not it is in the set L that can be formally deduced from G). If you agree to further identify grammatical with correct (= well-behaved modulo the rules of G and, therefore, acceptable as an object of L), then you can also automatically tell whether a sentence is or is not correct relative to G. So far, there is no problem.

The problem is that we have nothing remotely approaching a formally explicit complete grammar of any natural language, even if by natural language we meant just 'the state of the internal language L assumed by speaker S at time t,... (replace "..." with a list of parameters encoding all the factors that may condition the state of speaker S's internal 'grammar' G during a specific speech act). Actually, we do not even have anything remotely approaching an explicit grammar of 'the language of speaker S' tout court, with all such parameters abstracted away for simplicity's or idealisation's sake, i.e., we do not have any explicit grammar of any individual speaker S's idealised 'idiolect', approximately what Chomsky once called 'the language of Jones'), and the bad news is that we are not likely to ever have one of those either.

Needless to say, we are still incomparably further away from having any formally explicit complete grammar of 'English' (or any other language) as people normally understand the terms English, Spanish, etc., i.e., as the would-be homogeneous 'public languages' millions of people across the world 'share' and use to express themselves, which is the way I presume you understand the object 'English' and the word English.

Unfortunately, having the first such grammar of a natural language in that latter sense is not just a question of time and doing much more research; it is simply an impossible enterprise, for reasons clearly explained long ago by Quine in Word and Object and by many others since (Davidson, Chomsky). We will never have an explicit, complete, and consistent grammar of 'English' in that sense because 'English' in that sense is not a scientifically coherent, definable object; it is just a practically convenient fiction, and it is impossible to develop such a grammar for it.

Since, unless you first do exactly that, no automatic verification procedure can possibly be designed and made to work, either, the answer to your question, as I assume you intended it to be interpreted, is: "No, it is not possible to automatically verify whether a sentence (of 'English', or any other natural language in the sense explained) is or not 'grammatically correct'."


I'm afraid no, almost any sequence of words can be a correct sentence in English in a particular context, e.g. sentences like "Buffalo buffalo buffalo...". Your first example is correct, if it is an imperative sentence which means "Make your yellow color more lemon," a painter can say that to his apprentice. Your third example is correct, if it is a newspaper headline which allows the absence of articles, and 'Jim' is plural, for example it is the abbreviated name of an organization. Not to speak about different local or social varieties of English.

On the other hand, it can well be done for the EASL class use for the most standard meanings of such sentences where the grammar is prescriptive. Still, there's too much variety even here, and not only grammar, but also some semantic and context analysis is needed, and that makes it much harder.

  • 2
    Exactly. Probably 90% of the problem is that word type is so fluid. Any word can be quickly made a noun, verb, adjective and (for some dialects) adverb without modification at all. I'd guess a highly synthetic language might be easier to do a grammar check, and harder to do a spell check, whiel analyticals like English are the opposite (going by my experience writing a spell checker for Asturian) – user0721090601 Dec 25 '14 at 17:25
  • 1
    @guifa - Synthetic languages usually have free word order which makes them very difficult to be formalized, especially if mistakes are supposed to be there, in this case it's absolutely impossible to know which word agrees with which, unless you know the correct variant. So I think it's easier to write software that compares the answer with the key than software that can tell you if any sentence is absolutely correct. – Yellow Sky Dec 25 '14 at 18:13

You already have two answers. One says yes, and the other says no. Both give you arguments to support their view. Maybe the problem is with the question.

Your question is, regarding English grammar:

Is it possible to verify if sentence is grammatically correct automatically?

I believe it might be possible, provided you give a definition of what is a grammatically correct sentence in English, i.e. you give an accurate English grammar.

You may notice that I am turning your words around, in a somewhat tautological way. My intent is to question your question.

You can wonder whether something belongs to a set only if you are first careful to define what that set is. Here, your set is defined by "English grammar", which is a bit short.

Is there one prototype "English grammar" in platinum and iridium alloy, as there is (or was) for the meter, to serve as reference to decide whether a sentence is English or not? (BTW, what is a sentence? ... but I will skip that).

The answer is obviously no. But my intent is to tell you that the first problem is not with the science or technology for checking whether a sentence is grammatically correct, but with defining what is a grammatically correct sentence, if it is definable at all.

They assuming that you manage to agree on some definition, with a group of at least two people, you need some formal way of defining a grammatically correct sentence, so that grammaticality is well defined. Many formalizations of natural language have been proposed. One major difficulty is that the subtlety of the language, and the great variety of permissible constructions is such that the formalizations used can reach very high levels of complexity, such as is permitted by Chomsky type 0 grammars.

Unfortunately, at that level of sophistication of linguistic description, you may hit limitations of what mathematics, or any technology or device can do for you. You are in the realm of recursively enumerable formalisms. That may mean that you may have a definition that will allow you to recognize grammatical sentences, but it will be impossible tho ascertain that a sentence is not grammatical.

The conclusion is that defining a procedure to check grammaticality will hit two kinds of limitations:

  • linguistic limitations as grammaticality is an ill-defined concept because a language has necessarily a fuzzy characterization;

  • mathematical limitations because the mathematical procedures required by the more sophisticated definitions of language have intrinsic fundamental limitations that cannot be overcome.

Now, if you are willing to settle for something that works reasonably well most of the time, the answer is yes, it can be done, as suggested by other answers.


Yes, there are many existing services doing exactly what you are asking for.

For instance, the one at reverso.net. I'm not affiliated with them, but I'm using it sometimes when I'm not sure about my wording as English is not my first language. Here's a screenshot:

Reverso speller

As every piece of software, it can be confused by some awkward contexts and phraseologic constructs, but in general it works fine.

As of how to write your own one, most likely, you will need:

  1. some word corpus to parse out individual words
    1. probably, with flexibility to misspelt words — Markov's chains would help you here;
    2. and also flexible to some common errors (like "misspelt" instead of "misspelled");
  2. identify time, person, number, and declensions;
  3. identify their parts of speech (in English, the same word can act in different ways, e.g. "a glass of water" or "to water flowers";
  4. Build all possible — with enough flexibility to "understand" an erroneously-built phrases;
  5. check verb and noun governance in VP, NP, and so on;
  6. wrap it into an user interface.

There are software libraries doing syntax trees available. For instance:


(image produced by the interface that provides online access to the LinGO English Resource Grammar).

Note that LinGO (and most of similar libraries I'm aware of) are not tolerable to errors. For example, LinGO fails to process "Jim want to buy new car" , but it works well for a properly-built one.

Summarizing all above, you are taking a very large task. Even for a single dialect of a single language (e.g., American English), it would require thousands of man-hours of work. Nevertheless, if you're still desperate to write it, I wish you the best luck.

  • If you enter the second example of the OP there, 'If it will rain, we will not go to the cinema tonight,' it says it is correct. – Yellow Sky Dec 26 '14 at 0:57
  • Even 'Bridge big built workers' is correct there. – Yellow Sky Dec 26 '14 at 1:03
  • @YellowSky Ha, yes, funny to see how it parsed it; it's an imperative sentence, ordering someone to "bridge" (verb) some workers who are "big" and "built" :) – bytebuster Dec 26 '14 at 2:31
  • Rather than build from scratch, I think a better route is to collect patterns from available grammar checkers and build one that way. – user3898238 Dec 27 '14 at 9:00

Let me try to add another yes/no answer from a slightly different perspective.

  1. No, you cannot identify the 'grammatical' correctness of any given sentence using the computational methods of today. Even if we leave aside the fuzzy boundaries of what constitutes a grammatical sentence and even if we ignore the fact that inter-rater agreement with human raters is rather low. Any algorithm available today will misidentify or miss far too many issues that would be immediately obvious to a trained native speaker or native-like editor. The key issue is that a human reader also understands the meaning and can gather the intentions of the writer. They also do not operate with a formal notion of grammar but a rather more holistic approach that will take into account genre, personal style, quotation, etc.

  2. Yes, for relatively straightforward texts, it is possible to identify a relatively small subtext of common grammatical issues with some level of reliability. The most common of these include verbal agreement (boys walks), disambiguation of some homonyms (they're vs. there), and common stylistic preferences (overuse of passive). All of these can be very helpful to many struggling writers as well as catch results of copy and paste errors. However, you cannot really speak about 'identifying correctness' in a general sense. Some of the tools available are MS Word grammar checker, After the Deadline, Reverso and they may even offer an API but constructing a usable algorithm like that from scratch would be very difficult (as in: if you have to ask the question, it's probably too difficult for you).

  • For high level documents that require human proofreaders, what some do is gather new data from these annotations and learn new correction patterns. Some systems also take into account genre as well. – user3898238 Dec 27 '14 at 16:25

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.