{"id":14483175,"url":"https://github.com/andychase/reparse","last_synced_at":"2025-05-07T22:08:16.618Z","repository":{"id":10007920,"uuid":"12043827","full_name":"andychase/reparse","owner":"andychase","description":"Regular Expression based parsers for extracting data from natural languages","archived":false,"fork":false,"pushed_at":"2017-06-13T19:12:18.000Z","size":107,"stargazers_count":70,"open_issues_count":7,"forks_count":12,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-05-07T22:08:09.768Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://reparse.readthedocs.org/en/latest/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/andychase.png","metadata":{"files":{"readme":"readme.rst","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-08-11T22:49:06.000Z","updated_at":"2025-01-17T09:47:23.000Z","dependencies_parsed_at":"2022-09-05T21:51:23.120Z","dependency_job_id":null,"html_url":"https://github.com/andychase/reparse","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andychase%2Freparse","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andychase%2Freparse/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andychase%2Freparse/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andychase%2Freparse/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/andychase","download_url":"https://codeload.github.com/andychase/reparse/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252961837,"owners_count":21832196,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-09-03T00:01:34.508Z","updated_at":"2025-05-07T22:08:16.583Z","avatar_url":"https://github.com/andychase.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"Reparse\n=======\n\n*Python library/tools for combining and parsing using Regular Expressions in a maintainable way*\n\n[|Build Status| `Download/View Source on Github`_] [`Docs at ReadtheDocs`_]\n\nThis library also allows you to:\n\n- Maintain a database of Regular Expressions\n- Combine them together using Patterns\n- Search, Parse and Output data matched by combined Regex using Python functions.\n\nThis library basically just gives you a way to combine Regular Expressions together\nand hook them up to some callback functions in Python.\n\nA Taste / Getting Started\n=========================\n\n(See the examples/ directory for a full code examples)\n\nSay your fashionista friend must know what colors their friends like at certain times.\nLuckily for you two, your friend's friends are blogging fanatics and you have downloaded thousands\nof text documents containing their every thought.\n\nSo you want to get (color and time) or ``[('green', datetime.time(23, 0))]`` out of text like::\n\n     blah blah blah go to the store to buy green at 11pm! blah blah\n\nIf you need scan/search/parse/transform some unstructured input and get some semi-structured data\nout of it Reparse might be able to help.\n\nFirst structure some Regular Expressions (Here, in Yaml)\n--------------------------------------------------------\n\n.. code-block:: yaml\n\n    Color:\n        Basic Color:\n            Expression: (Red|Orange|Yellow|Green|Blue|Violet|Brown|Black)\n            Matches: Orange | Green\n            Non-Matches: White\n            Groups:\n              - Color\n\n    Time:\n        Basic Time:\n            Expression: ([0-9]|[1][0-2]) \\s? (am|pm)\n            Matches: 8am | 3 pm\n            Non-Matches: 8a | 8:00 am | 13pm\n            Groups:\n              - Hour\n              - AMPM\n\nThen structure some Patterns with those expressions (Yaml)\n----------------------------------------------------------\n\n.. code-block:: yaml\n\n    BasicColorTime:\n      Order: 1\n      Pattern: |\n        \u003cColor\u003e \\s? at \\s? \u003cTime\u003e\n      # Angle brackets detonate expression groups\n      # Multiple expressions in one group are combined together\n\nSome callback functions (in Python)\n-----------------------------------\n\n.. code-block:: python\n\n    from datetime import time\n    def color_time(Color=None, Time=None):\n        Color, Hour, Period = Color[0], int(Time[0]), Time[1]\n        if Period == 'pm':\n            Hour += 12\n        Time = time(hour=Hour)\n\n        return Color, Time\n\nBuild your parser\n-----------------\n\n.. code-block:: python\n\n    from examples.colortime.functions import functions\n    import reparse\n\n\n    colortime_parser = reparse.parser(\n        parser_type=reparse.basic_parser,\n        expressions_yaml_path=path + \"expressions.yaml\",\n        patterns_yaml_path=path + \"patterns.yaml\",\n        functions=functions\n    )\n\n    print(colortime_parser(\"~ ~ ~ go to the store ~ buy green at 11pm! ~ ~\"))\n\nResult\n------\n\n.. code-block:: python\n\n    [('green', datetime.time(23, 0))]\n\nCool!\n\nIntrigued? Learn more how to make the magic happen in `Howto: How to use Reparse`_.\n\nWant to read more about what Reparse is and what it can do? More info in `About: Why another tool for parsing?`_\n\nInfo\n====\n\n.. _installation-howto:\n\nInstallation\n------------\n\npip\n~~~~\n.. code-block:: python\n\n    pip install reparse\n\nmanually\n~~~~~~~~\n\n1. If you don't have them already,\n   Reparse depends on REGEX_, and PyYaml_.\n   Download those and ``python setup.py install`` in their directories.\n   If you are on windows, you may have to find binary installers for these, since they\n   contain modules that have to be compiled.\n\n2. Download the `Zip off of Github`_ (or clone the repo).\n\n3. Extract and do ``python setup.py install`` in the reparse containing the setup.py file directory.\n   You can also just have the reparse/reparse directory in the source tree\n   of your project if you don't want to install it.\n\n4. Test with ``python -c \"import reparse\"``,\n   no output means it is probably installed.\n   If you get ``ImportError: No module named reparse``\n   then you might want to recheck your steps.\n\nSupport\n-------\n\nNeed some help? Send me an email at theandychase@gmail.com and I'll do my best to help you.\n\nContribution\n------------\n\nThe code is located on Github_.\nSend me suggestions, issues, and pull requests and I'll gladly review them!\n\nVersions\n--------\n\n- *3.0* InvalidPattern Exception, Allow monkey patching regex arguments. RE|PARSE -\u003e Reparse.\n- *2.1* Change `yaml.load` to `yaml.safe_load` for security\n- *2.0* Major Refactor, Python 3, Better Parser builders\n- *1.1* Fix setup.py\n- *1.0* Release\n\nLicence\n-------\n\nMIT Licensed! See LICENSE file for the full text.\n\n.. |Build Status| image:: https://travis-ci.org/andychase/reparse.svg?branch=master\n   :target: https://travis-ci.org/andychase/reparse\n\n.. _Download/View Source on Github: https://github.com/andychase/reparse\n\n.. _Github: https://github.com/andychase/reparse\n\n.. _Docs at Readthedocs: https://reparse.readthedocs.org/en/latest/\n\n.. _`Howto: How to use Reparse`: https://reparse.readthedocs.org/en/latest/howto.html\n\n.. _`About: Why another tool for parsing?`: https://reparse.readthedocs.org/en/latest/about.html\n\n.. _`REGEX`: https://pypi.python.org/pypi/regex\n\n.. _`PyYaml`: https://pypi.python.org/pypi/PyYAML\n\n.. _`Zip off of Github`: https://github.com/andychase/reparse/archive/master.zip\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandychase%2Freparse","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fandychase%2Freparse","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandychase%2Freparse/lists"}