I am just trying to understand a natural language interface for relational databases proposed by Fei Li (2014) (available as github project). Specifically I don't understand the grammar they define for a ParseTree of a natural language query to a database. This question is somewhat like this one but with a more complex grammar.
Background: A natural language sentence can be parsed as ParseTree (common library for this is the Stanford Parser) which describes the grammatical relations of words in a sentence.
The grammar for a valid ParseTree is:
Q -> (SClause)(ComplexCondition)*
SClause -> SELECT + GNP
ComplexCondition -> ON + (leftSubtree*rightSubtree)
leftSubtree -> GNP
rightSubtree -> GNP | VN | MIN | MAX
GNP -> (FN + GNP) | NP
NP -> NN + (NN)*(condition)*
condition -> VN | (ON + VN)
where
Qrepresents an entire query tree+a parent-child relationship*a sibling relationshipSNis a SELECT nodeONis an OPERATOR node (e.g.=,<=)FNis a FUNCTION node (e.g.AVG)NNis a NAME node (e.g. a column in a db table)VNis a VALUE node (i.e. a value in a column in a db table)ComplexConditionmust have oneONwith aleftSubtreeandrightSubtreeNPis oneNNwhose children are multipleNNs and conditions.
My questions:
why is
conditiondefined asVNor (ON+VN)? This would mean that something like the digit5by itself can be a condition. Would make more sense of only the latter, i.e. (ON+VN) is a condition (e.g.>5)How can a
rightSubtreejust be a function (e.g.MIN). Btw I am understanding the pipe|as logical or.I understand that
GNPis recursively defined but at a terminal node theGNPnode must be just aNPnode right? But aNPis defined as something that has children... HOW?!?!?!The authors of the github project quoted above state: "Take a Value Node (
VN) for example, according to the grammar, it is invalid if and only if it has children. I don't know how to infer this from the grammar
Thanks for the help