pybool_ir.experiments.decompose#

Classes and methods for running experiments that involve execution of each atomic node in a query.

An example of what is possible with this module: >>> from pybool_ir.experiments.decompose import AdHocDecomposeRetrievalExperiment >>> from pybool_ir.index.pubmed import PubmedIndexer >>> from pybool_ir.query.ast import AtomNode >>> def print_callback(node: AtomNode, hits: Hits): … print(f”Query: {node.query}, Hits: {hits.length()}”) >>> with AdHocDecomposeRetrievalExperiment(PubmedIndexer(index_path=”pubmed”), … raw_query=”(a AND b) OR (c AND d)”, … atomic_callback=print_callback) as exp: … exp.go() a 1000 b 500 c 10 d 1000

Functions

AdHocDecomposeRetrievalExperiment(indexer[, ...])

Create an experiment that decomposes a query into atomic nodes and executes each one.

Classes

AND()

DecomposeRetrievalExperiment(indexer, ...[, ...])

Base class for running experiments that involve execution of each atomic node in a query.

NOT()

OR()

Operator()

An operator combines document sets together. It is used by the DecomposeRetrievalExperiment class to

class pybool_ir.experiments.decompose.AND#

Bases: Operator

pybool_ir.experiments.decompose.AdHocDecomposeRetrievalExperiment(indexer: ~pybool_ir.index.index.Indexer, raw_query: str | None = None, query_parser: ~pybool_ir.query.parser.QueryParser = <pybool_ir.query.pubmed.parser.PubmedQueryParser object>, date_from='1900/01/01', date_to='3000/01/01', ignore_dates: bool = False, date_field: str = 'dp', atomic_callback=typing.Callable[[pybool_ir.query.ast.AtomNode, lupyne.engine.documents.Hits], NoneType]) DecomposeRetrievalExperiment#

Create an experiment that decomposes a query into atomic nodes and executes each one. This method can be used to run experiments “on the fly” without having to refer to a collection.

class pybool_ir.experiments.decompose.DecomposeRetrievalExperiment(indexer: ~pybool_ir.index.index.Indexer, collection: ~pybool_ir.experiments.collections.Collection, query_parser: ~pybool_ir.query.parser.QueryParser = <pybool_ir.query.pubmed.parser.PubmedQueryParser object>, eval_measures: ~typing.List[~ir_measures.measures.base.Measure] | None = None, run_path: ~pathlib.Path | None = None, filter_topics: ~typing.List[str] | None = None, ignore_dates: bool = False, date_field: str = 'dp', atomic_callback=typing.Callable[[pybool_ir.query.ast.AtomNode, lupyne.engine.documents.Hits], NoneType])#

Bases: RetrievalExperiment

Base class for running experiments that involve execution of each atomic node in a query.

The atomic_callback argument can be used to specify a callback function that is called after each atomic query is executed. This is useful for logging the results of each atomic query, or for performing some other operation on the results.

atomic_callback#

The callback function that is called after each atomic query is executed.

operators#

The operators used to combine the results of the atomic queries.

property queries: Dict[str, ASTNode]#

This method overrides the default behavior of the pybool_ir.experiments.retrieval.RetrievalExperiment class which adds the date restrictions to the query. This is not necessary for the DecomposeRetrievalExperiment class because the date restrictions are applied to each atomic clause. This ensures that all the atomic queries are executed on the same date range.

class pybool_ir.experiments.decompose.NOT#

Bases: Operator

class pybool_ir.experiments.decompose.OR#

Bases: Operator

class pybool_ir.experiments.decompose.Operator#

Bases: ABC

An operator combines document sets together. It is used by the DecomposeRetrievalExperiment class to

combine the results of the subqueries.