Skip to main content

A small boolean + positional query engine with a proper parser.

Project description

LexiQuery

🌐 Language / 语言 · English | 中文


English Version

✨ Highlights

  • 🔀 Boolean logic: NOT > AND > (OR == XOR) with parentheses for custom precedence.
  • 📍 Positional windows: BEF, AFT, NEAR accept /n, /m-n, or /*, and can chain IN(...) (all targets) / INOF(...) (any target).
  • 📏 Length guards: LEN/3-10 for token counts, SIZE/32-128 for byte ranges.
  • 🎯 Match helpers: ONLY, LIKE, STR, END cover set equality, fuzzy presence, and start/end checks.
  • 🃏 Wildcards: foo* or foo * match every token sharing the prefix.
  • 📚 Docs: Detailed syntax in LANGUAGE_MANUAL.md, multilingual overview in README_multi.md.

🚀 Quickstart

from lexiquery import LexiQueryExpression

expr = LexiQueryExpression(
    "(foo XOR bar) AND LEN/3-10 AND foo BEF/2 IN(bar baz)"
)

expr.query("foo baz qux")      # True
expr.query("bar foo baz qux")  # False
from lexiquery import LexiQuery

engine = LexiQuery("foo bar baz qux")
assert engine.query("foo BEF/2 bar")

📦 Install

python -m venv .venv
source .venv/bin/activate
pip install -e .[dev]   # editable + dev extras
# or runtime only
pip install -e .

Publishing to PyPI:

python -m pip install --upgrade build twine
python -m build
python -m twine upload dist/*

🧪 Tests

PYTHONPATH=. pytest

🧩 Syntax Cheat Sheet

Category Example
Boolean (foo OR bar) AND NOT baz
Positional alpha BEF/2-4 beta, foo AFT/* bar, foo NEAR/3 beta
Positional + Sets foo BEF/3 IN(bar baz), foo BEF/* INOF(alpha beta)
Length LEN/5-10 AND foo BEF/2 bar, NOT SIZE/32
Match LIKE foo bar, ONLY foo bar, STR hello world, END goodbye
Wildcard foo* NEAR/1 bar, NOT app*

More samples in tests/test_core.py & tests/test_new_ops.py.

📄 License

MIT License.


中文版本

✨ 功能亮点

  • 🔀 布尔优先级NOT > AND > (OR == XOR),可用括号自定义顺序。
  • 📍 位置窗口BEFAFTNEAR 支持 /n/m-n/*,还能链式追加 IN(...)(全部满足)或 INOF(...)(任一满足)。
  • 📏 长度约束LEN/3-10 控制词数,SIZE/32-128 控制字节长度。
  • 🎯 匹配运算ONLYLIKESTREND 覆盖集合判断与首尾匹配。
  • 🃏 通配符foo* / foo * 匹配所有以 foo 开头的 token。
  • 📚 文档:详尽语法见 LANGUAGE_MANUAL.md,多语言概览见 README_multi.md

🚀 快速体验

from lexiquery import LexiQueryExpression

expr = LexiQueryExpression(
    "(foo XOR bar) AND LEN/3-10 AND foo BEF/2 IN(bar baz)"
)

expr.query("foo baz qux")      # True
expr.query("bar foo baz qux")  # False
from lexiquery import LexiQuery

engine = LexiQuery("foo bar baz qux")
assert engine.query("foo BEF/2 bar")

📦 安装方式

python -m venv .venv
source .venv/bin/activate
pip install -e .[dev]   # 本地开发
# 或仅安装运行时
pip install -e .

发布到 PyPI:

python -m pip install --upgrade build twine
python -m build
python -m twine upload dist/*

🧪 运行测试

PYTHONPATH=. pytest

🧩 语法速查

分类 示例
布尔 (foo OR bar) AND NOT baz
位置 alpha BEF/2-4 betafoo AFT/* barfoo NEAR/3 beta
位置 + 集合 foo BEF/3 IN(bar baz)foo BEF/* INOF(alpha beta)
长度 LEN/5-10 AND foo BEF/2 barNOT SIZE/32
匹配 LIKE foo barONLY foo barSTR hello worldEND goodbye
通配 foo* NEAR/1 barNOT app*

更多示例请参考 tests/test_core.pytests/test_new_ops.py

📄 许可

MIT 许可证。

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

lexiquery-0.2.0.tar.gz (15.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

lexiquery-0.2.0-py3-none-any.whl (9.7 kB view details)

Uploaded Python 3

File details

Details for the file lexiquery-0.2.0.tar.gz.

File metadata

  • Download URL: lexiquery-0.2.0.tar.gz
  • Upload date:
  • Size: 15.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.12

File hashes

Hashes for lexiquery-0.2.0.tar.gz
Algorithm Hash digest
SHA256 94a692115493095b894781e30d5686cccbcf6766607818311bb0fe9b0e126da7
MD5 28b8d6bc6fdd9764ee79abc0f64fe653
BLAKE2b-256 0aae12f61788581c374412698247c1a2aa6cda959bafef73eb714883a8b6e468

See more details on using hashes here.

File details

Details for the file lexiquery-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: lexiquery-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 9.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.12

File hashes

Hashes for lexiquery-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 dca286ec13cb4a011bf1e4e879df7ec937b382d3ba59bc0399a88cd863187f2a
MD5 e3d8418b71bf80969d59b09efeb62462
BLAKE2b-256 22219a361831c6be2729f19c1b336313a507bbd41a3f2b8982d0fd9fe4a7a840

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page