[Xapian-tickets] [Xapian] #521: Precedence of HATE is surprising
Xapian
nobody at xapian.org
Thu Mar 3 20:43:03 GMT 2011
#521: Precedence of HATE is surprising
-------------------------+--------------------------------------------------
Reporter: olly | Owner: olly
Type: defect | Status: new
Priority: normal | Milestone: 1.2.x
Component: QueryParser | Version: 1.2.3
Severity: normal | Keywords:
Blockedby: | Platform: All
Blocking: |
-------------------------+--------------------------------------------------
Comment(by dcolish):
After looking briefly at the grammar, I think a good refactoring will be
needed to support this style of precedence. The main issue is that the
grammar will branch on the boolean operators before ever considering the
hate/love operators. This means that even with precedence weight changes,
the grammar could not support the expected output. One way to resolve this
is to classify all binary expressions and reduce those. This way, the
potential reduction of '-' before 'AND' will be controlled by the
precedence of operators. Another approach would be to structure the
grammar to ensure the LOVE/HATE operators are reduced before the boolean
ones; however, this could also have unintended side-effects. I did dump
out the lemon grammar as it stands::
// Reprint of input file "queryparser.lemony".
// Symbols:
// 0 $ 10 HATE_AFTER_AND 20 BRA 30 stop_prob
// 1 ERROR 11 SYNONYM 21 KET 31 stop_term
// 2 OR 12 TERM 22 EMPTY_GROUP_OK 32
compound_term
// 3 XOR 13 GROUP_TERM 23 error 33 phrase
// 4 AND 14 PHR_TERM 24 query 34
phrased_term
// 5 NOT 15 WILD_TERM 25 expr 35 group
// 6 NEAR 16 PARTIAL_TERM 26 prob_expr 36 near_expr
// 7 ADJ 17 BOOLEAN_FILTER 27 bool_arg 37 adj_expr
// 8 LOVE 18 RANGE 28 prob
// 9 HATE 19 QUOTE 29 term
query ::= expr.
query ::=.
expr ::= prob_expr.
expr ::= bool_arg AND bool_arg.
expr ::= bool_arg NOT bool_arg.
expr ::= bool_arg AND NOT bool_arg. [NOT]
expr ::= bool_arg AND HATE_AFTER_AND bool_arg. [AND]
expr ::= bool_arg OR bool_arg.
expr ::= bool_arg XOR bool_arg.
bool_arg ::= expr.
bool_arg ::=. [ERROR]
prob_expr ::= prob.
prob_expr ::= term.
prob ::= RANGE.
prob ::= stop_prob RANGE.
prob ::= stop_term stop_term.
prob ::= prob stop_term.
prob ::= LOVE term.
prob ::= stop_prob LOVE term.
prob ::= HATE term.
prob ::= stop_prob HATE term.
prob ::= HATE BOOLEAN_FILTER.
prob ::= stop_prob HATE BOOLEAN_FILTER.
prob ::= BOOLEAN_FILTER.
prob ::= stop_prob BOOLEAN_FILTER.
prob ::= LOVE BOOLEAN_FILTER.
prob ::= stop_prob LOVE BOOLEAN_FILTER.
stop_prob ::= prob.
stop_prob ::= stop_term.
stop_term ::= TERM.
stop_term ::= compound_term.
term ::= TERM.
term ::= compound_term.
compound_term ::= WILD_TERM.
compound_term ::= PARTIAL_TERM.
compound_term ::= QUOTE phrase QUOTE.
compound_term ::= phrased_term.
compound_term ::= group.
compound_term ::= near_expr.
compound_term ::= adj_expr.
compound_term ::= BRA expr KET.
compound_term ::= SYNONYM TERM.
phrase ::= TERM.
phrase ::= phrase TERM.
phrased_term ::= TERM PHR_TERM.
phrased_term ::= phrased_term PHR_TERM.
group ::= TERM GROUP_TERM.
group ::= group GROUP_TERM.
group ::= group EMPTY_GROUP_OK.
near_expr ::= TERM NEAR TERM.
near_expr ::= near_expr NEAR TERM.
adj_expr ::= TERM ADJ TERM.
adj_expr ::= adj_expr ADJ TERM.
--
Ticket URL: <http://trac.xapian.org/ticket/521#comment:2>
Xapian <http://xapian.org/>
Xapian
More information about the Xapian-tickets
mailing list