regexmodel


Nameregexmodel JSON
Version 0.3.5 PyPI version JSON
download
home_pageNone
SummaryPackage modeling structured strings with regex.
upload_time2024-09-17 08:37:20
maintainerNone
docs_urlNone
authorNone
requires_python>=3.8
licenseMIT License Copyright (c) 2023 SoDa Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords regex fitting modeling statistics
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 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:

```bash
pip install regexmodel
```

If you want the latest version of git, use:

```bash
pip install git+https://github.com/sodascience/regexmodel.git
```

If you want to run the benchmarks, you should also install the faker package:

```bash
pip install faker
```

## Using regexmodel

Fitting the regexmodel is as simple as:

```python
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:

```python
model.draw()
```

## Serialization

The regex model can be serialized so that it can be stored in for example a JSON file:

```python
import json
with open(some_file, "w") as handle:
    json.dump(model.serialize(), handle)
```

And deserialized:

```python
with open(some_file, "r") as handle:
    model = RegexModel(json.load(handle))
```


<!-- CONTRIBUTING -->
## 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:
1. Fork the Project
2. Create your Feature Branch (`git checkout -b feature/AmazingFeature`)
3. Commit your Changes (`git commit -m 'Add some AmazingFeature'`)
4. Push to the Branch (`git push origin feature/AmazingFeature`)
5. Open a Pull Request


<!-- CONTACT -->
## Contact
**Regexmodel** is a project by the [ODISSEI Social Data Science (SoDa)](https://odissei-data.nl/nl/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](https://github.com/qubixes).

<img src="soda.png" alt="SoDa logo" width="250px"/> 

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "regexmodel",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": "regex, fitting, modeling, statistics",
    "author": null,
    "author_email": "Raoul Schram <r.d.schram@uu.nl>",
    "download_url": "https://files.pythonhosted.org/packages/3f/22/a64d2acf75a428420ca6538f2f2e8f0eeab941e92e13299f618d17db13f2/regexmodel-0.3.5.tar.gz",
    "platform": null,
    "description": "# regexmodel\n\nRegexmodel is a python package that uses a graph model to fit and synthesize structured strings.\nStructured 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\n(such as phone numbers etc.).\n\nFeatures:\n\n- Draw new synthetic values\n- Only on the numpy and polar libraries (faker for benchmarks).\n- Fast (on average < 1 second for about 500 positive examples).\n- Can provide statistics on how good the regexmodel has fit your values using log likelihood.\n- Can be serialized and can be modified by hand.\n\n## Installation\n\nYou can install regexmodel using pip:\n\n```bash\npip install regexmodel\n```\n\nIf you want the latest version of git, use:\n\n```bash\npip install git+https://github.com/sodascience/regexmodel.git\n```\n\nIf you want to run the benchmarks, you should also install the faker package:\n\n```bash\npip install faker\n```\n\n## Using regexmodel\n\nFitting the regexmodel is as simple as:\n\n```python\nfrom regexmodel import RegexModel\n\nmodel = RegexModel.fit(your_values_to_fit, count_thres=10, method=\"accurate\")\n```\n\nThe `count_thres` parameter changes how detailed and time consuming the fit is. A higher threshold means\na shorter time to fit, but also a worse fit.\n\nThe `method` parameter determines the performance/how fast the model is trained. For better looking results,\nthe \"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.\n\nThen synthesizing a new value is done with:\n\n```python\nmodel.draw()\n```\n\n## Serialization\n\nThe regex model can be serialized so that it can be stored in for example a JSON file:\n\n```python\nimport json\nwith open(some_file, \"w\") as handle:\n    json.dump(model.serialize(), handle)\n```\n\nAnd deserialized:\n\n```python\nwith open(some_file, \"r\") as handle:\n    model = RegexModel(json.load(handle))\n```\n\n\n<!-- CONTRIBUTING -->\n## Contributing\nYou can contribute to the regexmodel package by giving feedback in the \"Issues\" tab, or by creating a pull request.\n\nTo create a pull request:\n1. Fork the Project\n2. Create your Feature Branch (`git checkout -b feature/AmazingFeature`)\n3. Commit your Changes (`git commit -m 'Add some AmazingFeature'`)\n4. Push to the Branch (`git push origin feature/AmazingFeature`)\n5. Open a Pull Request\n\n\n<!-- CONTACT -->\n## Contact\n**Regexmodel** is a project by the [ODISSEI Social Data Science (SoDa)](https://odissei-data.nl/nl/soda/) team.\nDo you have questions, suggestions, or remarks on the technical implementation? File an issue in the issue tracker or feel free to contact [Raoul Schram](https://github.com/qubixes).\n\n<img src=\"soda.png\" alt=\"SoDa logo\" width=\"250px\"/> \n",
    "bugtrack_url": null,
    "license": "MIT License  Copyright (c) 2023 SoDa  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ",
    "summary": "Package modeling structured strings with regex.",
    "version": "0.3.5",
    "project_urls": {
        "GitHub": "https://github.com/sodascience/regexmodel"
    },
    "split_keywords": [
        "regex",
        " fitting",
        " modeling",
        " statistics"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "2d372d8d2013c8ce7563955686d2c128140b4b280a043bb6438bf75959b4707a",
                "md5": "d5b07bbda3c307f173bf45672771bccb",
                "sha256": "b4bdc87a87df13f24e845964b8e3aff78e0cff44e9964fab40cb79dcf7d62a47"
            },
            "downloads": -1,
            "filename": "regexmodel-0.3.5-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "d5b07bbda3c307f173bf45672771bccb",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 18763,
            "upload_time": "2024-09-17T08:37:18",
            "upload_time_iso_8601": "2024-09-17T08:37:18.901055Z",
            "url": "https://files.pythonhosted.org/packages/2d/37/2d8d2013c8ce7563955686d2c128140b4b280a043bb6438bf75959b4707a/regexmodel-0.3.5-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "3f22a64d2acf75a428420ca6538f2f2e8f0eeab941e92e13299f618d17db13f2",
                "md5": "e4778e00a9c09d5c67626c64ce77c6d9",
                "sha256": "8c3ee7f2f4755e585eefba93ff2b520695cd665b84563683ef67e96c78693312"
            },
            "downloads": -1,
            "filename": "regexmodel-0.3.5.tar.gz",
            "has_sig": false,
            "md5_digest": "e4778e00a9c09d5c67626c64ce77c6d9",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 274698,
            "upload_time": "2024-09-17T08:37:20",
            "upload_time_iso_8601": "2024-09-17T08:37:20.572607Z",
            "url": "https://files.pythonhosted.org/packages/3f/22/a64d2acf75a428420ca6538f2f2e8f0eeab941e92e13299f618d17db13f2/regexmodel-0.3.5.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-09-17 08:37:20",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "sodascience",
    "github_project": "regexmodel",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "regexmodel"
}
        
Elapsed time: 0.39285s