How to check whether a sentence is correct (simple grammar check in Python)?

There are various Web Services providing automated proofreading and grammar checking. Some have a Python library to simplify querying. As far as I can tell, most of those tools (certainly After the Deadline and LanguageTool) are rule based. The checked text is compared with a large set of rules describing common errors. If a rule … Read more

English grammar for parsing in NLTK

You can take a look at pyStatParser, a simple python statistical parser that returns NLTK parse Trees. It comes with public treebanks and it generates the grammar model only the first time you instantiate a Parser object (in about 8 seconds). It uses a CKY algorithm and it parses average length sentences (like the one … Read more

Why is 019 not a JavaScript syntax error? Or why is 019 > 020

From what I could find, it seems that some implementations of JavaScript just don’t follow the spec on that point. From the MDN site: Note that decimal literals can start with a zero (0) followed by another decimal digit, but If the next digit after the leading 0 is smaller than 8, the number gets … Read more

How to identify whether a grammar is LL(1), LR(0) or SLR(1)?

To check if a grammar is LL(1), one option is to construct the LL(1) parsing table and check for any conflicts. These conflicts can be FIRST/FIRST conflicts, where two different productions would have to be predicted for a nonterminal/terminal pair. FIRST/FOLLOW conflicts, where two different productions are predicted, one representing that some production should be … Read more

Difference between an LL and Recursive Descent parser?

LL is usually a more efficient parsing technique than recursive-descent. In fact, a naive recursive-descent parser will actually be O(k^n) (where n is the input size) in the worst case. Some techniques such as memoization (which yields a Packrat parser) can improve this as well as extend the class of grammars accepted by the parser, … Read more

What is the difference between LR, SLR, and LALR parsers?

SLR, LALR and LR parsers can all be implemented using exactly the same table-driven machinery. Fundamentally, the parsing algorithm collects the next input token T, and consults the current state S (and associated lookahead, GOTO, and reduction tables) to decide what to do: SHIFT: If the current table says to SHIFT on the token T, … Read more

What is a Context Free Grammar?

A context free grammar is a grammar which satisfies certain properties. In computer science, grammars describe languages; specifically, they describe formal languages. A formal language is just a set (mathematical term for a collection of objects) of strings (sequences of symbols… very similar to the programming usage of the word “string”). A simple example of … Read more