A set of tools for testing SmokeDetector regexes
Project description
SmokeDetector Regex Testing
SmokeDetector Regex Testing (SDRT) provides functionality for testing regexes against metasmoke data and analyzing their results.
It makes heavy use of the Polars library, which it uses to store post data, test regexes, filter results, and more.
Installation
SDRT is available on PyPI under the name sd-regex-testing.
pip install sd-regex-testing
Usage
Python module
It's recommended to use the sdrt alias when importing sd_regex_testing:
import sd_regex_testing as sdrt
Any processing requires an initial call to sdrt.read_json. This function
accepts the path to a metasmoke JSON file and returns a Polars DataFrame.
data = sdrt.read_json("path/to/file")
From there, the DataFrame can be tested against a regex. The sdrt polars
namespace includes several testing methods:
title = data.sdrt.test_title("test")
username = data.sdrt.test_username("test")
keyword = data.sdrt.test_keyword("test")
website = data.sdrt.test_website("test")
Each of these methods also takes a case_sensitive optional parameter, which
defaults to False.
case_sensitive = data.sdrt.test_keyword("test", case_sensitive=True)
The results of a given test can be filtered using the tp, fp, tn, and
fn properties, which reflect the effectiveness of the just-tested regex.
Each of these properties is a DataFrame containing only the target posts.
tps = keyword.sdrt.tp
fps = keyword.sdrt.fp
tns = keyword.sdrt.tn
fns = keyword.sdrt.fn
Commmand line tool
This package also creates an sdrt command line tool. It takes the path to
an MS JSON file as an argument:
sdrt path/to/file
This will open an interactive regex testing session. The test command will
test a given regex against the file and store the result.
>>> test (title|username|keyword|website) regex
The tp, fp, tn, and fn commands will report the number of posts
with the given result.
>>> tp|fp|tn|fn
The summarize command will pretty-print the counts for all four result
types, as well as reporting the last test.
>>> summarize
Regex [last regex] as a [last regex type] yielded [count] TP, [count] FP, [count] TN, and [count] FN.
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 sd_regex_testing-1.0.2.tar.gz.
File metadata
- Download URL: sd_regex_testing-1.0.2.tar.gz
- Upload date:
- Size: 16.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.11.2 Linux/5.15.153.1-microsoft-standard-WSL2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c9cc885965f243b95bcf17b1ec835a7217b194c86efef83cb801e432cde0ceec
|
|
| MD5 |
988d095cfc4cbcba3ce36c3e879f45a3
|
|
| BLAKE2b-256 |
fd9a4bfdf692c6cf2b1fa4f5a866f596d2ed658e9c706afc4a93fc300f2dc748
|
File details
Details for the file sd_regex_testing-1.0.2-py3-none-any.whl.
File metadata
- Download URL: sd_regex_testing-1.0.2-py3-none-any.whl
- Upload date:
- Size: 18.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.11.2 Linux/5.15.153.1-microsoft-standard-WSL2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6095caaad5536c9764fb1546486a6c0aff18bb1f448ab1e11a825572288e8f96
|
|
| MD5 |
638d0e0f3c02b897ff79ecaf3507317a
|
|
| BLAKE2b-256 |
16d0cf8a0ad6236f4e18cc8df452f56d03a1ac21acbc4d4a8381295ec074d7af
|