regexmodel


Nameregexmodel JSON
Version 0.3.3 PyPI version JSON
download
home_page
SummaryPackage modeling structured strings with regex.
upload_time2023-10-13 08:22:25
maintainer
docs_urlNone
author
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))
```

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "regexmodel",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": "",
    "keywords": "regex,fitting,modeling,statistics",
    "author": "",
    "author_email": "Raoul Schram <r.d.schram@uu.nl>",
    "download_url": "https://files.pythonhosted.org/packages/d9/bd/ab73c2bc3fbac39782ab3753a6310fb0c32a9181ca6b174f712f58c843ce/regexmodel-0.3.3.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",
    "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.3",
    "project_urls": {
        "GitHub": "https://github.com/sodascience/regexmodel"
    },
    "split_keywords": [
        "regex",
        "fitting",
        "modeling",
        "statistics"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "b50a4de0510b6890dabed3e35e9a0af7fefc0077d026a2a3c1a30ccdc1d80393",
                "md5": "895e0d3079163138672b33ca01153f7d",
                "sha256": "4cb15bd3eff9c77c9b09598214c2a2268132a798d2e45d3956aac0cfd1daf0f9"
            },
            "downloads": -1,
            "filename": "regexmodel-0.3.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "895e0d3079163138672b33ca01153f7d",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 18334,
            "upload_time": "2023-10-13T08:22:23",
            "upload_time_iso_8601": "2023-10-13T08:22:23.779402Z",
            "url": "https://files.pythonhosted.org/packages/b5/0a/4de0510b6890dabed3e35e9a0af7fefc0077d026a2a3c1a30ccdc1d80393/regexmodel-0.3.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d9bdab73c2bc3fbac39782ab3753a6310fb0c32a9181ca6b174f712f58c843ce",
                "md5": "bb829bcceab95f34926a01ba9da0a650",
                "sha256": "eed4731accf27949e26e9f5771ccade44263d7631dcf832625b7d4892be3e6e4"
            },
            "downloads": -1,
            "filename": "regexmodel-0.3.3.tar.gz",
            "has_sig": false,
            "md5_digest": "bb829bcceab95f34926a01ba9da0a650",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 192881,
            "upload_time": "2023-10-13T08:22:25",
            "upload_time_iso_8601": "2023-10-13T08:22:25.963384Z",
            "url": "https://files.pythonhosted.org/packages/d9/bd/ab73c2bc3fbac39782ab3753a6310fb0c32a9181ca6b174f712f58c843ce/regexmodel-0.3.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-10-13 08:22:25",
    "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.13325s