Case-insensitive Swarmauri file-search tool for counting and highlighting word or phrase matches.
Project description
Swarmauri Tool Search Word
swarmauri_tool_searchword is a Swarmauri file-analysis tool for finding
case-insensitive word or phrase matches inside UTF-8 text files. It returns the
total match count and a line-by-line view with matching lines highlighted, which
makes it useful for documentation QA, terminology enforcement, audit workflows,
and agent-assisted text review.
Why Use Swarmauri Tool Search Word
- Count repeated terms or phrases inside local text files.
- Surface matching lines for agent answers, reviews, and diagnostics.
- Enforce style-guide or terminology rules in docs and content pipelines.
- Reuse a simple search primitive inside larger Swarmauri toolchains.
FAQ
What inputs does the tool expect?
It expects a stringfile_pathand a stringsearch_word.
Is the search case-sensitive?
No. Matching is case-insensitive.
What does the tool return?
A dictionary withcountandlines, wherelinescontains every line from the file and highlights matching lines with ANSI color codes.
Does it only search single words?
No. It can search multi-word phrases as well.
Features
- Case-insensitive search across UTF-8 text files.
- Returns both total occurrence count and full-file line output.
- Highlights matching lines using ANSI escape codes.
- Simple Swarmauri
ToolBaseinterface for scripting and agents. - Supports Python 3.10, 3.11, 3.12, 3.13, and 3.14.
Installation
uv add swarmauri_tool_searchword
pip install swarmauri_tool_searchword
Usage
from swarmauri_tool_searchword import SearchWordTool
tool = SearchWordTool()
result = tool(file_path="docs/README.md", search_word="swarmauri")
print(result["count"])
Examples
Scan documentation for banned terminology
from pathlib import Path
from swarmauri_tool_searchword import SearchWordTool
tool = SearchWordTool()
for path in Path("docs").rglob("*.md"):
result = tool(str(path), "utilize")
if result["count"]:
print(path, result["count"])
Highlight policy terms in a compliance file
from swarmauri_tool_searchword import SearchWordTool
tool = SearchWordTool()
result = tool("policies/security.txt", "retention period")
for line in result["lines"]:
print(line)
Use the tool in a Swarmauri workflow
from swarmauri_standard.tools.ToolCollection import ToolCollection
from swarmauri_tool_searchword import SearchWordTool
tools = ToolCollection(tools=[SearchWordTool()])
print(tools)
Related Packages
- swarmauri_tool_textlength
- swarmauri_tool_lexicaldensity
- swarmauri_tool_sentencecomplexity
- swarmauri_tool_smogindex
- swarmauri_tool_dalechallreadability
Swarmauri Foundations
More Documentation
Best Practices
- Strip ANSI sequences before rendering in interfaces that do not support them.
- Use absolute or well-scoped relative paths in CI jobs.
- Reserve this tool for text files encoded as UTF-8.
- Combine match counts with readability tools when reviewing large content sets.
License
This project is licensed under the Apache-2.0 License.
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
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 swarmauri_tool_searchword-0.11.0.dev1.tar.gz.
File metadata
- Download URL: swarmauri_tool_searchword-0.11.0.dev1.tar.gz
- Upload date:
- Size: 8.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
86ff530d63768e1504bc1694625446a6d79d787388ce19e0ea8def07244b6561
|
|
| MD5 |
fcc3dda257255c32be162205192fc8cd
|
|
| BLAKE2b-256 |
9c3ef5bfa0448ba0acee10938748507e5d51698da457ea2b21aeddb85fb973b3
|
File details
Details for the file swarmauri_tool_searchword-0.11.0.dev1-py3-none-any.whl.
File metadata
- Download URL: swarmauri_tool_searchword-0.11.0.dev1-py3-none-any.whl
- Upload date:
- Size: 9.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
52a57e3bbf8d16e4fd2e3d257262c3cef58082f29b137ecb5f9b51b3acc25df4
|
|
| MD5 |
cdcb3199d65f076ebc133cc7223fb934
|
|
| BLAKE2b-256 |
b413d3d887cb30c9d0447a0e3be4bb007dc0a350412cfc4c9f53fc20835ff004
|