{"id":15683962,"url":"https://github.com/dylanwal/unit_parse","last_synced_at":"2025-08-07T00:40:15.176Z","repository":{"id":40770445,"uuid":"450973107","full_name":"dylanwal/unit_parse","owner":"dylanwal","description":"Tool for parsing 'ugly' numbers and units","archived":false,"fork":false,"pushed_at":"2025-04-23T15:49:53.000Z","size":1174,"stargazers_count":12,"open_issues_count":0,"forks_count":3,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-24T09:03:51.991Z","etag":null,"topics":["parser","python","science","units","units-measures-converter","units-of-measure"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dylanwal.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2022-01-23T00:58:59.000Z","updated_at":"2025-04-23T15:49:58.000Z","dependencies_parsed_at":"2024-07-05T15:32:10.221Z","dependency_job_id":"03ce25c8-d92c-44f0-80d5-afaf67a77d81","html_url":"https://github.com/dylanwal/unit_parse","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/dylanwal/unit_parse","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dylanwal%2Funit_parse","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dylanwal%2Funit_parse/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dylanwal%2Funit_parse/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dylanwal%2Funit_parse/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dylanwal","download_url":"https://codeload.github.com/dylanwal/unit_parse/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dylanwal%2Funit_parse/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269180959,"owners_count":24373841,"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","status":"online","status_checked_at":"2025-08-06T02:00:09.910Z","response_time":99,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["parser","python","science","units","units-measures-converter","units-of-measure"],"created_at":"2024-10-03T17:09:21.132Z","updated_at":"2025-08-07T00:40:15.149Z","avatar_url":"https://github.com/dylanwal.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"# Unit Parse (unit_parse)\n\n---\n---\n![PyPI](https://img.shields.io/pypi/v/unit_parse)\n![tests](https://raw.githubusercontent.com/dylanwal/unit_parse/master/tests/badges/tests-badge.svg)\n![coverage](https://raw.githubusercontent.com/dylanwal/unit_parse/master/tests/badges/coverage-badge.svg)\n![flake8](https://raw.githubusercontent.com/dylanwal/unit_parse/master/tests/badges/flake8-badge.svg)\n![downloads](https://static.pepy.tech/badge/unit_parse)\n![license](https://img.shields.io/github/license/dylanwal/unit_parse)\n\nDo you have strings/text that you want to turn into quantities?\n\nAre you trying to clean scientific data you extracted from [Wikipida](https://en.wikipedia.org/wiki/Main_Page) or some \nother sketchy website?\n\nTry 'Unit_Parse' to clean everything up for you!\n\n#### Description: \n\n'Unit_Parse' is built on top of [Pint](https://github.com/hgrecco/pint). It was specifically designed to handle data \nthat was extracted from scientific work. It has been rigorously tested against chemistry data \nextracted from Wikipida (example: [styrene](https://en.wikipedia.org/wiki/Styrene); density, melting point, boiling \npoint, etc.) and data from [PubChem](https://pubchem.ncbi.nlm.nih.gov/) \n(example: [styrene](https://pubchem.ncbi.nlm.nih.gov/compound/Styrene) ; density, melting point, flash point, etc.).\n\n\n---\n\n## Installation\n\n```\npip install unit_parse\n```\n\n## Dependencies\n\n[Pint](https://github.com/hgrecco/pint) - Provides unit conversions of cleaned and parsed quantities.\n\n---\n---\n\n## Usage\n\n### Basics\n\nPass string you want to parse to `parser()`.\n\n```python\nfrom unit_parse import parser\n\nresult = parser(\"1.23 g/cm3 (at 25 °C)\")\nprint(result) # [[\u003cQuantity(1.23, 'g / cm ** 3')\u003e, \u003cQuantity(25, 'degC')\u003e]]\n```\n'Quantity' are [pint quantities](https://pint.readthedocs.io/en/stable/defining-quantities.html). \n\n### Output structure\n* **Parse unsuccessful**: None\n* **Single value:** quantity\n    * `5 g/mol`\n* **Single value with condition:** [[quantity, condition]]  \n    * `[['25 degC', '1 bar']]`\n    * boil temperature is 25 °C at 1 bar of pressure\n* **Multiple values with conditions:** [[quantity, condition], [quantity, condition], ...]\n    * `[['25 degC', '1 bar'], ['50 degC', '5 bar'], ['100 degC', '10 bar']]`\n\n### Merging Quantities\n\nSometimes when you are doing parsing, you get multiple values from the parser. So it would be nice to reduce it \ndown just to one value/value+condition/series+condition. `reduce_quantities` does exactly that!\n\nIt will group approximate equivalent quantities and throw out bad units (units that are not like the most common). \nYou can select your preference for return priority with the `order` parameter. \n\n```python\nfrom unit_parse import Quantity, reduce_quantities\n  \nquantities = [Quantity(\"68 degF\"), Quantity(\"68.0 degF\"), Quantity(\"20.0 degC\"),\n              Quantity(\"293.15 kelvin * speed_of_light ** 2\")]\n  \nresult = reduce_quantities(quantities)\nprint(result)  # Quantity(\"68 degF\")\n```\n\n---\n---\n## Logging\n\nThe logger can be used to track the parsing steps.\n\nDefault level is warning.\n\nwarning: will only let you know if there is any text that is being ignored in the parsing process.\ninfo: will show the major parsing steps.\ndebug: will show fine grain parsing steps.\n\n### Example: INFO\n\nCode:\n\n```python\nimport logging\n\nfrom unit_parse import parser, logger\n\nlogger.setLevel(logging.INFO)\n\nresult = parser(\"37.34 kJ/mole (at 25 °C)\")\nprint(result)\n```\n\nOutput:\n\n```console\n    INPUT: 37.34 kJ/mole (at 25 °C)\n    substitution: ('37.34 kJ/mole (at 25 °C)',) --\u003e 37.34 kJ/mole ( @ 25 °C)\n    multiple_quantities_main: ('37.34 kJ/mole ( @ 25 °C)',) --\u003e [['37.34 kJ/mole', '', '25 °C']]\n    text_list_to_quantity: ([['37.34 kJ/mole', '', '25 °C']],) --\u003e [[\u003cQuantity(37.34, 'kilojoule / mole')\u003e, \u003cQuantity(25, 'degree_Celsius')\u003e]]\n    remove_duplicates: ([[\u003cQuantity(37.34, 'kilojoule / mole')\u003e, \u003cQuantity(25, 'degree_Celsius')\u003e]],) --\u003e [[\u003cQuantity(37.34, 'kilojoule / mole')\u003e, \u003cQuantity(25, 'degree_Celsius')\u003e]]\n    OUTPUT: [\u003cQuantity(37.34, 'kilojoule / mole')\u003e, \u003cQuantity(25, 'degree_Celsius')\u003e]\n[\u003cQuantity(37.34, 'kilojoule / mole')\u003e, \u003cQuantity(25, 'degree_Celsius')\u003e]\n```\n\n### Example: DEBUG\nCode:\n\n```python\nimport logging\n\nfrom unit_parse import parser, logger\n\nlogger.setLevel(logging.DEBUG)\n\nresult = parser(\"37.34 kJ/mole (at 25 °C)\")\nprint(result) \n```\n\nOutput:\n\n```console\n    INPUT: 37.34 kJ/mole (at 25 °C)\n        sub_general: ('37.34 kJ/mole (at 25 °C)',) --\u003e 37.34 kJ/mole ( @ 25 °C)\n        sub_power: ('37.34 kJ/mole ( @ 25 °C)',) --\u003e 37.34 kJ/mole ( @ 25 °C)\n        sub_sci_notation: ('37.34 kJ/mole ( @ 25 °C)',) --\u003e 37.34 kJ/mole ( @ 25 °C)\n        reduce_ranges: ('37.34 kJ/mole ( @ 25 °C)',) --\u003e 37.34 kJ/mole ( @ 25 °C)\n    substitution: ('37.34 kJ/mole (at 25 °C)',) --\u003e 37.34 kJ/mole ( @ 25 °C)\n        multiple_quantities: ('37.34 kJ/mole ( @ 25 °C)',) --\u003e ['37.34 kJ/mole ( @ 25 °C)']\n        reduce_parenthesis: ('37.34 kJ/mole ( @ 25 °C)',) --\u003e ['37.34 kJ/mole ', ' @ 25 °C']\n        condition_finder: ('37.34 kJ/mole ( @ 25 °C)',) --\u003e ['37.34 kJ/mole', '', '25 °C']\n    multiple_quantities_main: ('37.34 kJ/mole ( @ 25 °C)',) --\u003e [['37.34 kJ/mole', '', '25 °C']]\n        get_quantity_and_cond: (['37.34 kJ/mole', '', '25 °C'],) --\u003e [\u003cQuantity(37.34, 'kilojoule / mole')\u003e, \u003cQuantity(25, 'degree_Celsius')\u003e]\n    text_list_to_quantity: ([['37.34 kJ/mole', '', '25 °C']],) --\u003e [[\u003cQuantity(37.34, 'kilojoule / mole')\u003e, \u003cQuantity(25, 'degree_Celsius')\u003e]]\n    remove_duplicates: ([[\u003cQuantity(37.34, 'kilojoule / mole')\u003e, \u003cQuantity(25, 'degree_Celsius')\u003e]],) --\u003e [[\u003cQuantity(37.34, 'kilojoule / mole')\u003e, \u003cQuantity(25, 'degree_Celsius')\u003e]]\n    OUTPUT: [\u003cQuantity(37.34, 'kilojoule / mole')\u003e, \u003cQuantity(25, 'degree_Celsius')\u003e]\n[\u003cQuantity(37.34, 'kilojoule / mole')\u003e, \u003cQuantity(25, 'degree_Celsius')\u003e]\n```\n\n---\n---\n## Examples\n\nYep, there's alot of them! \n\n```python\n# Simple conversions\n    5 --\u003e 5\n    5 g --\u003e 5 g\n    5 g/ml --\u003e 5.0 g / ml\n    1 K --\u003e 1 K\n    40 °F --\u003e 40 °F\n    -40 °F --\u003e -40 °F\n    170°C --\u003e 170 °C\n    40°F --\u003e 40 °F\n    20.80 mmHg --\u003e 20.8 mmHg\n    20.80 mm Hg --\u003e 20.8 mmHg\n# scientific notation\n    15*10**2 s --\u003e 1500 s\n    15*10^2 s --\u003e 1500 s\n    15 10**2 s --\u003e 1500 s\n    8.20x10**+1 ppm --\u003e 82.0 ppm\n    8.20x10+1 ppm --\u003e 82.0 ppm\n    5e1 g/mol --\u003e 50.0 g / mol\n    5E1 g/mol --\u003e 50.0 g / mol\n    5 e1 g/mol --\u003e 50.0 g / mol\n    5 E1 g/mol --\u003e 50.0 g / mol\n    5e+1 g/mol --\u003e 50.0 g / mol\n    5E-1 g/mol --\u003e 0.5 g / mol\n    −66.11·10-62 ml/mol --\u003e -6.611e-61 ml / mol\n    −66.11·10+62 ml/mol --\u003e -6.611e+63 ml / mol\n    −66.11·1062 ml/mol --\u003e -6.611e+63 ml / mol\n# messed up units/ units with powers\n    2.3 gcm --\u003e 2.3 cm * g\n    5e5 gmol/s --\u003e 500000.0 g * mol / s\n    2.3 gcm**3 --\u003e 2.3 cm**3 * g\n    2.3 gcm**3 --\u003e 2.3 cm**3 * g\n    2.3     g --\u003e 2.3 g\n    1.10*10**-05 atm-m**3/mole --\u003e 1.1000000000000001e-05 atm * m**3 / mol\n    -54.6e-5 atm-m**3/mole --\u003e -0.000546 atm * m**3 / mol\n    2.3 mlgcm --\u003e 2.3 cm * g * ml\n    42.3 gcm-3 --\u003e 42.3 g / cm**3\n    42.3 g cm-3 --\u003e 42.3 g / cm**3\n    −66.11·10-62 cm3/mol --\u003e -6.611e-61 cm**3 / mol\n    −66.11·10+62 cm3/mol --\u003e -6.611000000000001e+63 cm**3 / mol\n    −66.11·1062 cm3/mol --\u003e -6.611000000000001e+63 cm**3 / mol\n    345.234 KCAL/MOLE --\u003e 345.234 kcal / mol\n# parenthesis (brackets turn into parenthesis)\n    (4.0 °C) --\u003e 4.0 °C\n    [4.0 °C] --\u003e 4.0 °C\n    4.0 (°C) --\u003e 4.0 °C\n    4.0 (°C)) --\u003e 4.0 °C\n    )4.0 (°C) --\u003e 4.0 °C\n    (4.0 (°C) --\u003e 4.0 °C\n    ()4.0 (°C) --\u003e 4.0 °C\n    4.0 °C [39.2 g/[mol * s]] --\u003e [[\u003cQuantity(4.0, 'degree_Celsius')\u003e, \u003cQuantity(39.2, 'gram / mole / second')\u003e]]\n    1.0722 at 68 °F (EPA, 1998) --\u003e [[1.0722, \u003cQuantity(68, 'degree_Fahrenheit')\u003e]]\n# conditions\n    37.34 kJ/mole (at 25 °C) --\u003e [[\u003cQuantity(37.34, 'kilojoule / mole')\u003e, \u003cQuantity(25, 'degree_Celsius')\u003e]]\n    20.8 mm Hg @ 25 °C --\u003e [[\u003cQuantity(20.8, 'millimeter_Hg')\u003e, \u003cQuantity(25, 'degree_Celsius')\u003e]]\n    20.8 mm Hg (25 °C) --\u003e [[\u003cQuantity(20.8, 'millimeter_Hg')\u003e, \u003cQuantity(25, 'degree_Celsius')\u003e]]\n    20.8 mm Hg at 25 °C --\u003e [[\u003cQuantity(20.8, 'millimeter_Hg')\u003e, \u003cQuantity(25, 'degree_Celsius')\u003e]]\n    -4,395.63 kJ/mol at 25 °C --\u003e [[\u003cQuantity(-4395.63, 'kilojoule / mole')\u003e, \u003cQuantity(25, 'degree_Celsius')\u003e]]\n# list of quantities\n    18 mm Hg; 20 mm Hg --\u003e 20 mmHg\n    18 mm Hg @ 68 °F; 20 mm Hg @ 77° F --\u003e [[\u003cQuantity(18, 'millimeter_Hg')\u003e, \u003cQuantity(68, 'degree_Fahrenheit')\u003e], [\u003cQuantity(20, 'millimeter_Hg')\u003e, \u003cQuantity(77, 'degree_Fahrenheit')\u003e]]\n    18 mm Hg @ 68 °F ; 20 mm Hg @ 77° F (NTP, 1992) --\u003e [[\u003cQuantity(18, 'millimeter_Hg')\u003e, \u003cQuantity(68, 'degree_Fahrenheit')\u003e], [\u003cQuantity(20, 'millimeter_Hg')\u003e, \u003cQuantity(77, 'degree_Fahrenheit')\u003e]]\n    18 mm Hg at 68 °F ; 20 mm Hg at 77 °F --\u003e [[\u003cQuantity(18, 'millimeter_Hg')\u003e, \u003cQuantity(68, 'degree_Fahrenheit')\u003e], [\u003cQuantity(20, 'millimeter_Hg')\u003e, \u003cQuantity(77, 'degree_Fahrenheit')\u003e]]\n    Low threshold= 13.1150 mg/cu m; High threshold= 26840 mg/cu m; Irritating concn= 22875 mg/cu m. --\u003e 22875.0 mg / m**3\n# ranges\n    115.2-115.3 °C --\u003e 115.2 °C\n    115.2 - 115.3 °C --\u003e 115.2 °C\n    15 ± 5 ºC --\u003e 15 °C\n    Between 10 and 20 ºC --\u003e 10 °C\n# words\n    8.20x10+1 ppm; pure --\u003e 82.0 ppm\n    40 °F (NTP, 1992) --\u003e 40 °F\n    4.0 °C (39.2 °F) - closed cup --\u003e 4.0 °C\n    4.0 °C [39.2 g/[mol * s]] - closed cup --\u003e [[\u003cQuantity(4.0, 'degree_Celsius')\u003e, \u003cQuantity(39.2, 'gram / mole / second')\u003e]]\n    4.0 °C [39.2 g/[mol * s] approx.] - closed cup --\u003e [[\u003cQuantity(4.0, 'degree_Celsius')\u003e, \u003cQuantity(39.2, 'gram / mole / second')\u003e]]\n    4.0 °C [39.2g/[mol*s] approx.] - closed cup --\u003e [[\u003cQuantity(4.0, 'degree_Celsius')\u003e, \u003cQuantity(39.2, 'gram / mole / second')\u003e]]\n    4.0 °C [39.2g/[mol*s]approx.] - closed cup --\u003e [[\u003cQuantity(4.0, 'degree_Celsius')\u003e, \u003cQuantity(39.2, 'gram / mole / second')\u003e]]\n    Detection in water: 0.73 ppm; Chemically pure --\u003e 0.73 ppm\n    Odor Threshold Range: 0.15 to 25 ppm --\u003e 0.15 ppm\n    0.05 ppm purity specified --\u003e 0.05 ppm\n    Odor detection in air, 0.05 ppm (purity not specified) --\u003e 0.05 ppm\n    Relative density (water = 1): 1.04-1.13 --\u003e 1.04\n    Density approximately 6.5 lb / gal. --\u003e 6.5 lb / gal\n# duplicates of same quantity different units\n    4.0 °C (39.2 °F) --\u003e 4.0 °C\n    -7991 cal/g = -334.6X10+5 J/KG --\u003e -33460000.000000004 J / kg\n# complex\n    18 mm Hg at 68 °F ; 20 mm Hg at 77° F (NTP, 1992) --\u003e [[\u003cQuantity(18, 'millimeter_Hg')\u003e, \u003cQuantity(68, 'degree_Fahrenheit')\u003e], [\u003cQuantity(20, 'millimeter_Hg')\u003e, \u003cQuantity(77, 'degree_Fahrenheit')\u003e]]\n    Sound travels at 0.34 km/s --\u003e 0.34 km / s\n    Pass me a 300 ml beer. --\u003e 300 ml\n```\n\n\nStuff it gets wrong. No one is perfect!\n```python\nIndex of refraction: 1.50920 @ 20 °C/D --\u003e [[1.5092, \u003cQuantity(293.15, 'kelvin / debye')\u003e]]\nVapor pressure, kPa at 20 °C: 2.0 --\u003e 2.0\nSpecific optical rotation @ 15 °C/D + 230 deg (concn by volume = 1.8 in chloroform) --\u003e 1.8\n10-20 ºC --\u003e 1e-20 °C   # range interpreted as scientific notation if first number is 10\n```\n\n---\n---\n## Configuration\n\nThe parser has a few configurations exposed to make it easy to modify how the works.\n\n### Remove words\n\nText you want removed prior to parsing. \n\nDefault is None. (Note: the parser naturally takes care of alot of 'bad' text)\n\n```python\nimport unit_parse\n\nremove_words = [\"approx.\", \"roughly\", \"close to\"]\nunit_parse.config.remove_text = remove_words\n\nresult = unit_parse.parser(\"approx. 100 grams\")\nprint(result)  # Quantity(\"100 gram\")\n```\n\n### Pre-Processing Substitutions\n\nText you want to replace with another. \n\nDefault there is a big list. Regex or text is accepted.\n\n**Defaults:**\n```python\npre_proc_sub = [\n  # [pattern, substitution value]\n  [\"^[a-zA-Z;,.: /]*\", \"\"],  # remove text at front of strings\n  [\"(?\u003c=[^a-zA-Z])at([^a-zA-Z])\", \" @ \"],  # replace at with @\n  [\"−\", \"-\"],  # unify dash (long, short) symbols\n  [\"·\", \"*\"],  # unify multiplication symbols\n  [\"° F\", \" °F\"],  # pint gets confused (degree farad)\n  [\"° C\", \" °C\"],  # pint gets confused\n  [\"°F\", \"degF\"],  # eliminates issue with capitalization step\n  [\"°C\", \"degC\"],  # eliminates issue with capitalization step\n  [\"(?\u003c=[0-9]{1})[ ]{0,1}X[ ]{0,1}(?=[0-9]{1})\", \"*\"],  # unify multiplication symbols\n  [\"(?\u003c=[0-9]{1})[ ]{0,1}x[ ]{0,1}(?=[0-9]{1})\", \"*\"],  # unify multiplication symbols\n  [\"\\[\", \"(\"],  # make all brackets parenthesis\n  [\"\\]\", \")\"],  # make all brackets parenthesis\n  [\"^.*={1}\", \"\"],  # delete everything in front of equal\n  [\"^.*:{1}\", \"\"],  # delete everything in front of collen\n  [\"( to )\", \"-\"],   # unify how range are represented\n  [\"(?\u003c=[a-zA-Z])-(?=[a-zA-Z])\", \" \"],  # turn dashes between text into spaces so dictionary can remove\n  [\"mm Hg\", \"mmHg\"],  # pint gets confused\n  [\"KG\", \"kg\"],  # pint gets confused\n  [\"LB\", \"lb\"],  # pint gets confused\n  [\"kpa\", \"kPa\"],  # pint gets confused\n  [\"cu ft\", \"ft**3\"],  # pint gets confused\n  [\"cu in\", \"in**3\"],  # pint gets confused\n  [\"cu m\", \"m**3\"],  # pint gets confused\n  [\"cu cm\", \"cm**3\"],  # pint gets confused\n  [\"cu mm\", \"mm**3\"],  # pint gets confused\n]\n```\n\n\n```python\nimport unit_parse\n\nmore_pre_processing = [[\"MOL\", \"mol\"]] # [bad text/regex, new text]\nunit_parse.config.pre_proc_sub += more_pre_processing  # Here we are adding to the existing list\n\nresult = unit_parse.parser(\"100 MOL\")  # pint is case-sensitive, so this will result in an invalid unit\nprint(result)  # Quantity(\"100 mole\")\n```\n\n### Last Minute Substitutions\n\nText you want to replace with another, but happens at the very last stage before trying to convert to a unit. You \nshould try to use pre-substitutions first, but there can be some situations where you want to do substitutions at a \nsemi-parsed quantity.  \n\nDefault there is a big list. Regex or text is accepted.\n\n**Defaults:**\n```python\nlast_minute_sub = [\n  # [pattern, substitution value]\n  [\"-{1}[^0-9]*$\", \"\"],  # remove trailing dash\n  [\"(?\u003c=[a-zA-Z0-9]) {1,2}[0-9()]{2,5}\", \"\"]  # remove trailing number  ex. 90 g/mol 1999 -\u003e  90 g/mol\n]\n```\n\n\n```python\nimport unit_parse\n        \nmore_last_minute_sub = [[\"MOL\", \"mol\"]] # [bad text/regex, new text]\nunit_parse.config.last_minute_sub += more_last_minute_sub # Here we are adding to the existing list\n\nresult = unit_parse.parser(\"100 MOL\")  # pint is case-sensitive, so this will result in an invalid unit\nprint(result)  # Quantity(\"100 mole\")\n```\n\n---\n---\n\n## Notes\n\n### Pint UnitRegistry\n\nPint's requires a Unit Registry to be defined. However, Unit Registries are not interoperable and will throw\nerrors if a unit from one registry is used in another. Unit_Parse will go looking to see if one has been created,\nand if it hasn't we will make one!\n\nSo if your project uses Pint already, make sure you import Pint and define the `UnitRegistry` before\nimporting `unit_parse`. You must also define `Unit` and `Quantity` to make the registry discoverable.\n\n```python\nimport pint\n\nu = pint.UnitRegistry()\nU = Unit = u.Unit\nQ = Quantity = u.Quantity\n\nfrom unit_parse import parser\n\n# your code from here…\n```\n    \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdylanwal%2Funit_parse","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdylanwal%2Funit_parse","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdylanwal%2Funit_parse/lists"}