bqrs 0.1.3

apply boolean query to text
Documentation
  • Coverage
  • 50%
    1 out of 2 items documented1 out of 1 items with examples
  • Size
  • Source code size: 13.63 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.46 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 9s Average build duration of successful builds.
  • all releases: 9s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • KyussCaesar/bq-rust
    4 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • KyussCaesar

bqrs

This is a library for applying a boolean filter to text.

visit me on crates.io

Example:

extern crate bq_rust;

use bq_rust::Matcher;

let greeting = Matcher::from("'hello' | 'hi'");
assert!(greeting.query("hi there!"));
assert!(greeting.query("hello i am here"));

let greet2 = Matcher::from("('hello' | 'hi' ) 'there'");
assert!(greet2.query("hello there!"));
assert!(greet2.query("hi there!"));

Usage

Use Matcher::from to create a match object.

Use the query method of match objects to find out if the text is a match for the query.

Description

Internally, the query is represented in a tree structure. The interior nodes are the operators AND, OR and NOT, and the leaf nodes are the keywords for the search.

The library checks for any occurence of each keyword in the text, and decides whether to return TRUE or FALSE dependent on the interior nodes.

Uses an implementation of the Knuth-Morris-Pratt algorithm (that I shamelessly copied from a C implementation I found on the internet) for fast string matching.

Syntax

In pseudo-BNF language:

query:
    or-group ( '|' or-group )*

or-group:
    and-group ( '&' and-group )*

and-group:
    STRINGLITERAL
    '!' and-group
    '(' query ')'

Where STRINGLITERAL is any ASCII character sequence enclosed in quotes.

In English

Use '&' for AND, '|' for OR, '!' for NOT. NOT has highest precedence, then AND, then OR.

You can use '(' and ')' for grouping.

let complexq = Matcher::from(" 'that' & ( 'this' | 'these' ) & 'those' ");
assert!(complexq.query("that and this with those"));
assert!(complexq.query("that and these with those"));

TODOs

  • Documentation.
  • More tests.
  • Visualise query as a graph by outputting dot-language files.