Parsing and Evaluating Boolean Queries

Turning a query string into a tree and evaluating it against an index. Operator precedence and associativity, a grammar and a tested recursive-descent parser traced call by call, error handling, stop words and analysis inside queries, the parser behind this site's search box and the fixes that testing it led to, and lessons from my course assignment. Worked problems: every AND and OR combination of a query read left to right and by precedence, a traced parse, and a removed stop word under each operator.

A parser gives a Boolean query string its meaning. The conventional precedence, NOT then AND then OR, becomes a grammar with one rule per level and a recursive-descent parser with one function per rule, which builds the query tree. With postings paper → {1, 2}, date → {2, 3} and book → {3, 4}, paper OR date AND book returns documents 1, 2 and 3 by precedence but only 3 read left to right. Of the $2^{n-1}$ AND/OR combinations of $n$ distinct words, the $2^{n-1} - n$ with an OR before an AND mean different things under the two readings. Each query word must be analyzed exactly once, and a removed stop word must act as the identity of its operator: all documents under AND, none under OR.

The articles so far evaluated queries that were already structured, but a user types a string. What does paper OR date AND book mean? Read with AND binding more tightly than OR, as in most programming languages and in logic, it is paper OR (date AND book). Read strictly left to right, it is (paper OR date) AND book. Take the postings paper → {1, 2}, date → {2, 3}, and book → {3, 4}. The first reading returns documents 1, 2, and 3, and the second returns only document 3. Which reading is right, and how does a program arrive at it? Neither is right in itself. The first is the convention, and a program arrives at it by following a grammar that gives each operator its own level.

A Boolean search system has to choose one reading, document it, and implement it consistently. The choice belongs to the parser, the component that turns a query string into a structure the system can evaluate. That structure is a query tree, and the optimizer and the merge algorithms work on it.

The two readings of paper OR date AND book as trees, each node labeled with the documents it evaluates to. With AND binding tighter, AND joins date and book into {3}, and OR adds paper's {1, 2} to give {1, 2, 3}. Read left to right, OR forms {1, 2, 3} first and AND with book cuts it to {3}. Same words, same postings, different trees, different answers.
The two readings of paper OR date AND book as trees, each node labeled with the documents it evaluates to. With AND binding tighter, AND joins date and book into {3}, and OR adds paper's {1, 2} to give {1, 2, 3}. Read left to right, OR forms {1, 2, 3} first and AND with book cuts it to {3}. Same words, same postings, different trees, different answers.

First we write the conventional precedence as a grammar and build a recursive-descent parser from it. Then we evaluate the tree, handle malformed queries, and settle what a removed query word means. Then we look at two real parsers: this site's, and the one I wrote for the course's second assignment. Worked problems, the assignment among them, close the article.

Precedence and grammar

How can a program know which operator binds first? The conventional precedence, from tightest to loosest, is NOT, then AND, then OR, with parentheses overriding it. NOT a AND b OR c therefore means ((NOT a) AND b) OR c. The convention can be written as a grammar with one rule per precedence level:

expr    := term ( OR term )*
term    := factor ( AND factor )*
factor  := NOT factor | "(" expr ")" | WORD

Each rule handles one operator and delegates tighter-binding operators to the rule below it:

  • An expr is a sequence of terms joined by OR.
  • A term is a sequence of factors joined by AND.
  • A factor is a negation, a parenthesized expression, or a word.

Because OR appears only at the top level, AND always groups first.

Precedence decides how different operators group. Associativity decides how a run of the same operator groups: a AND b AND c could be (a AND b) AND c or a AND (b AND c). For Boolean AND and OR the choice cannot change the answer, since intersection and union are associative, so a parser may pick either. The loops in the grammar build left-leaning trees, which is the conventional choice. An optimizer is free to regroup the terms anyway, as optimizing Boolean queries describes. This freedom is exactly what lets it intersect the rarest lists first.

Example (NOT binds tightest). Under this grammar, NOT paper OR date and NOT (paper OR date) do not mean the same thing. NOT binds tightest, so the first is (NOT paper) OR date. Take five documents and the postings above. NOT paper is $\{3, 4, 5\}$, and its union with the documents of date, $\{2, 3\}$, is 2, 3, 4, and 5. paper OR date is $\{1, 2, 3\}$, so NOT (paper OR date) returns only 4 and 5.

A recursive-descent parser

How does a grammar become code? A grammar of this shape translates directly into a recursive-descent parser, with one function per rule (Aho, Lam, Sethi, and Ullman, 2006, chapter 4):

import re

TOKEN = re.compile(r"\s*(\(|\)|AND\b|OR\b|NOT\b|[^\s()]+)")


def tokenize(query):
    return [m.group(1) for m in TOKEN.finditer(query)]


class Parser:
    def __init__(self, tokens):
        self.tokens, self.pos = tokens, 0

    def peek(self):
        return self.tokens[self.pos] if self.pos < len(self.tokens) else None

    def take(self, expected=None):
        tok = self.peek()
        if tok is None or (expected and tok != expected):
            raise SyntaxError(f"expected {expected or 'a term'} at position {self.pos}, found {tok}")
        self.pos += 1
        return tok

    def parse(self):
        tree = self.expr()
        if self.peek() is not None:
            raise SyntaxError(f"unexpected {self.peek()} at position {self.pos}")
        return tree

    def expr(self):
        node = self.term()
        while self.peek() == "OR":
            self.take("OR")
            node = ("OR", node, self.term())
        return node

    def term(self):
        node = self.factor()
        while self.peek() == "AND":
            self.take("AND")
            node = ("AND", node, self.factor())
        return node

    def factor(self):
        if self.peek() == "NOT":
            self.take("NOT")
            return ("NOT", self.factor())
        if self.peek() == "(":
            self.take("(")
            node = self.expr()
            self.take(")")
            return node
        return ("TERM", self.take())

The parser produces the query tree. paper OR date AND book parses to

("OR", ("TERM", "paper"), ("AND", ("TERM", "date"), ("TERM", "book")))

with AND grouped below OR, as the grammar requires. Tracing the calls shows how. The tokens are paper, OR, date, AND, book. Each line below is a call to one of the three rule functions, indented by its depth and showing the next unread token, followed by the value it returns:

expr    (next token: paper)
  term    (next token: paper)
    factor    (next token: paper)
    -> ('TERM', 'paper')
  -> ('TERM', 'paper')                      the next token is OR, so term stops
  [expr consumes OR]
  term    (next token: date)
    factor    (next token: date)
    -> ('TERM', 'date')
    [term consumes AND]
    factor    (next token: book)
    -> ('TERM', 'book')
  -> ('AND', ('TERM', 'date'), ('TERM', 'book'))
-> ('OR', ('TERM', 'paper'), ('AND', ('TERM', 'date'), ('TERM', 'book')))

The decisive moment is the second call to term. Called by expr to read one operand of OR, it keeps consuming AND factor pairs before returning. So date AND book is complete before expr builds the OR node. The first call to term returned after one factor, because the token after paper was OR, which term does not handle. Precedence is encoded in which function owns which loop.

Operators are recognized only in capitals, the convention of many search systems, so that lowercase and and or are treated as ordinary words rather than operators. (In this grammar, the words of rock and roll would still need operators between them, as discussed under malformed queries below.)

Evaluating the tree

With a tree in hand, how is it turned into a set of documents? Evaluation walks the tree from the leaves up. Each leaf is analyzed into an index term and replaced by its postings from the inverted index. Each operator combines its children with the corresponding set operation:

def evaluate(node, postings, all_docs, analyze):
    op = node[0]
    if op == "TERM":
        return postings.get(analyze(node[1]), set())
    if op == "NOT":
        return all_docs - evaluate(node[1], postings, all_docs, analyze)
    left = evaluate(node[1], postings, all_docs, analyze)
    right = evaluate(node[2], postings, all_docs, analyze)
    return left & right if op == "AND" else left | right

On the example postings, with five documents in the collection:

Query Result
paper OR date AND book 1, 2, 3
(paper OR date) AND book 3
NOT paper AND book 3, 4
paper AND NOT (date OR book) 1

This evaluator uses Python sets for clarity. It assumes that any leaves whose words analysis would discard, such as stop words, have already been removed from the tree, for reasons explained below. A production evaluator differs in three ways:

  • it works on sorted postings lists with the merge algorithms (Manning, Raghavan, and Schütze, 2008, §1.3);
  • it reorders the tree's children before evaluating them, as described in optimizing Boolean queries;
  • it turns x AND NOT y into a single difference operation rather than computing a complement.

Separating parsing from evaluation, so that the parser produces a tree and the evaluator consumes it, is what makes those optimizations possible. A parser that computes sets while it parses commits to the order in which the query was written.

Malformed queries

What should happen when the string does not fit the grammar? Users type incomplete queries. A parser should reject them with a message that explains why, rather than guess or silently return nothing. The parser above reports three common errors:

Query Error
paper AND expected a term at position 2
(paper OR date expected ) at position 4
paper date unexpected date at position 1

The last is a design decision rather than an error in any absolute sense. Many systems, including web search engines, treat adjacent terms as an implicit AND. Supporting that means changing the term rule to continue whenever the next token begins a factor, not only when it is AND.

Writing a parser also avoids a tempting shortcut. Converting a query to a Python expression and calling eval() appears to work. But it executes whatever the user typed as code, which is a serious security hole, and it ties the query language to Python's syntax.

Analysis inside queries

A leaf holds the word the user typed, but the index holds terms. Each query term must be analyzed exactly as document terms were: tokenized, case-folded, checked against the stop list, and stemmed (see text processing and indexing). Two complications arise in Boolean queries.

Analyze each term exactly once. Suppose analysis happens both when the query is tokenized and again when a term is looked up. Terms are then stemmed twice. The Porter stemmer is not idempotent, so a second pass can produce a stem that is not in the index. It turns defense into defens, and defens into defen. The index, built with one pass, holds defens, and a query term stemmed twice looks up defen and finds nothing.

Decide what a removed stop word means. If analysis discards a query word, the tree loses a leaf, and the operator above it is left with a missing operand. Treating the missing operand as an empty set fails for AND, because x AND ∅ is always empty: Department AND of AND Defense would return nothing. The removed word should instead act as the identity element of its operator: the set of all documents for AND, the empty set for OR. The simplest implementation removes the leaf and its operator from the tree before evaluation, so that the query becomes Department AND Defense.

A parser that the public uses makes some of these decisions the other way. The search box on this site accepts the same kind of Boolean query, and its parser makes several of the decisions discussed above differently. A query that contains AND, OR, or NOT in capitals, or a parenthesis that groups, is parsed as Boolean. Any other query is treated as free text and ranked, in the style of a web search engine. The Boolean grammar is

or_expr  := and_expr ( OR and_expr )*
and_expr := not_expr ( [AND] not_expr )*
not_expr := NOT not_expr | primary
primary  := "(" or_expr ")" | atom

It has the same three precedence levels as the grammar above, with two changes. The brackets around AND make it optional, so adjacent terms are joined by an implicit AND, the extension suggested under malformed queries. And the loops collect all the operands of a run into one node, ('and', [x, y, z]), rather than nesting binary nodes, so a flattened conjunction is produced directly.

An atom can be more than a word:

  • a quoted phrase;
  • a word with a field prefix such as title:;
  • a prefix pattern such as crawl*;
  • a word with a leading minus, which the parser reads as NOT.

Words are left unanalyzed in the tree and are stemmed when the index evaluates it, so each leaf is analyzed once. How This Search Works describes the index that analyzes and evaluates the tree. A possessive 's is dropped from query words, as it is from page text, so Porter's searches for Porter. Run on example queries, the parser produces these trees:

Query Tree
paper OR date AND book or[paper, and[date, book]]
paper OR date book or[paper, and[date, book]]
NOT a AND b OR c or[and[not a, b], c]
(stemming OR lemmatization) AND NOT porter and[or[stemming, lemmatization], not porter]
"inverted index" -bm25 OR title:pagerank or[and[phrase "inverted index", not bm25], title:pagerank]
crawl* AND NOT robots.txt and[prefix crawl, not phrase "robots txt"]
(selection OR mutation)-ES and[or[selection, mutation], not ES]

The second query gives the same tree as the first, because the implicit AND binds as tightly as the explicit one. In the fifth, the minus sign and the space both behave as their Boolean equivalents, and the field restriction travels with its word. In the sixth, robots.txt is one written word but two tokens, so it becomes a two-word phrase. In the last, the minus sign is written against the closing parenthesis of a group that holds an operator, so it applies to the next word: the query means (selection OR mutation) AND NOT ES.

The other difference is error handling. What should a public search box do with paper AND? This parser never rejects a query. It repairs what it can and reports each repair as a note shown above the results:

Query Parsed as Note
(paper OR date or[paper, date] added a missing ")"
a AND OR b and[a, b] ignored OR with nothing before it
paper AND paper ignored AND with nothing after it

The design choice is the opposite of the strict parser's. A search box used by the public should return something useful for an imperfect query, and the note keeps the repair visible. Nesting is capped at 16 levels of parentheses, beyond which further opening parentheses are ignored with a note. No query the search box accepts (it keeps the first 200 characters) can therefore exhaust the recursion of the parser.

What testing the parser and index together changed

When this article was first written, testing the parser and index together showed four behaviors that did not match what the queries meant. All four have since been changed. They are kept here because each is a small lesson in where such mismatches come from.

  • A hyphen after a closing parenthesis was read as NOT. The lexer treated every parenthesis as grouping, so it split (1+1)-ES, the name of an evolution strategy, into (1+1) and -ES. The second token was an atom with a leading minus. The query became and[phrase "1 1", not ES], which excluded pages that mention ES, the opposite of what was meant. The lexer now splits the query at spaces first. It treats a leading ( or trailing ) of a chunk as grouping only if what they enclose is balanced. (1+1)-ES and f(x) are single written words, searched by their parts, while (a OR b) still groups, and -(a OR b) negates the group. An operator written against a parenthesis, as in (a)OR(b), and punctuation after a closing one, as in (a OR b), c, are split off first. A sign written against the ) of a group that holds an operator applies to the next word, as in the last row of the trees above.
  • A stop word became the set of all documents, under any operator. The index evaluated a stop word as every document. That is the identity element for AND, as the section on analysis inside queries recommends. For OR the identity is the empty set, and the OR pagerank returned every article on the site. The evaluator now returns "no constraint" for a node that holds only stop words, and each operator decides what that means: AND and OR skip it, and NOT of it is also no constraint. the OR pagerank returns the same articles as pagerank, with a note that "the" was ignored.
  • Greek letters matched nothing. The tokenizer kept only the letters a to z and the digits after accent folding. A query word such as μ was looked up, found no postings, and evaluated to the empty set. Greek letters are now replaced by their names on both sides. μ in a query is searched as "mu", and the index adds the names of the Greek letters used in each article's mathematics, written there as TeX commands such as \mu. A search for (μ,λ)-ES or mu lambda now finds the evolution-strategy articles.
  • A dangling AND was dropped without a note, although the module's documentation said every repair is reported. The note is now added.

None of these was a parsing problem in the narrow sense. Each came from a boundary between components:

  • the lexer and the atom syntax, in the first;
  • the analyzer and the evaluator, in the second and third;
  • the parser's documentation and its behavior, in the fourth.

The changes are the ones this article recommends, applied at those boundaries. Analyze each leaf once, decide in the tree what a removed word means for its operator, and test the parser and index together on queries with hand-computed answers. Each change now has a regression test in tools/search/test_search.py. The examples above come from tools/experiments/boolean/parsing.py, which runs the site's parser in app/query.py. The script reads the parser as it stands, so the tables describe the parser at the time the script was last run, in November 2026.

Lessons from my assignment

The same decisions arise in a parser written for a course. The second assignment in the course was to answer Boolean queries over an extended version of the HW01 index, which added term frequencies and changed the preprocessing. For each query of two to four words, the program generated every combination of AND and OR between the words, evaluated each, and ordered the results by TF-IDF score. Submissions were checked against expected answers for a set of searches on a provided dataset. Precedence had not yet been covered in the course, and the expected answers assumed the operators were applied left to right. An earlier version of my parser that followed the conventional precedence did not match them. It also evaluated set expressions in a way that could have executed injected code, so I set it aside. My submitted solution, HW02 on GitHub, contains a hand-written recursive-descent parser. It handles AND, OR, NOT, and parentheses, computes NOT by subtracting from the set of all documents, never calls eval(), and matched the expected answers.

Testing the parser class in isolation for this article, against a small stand-in index, shows how it behaves beyond the assignment's searches. The stand-in only approximates the assignment's data and preprocessing. These tests therefore describe the parser, not what the graded runs returned. Three points are worth noting.

Precedence is left to right. AND and OR are handled in the same loop and applied in the order written, as the assignment's expected answers required, so paper OR date AND book is evaluated as (paper OR date) AND book and returns document 3 rather than 1, 2, and 3. The parser's docstring, however, still describes the conventional precedence NOT > AND > OR. Reusing the parser outside the assignment would mean either updating the documentation or adding a precedence level for AND, as in the grammar above.

Dropped words become empty operands. The query tokenizer drops stop words and any token that is not purely alphabetic. That filter was carried over from HW01; the HW02 index itself no longer applied it. Department AND of AND Defense becomes depart AND AND defens. When the parser meets the second AND where it expects a term, it returns an empty set, and the intersection with an empty set is empty. The hyphenated word-occurrence fails the letters-only test and disappears in the same way. So word-occurrence AND frequency returns nothing, even though the index probably contains the hyphenated term. With OR elsewhere in the expression the result is not always empty, but it still differs from what the query asks. basis AND of OR recommendations returns every document containing recommendations and loses those containing only basis. Three of the assignment's five queries contain such a word: basis of recommendations, Department of Defense, and word-occurrence frequency.

Terms are stemmed twice. The double stemming described in building an indexing pipeline carried over from HW01: the parser stems each term when tokenizing the query and again when looking it up. For the assignment's queries, defense becomes defen and purpose becomes purpo, neither of which is in the index. Those two words therefore never match any document, so in Department of Defense and general purpose computer programs, every combination that requires either word returns nothing.

The last two behaviors are silent. The parser runs, returns plausible results for most combinations, and gives no sign that some answers are missing. The remedies are the ones described above:

  • one rule per precedence level;
  • a separate analysis step, applied to each leaf exactly once;
  • removal of stop-word leaves before evaluation.

A small set of tests with hand-computed answers, like the table in the evaluation section, catches all three.

Worked problems

Problem 1 is the Boolean part of the course's second assignment, described in the section above, solved on this article's example postings. Problems 2 and 3 are posed here on the same postings. Throughout, the collection has five documents and the postings are paper → {1, 2}, date → {2, 3} and book → {3, 4}. The script checks every result.

Problem 1. For a query of two to four words, generate every combination of AND and OR between the words and evaluate each combination with the operators applied from left to right. How many combinations are there? Carry the task out for the query words paper, date, book. For which combinations would the conventional precedence give a different answer?

Solution. A query of $n$ words has $n - 1$ gaps between words, and each gap takes AND or OR, so there are $2^{n-1}$ combinations: 2 for two words, 4 for three and 8 for four.

The approach. Evaluation from left to right needs no tree. Keep one running set, start it at the postings of the first word, and for each following word replace it by its intersection or union with that word's postings. The running set is the value of everything read so far, which is exactly the left-to-right grouping $((w_1 \circ w_2) \circ w_3) \circ w_4$. Generating the combinations is a count from 0 to $2^{n-1} - 1$ in binary, reading each bit as AND or OR. No string is ever handed to an interpreter, so nothing a user types can run as code.

For the three words:

Combination Left to right Result Conventional precedence Result
paper AND date AND book ({1, 2} ∩ {2, 3}) ∩ {3, 4} = {2} ∩ {3, 4} none the same grouping none
paper AND date OR book ({1, 2} ∩ {2, 3}) ∪ {3, 4} = {2} ∪ {3, 4} 2, 3, 4 the same grouping 2, 3, 4
paper OR date AND book ({1, 2} ∪ {2, 3}) ∩ {3, 4} = {1, 2, 3} ∩ {3, 4} 3 {1, 2} ∪ ({2, 3} ∩ {3, 4}) = {1, 2} ∪ {3} 1, 2, 3
paper OR date OR book ({1, 2} ∪ {2, 3}) ∪ {3, 4} 1, 2, 3, 4 the same grouping 1, 2, 3, 4

One combination of the four is read differently, the one in which an OR comes before an AND. That is the general rule. If every AND comes before every OR, the conventional reading groups the leading run of ANDs first and then applies the ORs in order, which is the left-to-right grouping. If some OR is followed later by an AND, and the words are all different (as in the assignment's queries), the two readings are different Boolean functions. With a repeated word they can coincide: a OR b AND a is a under both readings. Consider a document that contains the words before the first OR and no others. Read from left to right, the running value is true at the first OR, stays true through any further ORs, turns false at the next AND, whose word is missing, and stays false to the end, since every later word is missing too. Read by precedence, the words before the first OR form a complete AND group that is true, and the query is an OR of such groups, so it is true. The readings disagree on that document.

The combinations with no OR before an AND are a run of ANDs followed by a run of ORs, and there are $n$ of them for $n$ words (the run of ANDs can have $0, 1, \dots, n - 1$ operators). So $2^{n-1} - n$ combinations are grouped differently, and for distinct words they are different functions: 0 of 2 for two words, 1 of 4 for three, and 4 of 8 for four. Whether the results also differ depends on the postings.

The assignment then ordered each result by TF-IDF score. That step uses the weighting defined in TF-IDF weighting, in the next topic, and is not part of the Boolean evaluation. The submitted program is HW02 on GitHub.

Problem 2. Parse NOT paper AND (date OR book) with the grammar of this article, and evaluate the tree.

Solution. The tree is ("AND", ("NOT", ("TERM", "paper")), ("OR", ("TERM", "date"), ("TERM", "book"))), and it evaluates to documents 3 and 4.

The tokens are NOT, paper, AND, (, date, OR, book, ). The calls run as follows.

  1. expr calls term, which calls factor. The next token is NOT, so factor consumes it and calls factor again, which reads paper. The outer factor returns ("NOT", ("TERM", "paper")). The NOT has taken exactly one factor, the word after it, which is why it binds tightest.
  2. Back in term, the next token is AND, so term consumes it and calls factor for the right operand. The next token is (, so factor consumes it and calls expr for the contents.
  3. That inner expr calls term, which reads date and returns, because the next token is OR, which term does not handle. The inner expr consumes OR, calls term again for book, and builds ("OR", ("TERM", "date"), ("TERM", "book")). The next token is ), so its loop ends.
  4. factor consumes the ) and returns the OR node. term builds the AND node from its two factors. No tokens remain, so term and then the outer expr return it.

Evaluation goes from the leaves up. NOT paper is the five documents less {1, 2}, which is {3, 4, 5}. date OR book is {2, 3} ∪ {3, 4} = {2, 3, 4}. Their intersection is {3, 4}.

The parentheses changed the tree. Without them, NOT paper AND date OR book parses as ((NOT paper) AND date) OR book, which is {3} ∪ {3, 4} = {3, 4}, the same documents by coincidence of these postings. A NOT over a larger group shows a difference: NOT (paper AND date) OR book is the five documents less {2}, united with {3, 4}, which is 1, 3, 4 and 5.

Problem 3. The word of is on the stop list. Evaluate date AND of AND book and date OR of under three treatments of the removed word: as the empty set, as the set of all documents, and as the identity element of its operator.

Solution. Only the identity treatment gives the intended answer for both queries: document 3 for the first and documents 2 and 3 for the second.

Treatment of of date AND of AND book date OR of
empty set {2, 3} ∩ ∅ ∩ {3, 4} = none {2, 3} ∪ ∅ = 2, 3
all documents {2, 3} ∩ {1, ..., 5} ∩ {3, 4} = 3 {2, 3} ∪ {1, ..., 5} = 1, 2, 3, 4, 5
identity of its operator date AND book = 3 date = 2, 3

The intended meaning of each query is the query without the uninformative word: date AND book, which is {2, 3} ∩ {3, 4} = {3}, and date, which is {2, 3}. The empty set is right under OR and wrong under AND, where it empties the result. The set of all documents is right under AND and wrong under OR, where it returns the whole collection. Each is the identity element of one operator only: $X \cap D = X$ for the whole collection $D$, and $X \cup \emptyset = X$. A treatment that is right for both must therefore look at the operator above the removed word, which is what removing the leaf and its operator from the tree does.

What we have learned

A parser fixes what a query string means. With one grammar rule per precedence level, paper OR date AND book returns 1, 2, and 3 rather than 3. Keeping parsing apart from evaluation leaves the optimizer free to reorder the tree. Each leaf is analyzed exactly once, and a removed stop word acts as the identity of its operator.

That completes the machinery, from query string to merged postings. The next article, Boolean Search in Practice, describes who writes Boolean queries today and how Boolean search compares with ranking.

References

  • Aho, A. V., Lam, M. S., Sethi, R., and Ullman, J. D. (2006). Compilers: Principles, Techniques, and Tools, 2nd edition, chapter 4. Addison-Wesley. record
  • Manning, C. D., Raghavan, P., and Schütze, H. (2008). Introduction to Information Retrieval, section 1.3. Cambridge University Press. record · 102 pages

Reviewed: verified, 16 Nov 2026 · citations checked, 16 Nov 2026 · editorial review, 23 Nov 2026 · 10 revisions