Return-Path: X-Original-To: notmuch@notmuchmail.org Delivered-To: notmuch@notmuchmail.org Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id 260E5431FD0 for ; Thu, 20 Jan 2011 22:39:06 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: 0 X-Spam-Level: X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none] autolearn=disabled Received: from olra.theworths.org ([127.0.0.1]) by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id vb7Iq-+YL-GI for ; Thu, 20 Jan 2011 22:39:05 -0800 (PST) Received: from dmz-mailsec-scanner-1.mit.edu (DMZ-MAILSEC-SCANNER-1.MIT.EDU [18.9.25.12]) by olra.theworths.org (Postfix) with ESMTP id 15899431FB6 for ; Thu, 20 Jan 2011 22:39:05 -0800 (PST) X-AuditID: 1209190c-b7ba9ae0000009f8-0c-4d392a08d2ef Received: from mailhub-auth-1.mit.edu ( [18.9.21.35]) by dmz-mailsec-scanner-1.mit.edu (Symantec Brightmail Gateway) with SMTP id CB.B4.02552.80A293D4; Fri, 21 Jan 2011 01:39:04 -0500 (EST) Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103]) by mailhub-auth-1.mit.edu (8.13.8/8.9.2) with ESMTP id p0L6d3aZ004971; Fri, 21 Jan 2011 01:39:03 -0500 Received: from awakening.csail.mit.edu (awakening.csail.mit.edu [18.26.4.91]) (authenticated bits=0) (User authenticated as amdragon@ATHENA.MIT.EDU) by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id p0L6d2Bd004787 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT); Fri, 21 Jan 2011 01:39:03 -0500 (EST) Received: from amthrax by awakening.csail.mit.edu with local (Exim 4.72) (envelope-from ) id 1PgAeE-0000zO-Ie; Fri, 21 Jan 2011 01:39:02 -0500 Date: Fri, 21 Jan 2011 01:39:02 -0500 From: Austin Clements To: notmuch@notmuchmail.org Subject: [PATCH 2.5/8] Query parser tests for NEAR and ADJ operators. Message-ID: <20110121063902.GJ13226@mit.edu> References: <1295165458-9573-1-git-send-email-amdragon@mit.edu> <1295165458-9573-3-git-send-email-amdragon@mit.edu> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1295165458-9573-3-git-send-email-amdragon@mit.edu> User-Agent: Mutt/1.5.20 (2009-06-14) X-Brightmail-Tracker: AAAAAA== Cc: amdragon@mit.edu X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 21 Jan 2011 06:39:06 -0000 --- This is intended to be applied after patch 2/8 in this series, id:1295165458-9573-3-git-send-email-amdragon@mit.edu test/qparser | 5 ++ test/qparser.expected-output/near-and-adj | 83 +++++++++++++++++++++++++++++ test/qparser.expected-output/operators | 12 ++++ test/qparser.expected-output/probs | 6 ++ 4 files changed, 106 insertions(+), 0 deletions(-) create mode 100644 test/qparser.expected-output/near-and-adj diff --git a/test/qparser b/test/qparser index 0e7b022..7ed5c97 100755 --- a/test/qparser +++ b/test/qparser @@ -24,6 +24,11 @@ output=$(../qparser-test < $EXPECTED/operators) expected=$(cat $EXPECTED/operators) test_expect_equal "$output" "$expected" +test_begin_subtest "Near and adj" +output=$(../qparser-test < $EXPECTED/near-and-adj) +expected=$(cat $EXPECTED/near-and-adj) +test_expect_equal "$output" "$expected" + test_begin_subtest "Probs" output=$(../qparser-test < $EXPECTED/probs) expected=$(cat $EXPECTED/probs) diff --git a/test/qparser.expected-output/near-and-adj b/test/qparser.expected-output/near-and-adj new file mode 100644 index 0000000..0da4689 --- /dev/null +++ b/test/qparser.expected-output/near-and-adj @@ -0,0 +1,83 @@ +x near y +[lex] "x" NEAR "y" +[parse] (NEAR "x" (NEAR "y")) +[gen] (x:(pos=1) NEAR 11 y:(pos=2)) + +x near y near z +[lex] "x" NEAR "y" NEAR "z" +[parse] (NEAR "x" (NEAR "y" (NEAR "z"))) +[gen] (x:(pos=1) NEAR 12 y:(pos=2) NEAR 12 z:(pos=3)) + +x near/2 y +[lex] "x" NEAR/2 "y" +[parse] (NEAR "x" (NEAR/2 "y")) +[gen] (x:(pos=1) NEAR 3 y:(pos=2)) + +x near/2 y near z +[lex] "x" NEAR/2 "y" NEAR "z" +[parse] (NEAR "x" (NEAR/2 "y" (NEAR "z"))) +[gen] (x:(pos=1) NEAR 4 y:(pos=2) NEAR 4 z:(pos=3)) + +x near y near/2 z +[lex] "x" NEAR "y" NEAR/2 "z" +[parse] (NEAR "x" (NEAR "y" (NEAR/2 "z"))) +[gen] (x:(pos=1) NEAR 4 y:(pos=2) NEAR 4 z:(pos=3)) + +x near/0 y +[lex] "x" "near/0" "y" +[parse] (AND (AND "x" "near/0") "y") +[gen] (x:(pos=1) AND (near:(pos=2) PHRASE 2 0:(pos=3)) AND y:(pos=4)) + +x near/2z y +[lex] "x" "near/2z" "y" +[parse] (AND (AND "x" "near/2z") "y") +[gen] (x:(pos=1) AND (near:(pos=2) PHRASE 2 2z:(pos=3)) AND y:(pos=4)) + +# The first query below is Xapian-compatible; while the secnd one +# isn't. In both cases, Xapian initially sees "near" as a NEAR +# operator, but in the first case the trailing y is a syntax error, +# which cases Xapian to reparse with no flags. +x near/z y +[lex] "x" "near/z" "y" +[parse] (AND (AND "x" "near/z") "y") +[gen] (x:(pos=1) AND (near:(pos=2) PHRASE 2 z:(pos=3)) AND y:(pos=4)) + +x near/z +[lex] "x" "near/z" +[parse] (AND "x" "near/z") +[gen] (x:(pos=1) AND (near:(pos=2) PHRASE 2 z:(pos=3))) +[xapian] (x:(pos=1) NEAR 11 z:(pos=2)) + +x adj y adj z +[lex] "x" ADJ "y" ADJ "z" +[parse] (ADJ "x" (ADJ "y" (ADJ "z"))) +[gen] (x:(pos=1) PHRASE 12 y:(pos=2) PHRASE 12 z:(pos=3)) + +# Syntax errors +# These are all Xapian-incompatible because they're syntax errors. +(x) NEAR y +[lex] BRA "x" KET NEAR "y" +[parse] (AND (AND "x" "NEAR") "y") +[gen] (x:(pos=1) AND near:(pos=2) AND y:(pos=3)) + +x NEAR (y) +[lex] "x" NEAR BRA "y" KET +[parse] (AND (AND "x" "NEAR") "y") +[gen] (x:(pos=1) AND near:(pos=2) AND y:(pos=3)) + +x NEAR y NEAR (z) +[lex] "x" NEAR "y" NEAR BRA "z" KET +[parse] (AND (AND (NEAR "x" (NEAR "y")) "NEAR") "z") +[gen] ((x:(pos=1) NEAR 11 y:(pos=2)) AND near:(pos=3) AND z:(pos=4)) +[xapian] (x:(pos=1) AND near:(pos=2) AND y:(pos=3) AND near:(pos=4) AND z:(pos=5)) + +x NEAR y ADJ z +[lex] "x" NEAR "y" ADJ "z" +[parse] (AND (AND (NEAR "x" (NEAR "y")) "ADJ") "z") +[gen] ((x:(pos=1) NEAR 11 y:(pos=2)) AND adj:(pos=3) AND z:(pos=4)) +[xapian] (x:(pos=1) AND near:(pos=2) AND y:(pos=3) AND adj:(pos=4) AND z:(pos=5)) + +NEAR x +[lex] NEAR "x" +[parse] (AND "NEAR" "x") +[gen] (near:(pos=1) AND x:(pos=2)) diff --git a/test/qparser.expected-output/operators b/test/qparser.expected-output/operators index 788f007..3d69f9b 100644 --- a/test/qparser.expected-output/operators +++ b/test/qparser.expected-output/operators @@ -143,3 +143,15 @@ x OR @ [parse] (OR "x" "@") [gen] x:(pos=1) [xapian] error Syntax: OR + +@ NEAR x +[lex] "@" NEAR "x" +[parse] (NEAR "@" (NEAR "x")) +[gen] x:(pos=1) +[xapian] (near:(pos=1) AND x:(pos=2)) + +x NEAR @ +[lex] "x" NEAR "@" +[parse] (NEAR "x" (NEAR "@")) +[gen] x:(pos=1) +[xapian] (x:(pos=1) AND near:(pos=2)) diff --git a/test/qparser.expected-output/probs b/test/qparser.expected-output/probs index 3c166f7..8f50cdc 100644 --- a/test/qparser.expected-output/probs +++ b/test/qparser.expected-output/probs @@ -10,6 +10,12 @@ [gen] ((x:(pos=1) OR y:(pos=2)) AND z:(pos=3)) [xapian] (x:(pos=1) AND or:(pos=2) AND y:(pos=3) AND and:(pos=4) AND z:(pos=5)) +# Near binds tighter than hate +x -y NEAR z +[lex] "x" HATE "y" NEAR "z" +[parse] (AND "x" (NOT (NEAR "y" (NEAR "z")))) +[gen] (x:(pos=1) AND_NOT (y:(pos=2) NEAR 11 z:(pos=3))) + # Empty subexpression after prefix # Incompatible; Xapian treats as a syntax error. prob:() AND x -- 1.7.2.3