iword — High-speed keyword search with shared memory
Python binding for iWord: zero-copy keyword search via System V shared memory.
Requirements
-
Build the shared library:
git clone https://github.com/atfreaks/iword cd iword && make lib # → bin/libiword.so
-
Load a dictionary:
bin/iwordctl load dict/spam_en.txt
Install
pip install iword
Usage
from iword import seek, map as iword_map, filter_text, extract_by_key
from iword import MODE_HTML, MODE_FORBID, KEY_SPAM
# Search for a single word
key = seek("spam") # returns 2 (KEY_SPAM), or -1 if not found
# Scan text for all matches
matches = iword_map("Get your free prize now!", MODE_HTML | MODE_FORBID)
# [Match(position=8, length=4, key=2), ...]
# Replace matches with '*'
clean = filter_text("buy spam now", MODE_HTML | MODE_FORBID)
# "buy **** now"
# Extract matches by category
spam_only = extract_by_key(text, KEY_SPAM, MODE_HTML | MODE_FORBID)
LangChain Integration
from langchain.tools import BaseTool
from iword import map as iword_map, MODE_HTML, MODE_FORBID, KEY_SPAM
class IWordSpamFilter(BaseTool):
name = "iword_spam_filter"
description = "Detect spam keywords in text using shared memory dictionary."
def _run(self, text: str) -> dict:
matches = iword_map(text, MODE_HTML | MODE_FORBID)
spam = [m for m in matches if m.key == KEY_SPAM]
return {"is_spam": len(spam) > 0, "matches": len(spam)}
Notes
- Requires
bin/libiword.so(built viamake lib) at runtime - Dictionary must be loaded via
iwordctl loadbefore callingseek/map - System V SHM is not available on AWS Lambda, Cloud Run, or other serverless platforms
Metadata
Release files for iword 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| iword-0.1.0.tar.gz | 3.7 kB | Without provenance | Details for iword-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| iword-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for iword-0.1.0-py3-none-any.whl |
Total release size: 7.6 kB
Release files / iword-0.1.0.tar.gz
| Download URL | iword-0.1.0.tar.gz |
|---|---|
| Size | 3.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
44c8038d1db41632fb5585a00d118df9f7d347989f1bca3108d3c5c7343089ba
|
|
BLAKE2b-256 checksum How to use checksums |
dbe6870b38757b21bb46b107b6a1f2462c1b0f6cbff9e3fc6d3442266d81f05b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.8
|
Release files / iword-0.1.0-py3-none-any.whl
| Download URL | iword-0.1.0-py3-none-any.whl |
|---|---|
| Size | 3.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
881ab70a5a3a7c20f8222f9bb0dcefa0f7d4c1cb7357c640f37c6a170088b282
|
|
BLAKE2b-256 checksum How to use checksums |
cbdee203cca7171548dc23bafd6c772c15c72353f0455f17a562fbbd0a81c0b3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.8
|
Security for iword 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.