<jupyter_start><jupyter_text>Working with strings*A quantity can be created from a string expression, but not all libraries understand the same syntaxis and vocabulary*Some python libraries to work with physical quantities, as pint, are very efficient parsing strings. And some other probably not. And in addition, it is probable that not all of them use the samy syntaxis. With PyUnitWizard a unique parser and syntaxis can be used not matter the desired form of the quantity. Let's show how the methods `pyunitwizard.string_to_quantity()` and `pyunitwizard.string_to_unit()` work:<jupyter_code>import pyunitwizard as puw
puw.configure.load_library(['pint', 'simtk.unit'])
puw.configure.set_default_form('simtk.unit')
puw.quantity('(2 litres + 20 dL)/second')
puw.convert('2 newtons per square meter', parser='pint')
puw.quantity('1.5 kcal / mole', parser='pint', form='pint')
puw.convert('kelvin**(-1)', parser='pint', to_form='pint')<jupyter_output><empty_output><jupyter_text>And the inverse translation can be performed:<jupyter_code>q = puw.convert('2 newtons per square meter', parser='pint', to_form='simtk.unit')
puw.convert(q, to_form='string')
u = puw.convert('kelvin**(-1)', to_type='unit')
u
puw.convert(u, to_form='string')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.122336227308603, 'fraction_numerical': 0.007103393843725336, 'mean_word_length': 7.076433121019108, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '173906', 'license': 'MIT', 'n_tokens_mistral': 412, 'n_tokens_neox': 397, 'n_words': 127, 'path': 'docs/contents/Strings.ipynb', 'repo_name': 'uibcdf/PyUnitWizard', 'size': '1267'}