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,NEARaccept/n,/m-n, or/*, and can chainIN(...)(all targets) /INOF(...)(any target). - 📏 Length guards:
LEN/3-10for token counts,SIZE/32-128for byte ranges. - 🎯 Match helpers:
ONLY,LIKE,STR,ENDcover set equality, fuzzy presence, and start/end checks. - 🃏 Wildcards:
foo*orfoo *match every token sharing the prefix. - 📚 Docs: Detailed syntax in
LANGUAGE_MANUAL.md, multilingual overview inREADME_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),可用括号自定义顺序。 - 📍 位置窗口:
BEF、AFT、NEAR支持/n、/m-n、/*,还能链式追加IN(...)(全部满足)或INOF(...)(任一满足)。 - 📏 长度约束:
LEN/3-10控制词数,SIZE/32-128控制字节长度。 - 🎯 匹配运算:
ONLY、LIKE、STR、END覆盖集合判断与首尾匹配。 - 🃏 通配符:
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 beta、foo AFT/* bar、foo NEAR/3 beta |
| 位置 + 集合 | foo BEF/3 IN(bar baz)、foo BEF/* INOF(alpha beta) |
| 长度 | LEN/5-10 AND foo BEF/2 bar、NOT SIZE/32 |
| 匹配 | LIKE foo bar、ONLY foo bar、STR hello world、END goodbye |
| 通配 | foo* NEAR/1 bar、NOT app* |
更多示例请参考 tests/test_core.py 与 tests/test_new_ops.py。
📄 许可
MIT 许可证。
Project details
Release history Release notifications | RSS feed
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)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
94a692115493095b894781e30d5686cccbcf6766607818311bb0fe9b0e126da7
|
|
| MD5 |
28b8d6bc6fdd9764ee79abc0f64fe653
|
|
| BLAKE2b-256 |
0aae12f61788581c374412698247c1a2aa6cda959bafef73eb714883a8b6e468
|
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dca286ec13cb4a011bf1e4e879df7ec937b382d3ba59bc0399a88cd863187f2a
|
|
| MD5 |
e3d8418b71bf80969d59b09efeb62462
|
|
| BLAKE2b-256 |
22219a361831c6be2729f19c1b336313a507bbd41a3f2b8982d0fd9fe4a7a840
|