regexmodel
Regexmodel is a python package that uses a graph model to fit and synthesize structured strings. Structured strings are strings such as license plates, credit card numbers ip-addresses, and phone numbers. Regexmodel can infer a regex-like structure from a series of positive examples and create new samples (such as phone numbers etc.).
Features:
- Draw new synthetic values
- Only on the numpy and polar libraries (faker for benchmarks).
- Fast (on average < 1 second for about 500 positive examples).
- Can provide statistics on how good the regexmodel has fit your values using log likelihood.
- Can be serialized and can be modified by hand.
Installation
You can install regexmodel using pip:
pip install regexmodel
If you want the latest version of git, use:
pip install git+https://github.com/sodascience/regexmodel.git
If you want to run the benchmarks, you should also install the faker package:
pip install faker
Using regexmodel
Fitting the regexmodel is as simple as:
from regexmodel import RegexModel
model = RegexModel.fit(your_values_to_fit, count_thres=10, method="accurate")
The count_thres parameter changes how detailed and time consuming the fit is. A higher threshold means
a shorter time to fit, but also a worse fit.
The method parameter determines the performance/how fast the model is trained. For better looking results,
the "accurate" method is advised. If the quickness of the fit is more important, then you can use the "fast" method. The "accurate" method is generally slow with very long/branching/unstructured strings.
Then synthesizing a new value is done with:
model.draw()
Serialization
The regex model can be serialized so that it can be stored in for example a JSON file:
import json
with open(some_file, "w") as handle:
json.dump(model.serialize(), handle)
And deserialized:
with open(some_file, "r") as handle:
model = RegexModel(json.load(handle))
Contributing
You can contribute to the regexmodel package by giving feedback in the "Issues" tab, or by creating a pull request.
To create a pull request:
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature) - Commit your Changes (
git commit -m 'Add some AmazingFeature') - Push to the Branch (
git push origin feature/AmazingFeature) - Open a Pull Request
Contact
Regexmodel is a project by the ODISSEI Social Data Science (SoDa) team. Do you have questions, suggestions, or remarks on the technical implementation? File an issue in the issue tracker or feel free to contact Raoul Schram.
Metadata
Release files for regexmodel 0.3.5
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 |
|---|---|---|---|---|
| regexmodel-0.3.5.tar.gz | 274.7 kB | Without provenance | Details for regexmodel-0.3.5.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| regexmodel-0.3.5-py3-none-any.whl | Python 3 | none | any | Details for regexmodel-0.3.5-py3-none-any.whl |
Total release size: 293.5 kB
Release files / regexmodel-0.3.5.tar.gz
| Download URL | regexmodel-0.3.5.tar.gz |
|---|---|
| Size | 274.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8c3ee7f2f4755e585eefba93ff2b520695cd665b84563683ef67e96c78693312
|
|
BLAKE2b-256 checksum How to use checksums |
3f22a64d2acf75a428420ca6538f2f2e8f0eeab941e92e13299f618d17db13f2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.11.10
|
Release files / regexmodel-0.3.5-py3-none-any.whl
| Download URL | regexmodel-0.3.5-py3-none-any.whl |
|---|---|
| Size | 18.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b4bdc87a87df13f24e845964b8e3aff78e0cff44e9964fab40cb79dcf7d62a47
|
|
BLAKE2b-256 checksum How to use checksums |
2d372d8d2013c8ce7563955686d2c128140b4b280a043bb6438bf75959b4707a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.11.10
|
Security for regexmodel 0.3.5
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.