{"id":8575,"library":"quantulum3","title":"quantulum3","description":"quantulum3 is an actively maintained Python library (v0.10.0) designed for the robust extraction of quantities, measurements, and their associated units from unstructured text. It leverages machine learning, specifically k-nearest neighbors on GloVe vector representations, to disambiguate between similar-looking units, ensuring accurate information retrieval. The project is a Python 3 compatible fork of earlier versions and continues to evolve with ongoing development and community contributions.","status":"active","version":"0.10.0","language":"en","source_language":"en","source_url":"https://github.com/nielstron/quantulum3","tags":["nlp","quantities","units","text-extraction","measurements","information-extraction"],"install":[{"cmd":"pip install quantulum3","lang":"bash","label":"Base Installation"},{"cmd":"pip install quantulum3[classifier]","lang":"bash","label":"With Classifier Dependencies"}],"dependencies":[{"reason":"Core dependency for linguistic transformations (e.g., plurals, ordinals).","package":"inflect","optional":false},{"reason":"Core dependency for converting numbers to words.","package":"num2words","optional":false},{"reason":"Required for the unit disambiguation classifier functionality.","package":"scikit-learn","optional":true},{"reason":"Required for training the disambiguation classifier and extracting nearest neighbors for units.","package":"pymagnitude","optional":true}],"imports":[{"note":"quantulum is the Python 2 version; quantulum3 is for Python 3.","wrong":"from quantulum import parser","symbol":"parser","correct":"from quantulum3 import parser"},{"note":"While directly importable, Quantity objects are usually returned by parser.parse().","symbol":"Quantity","correct":"from quantulum3.classes import Quantity"}],"quickstart":{"code":"from quantulum3 import parser\n\ntext = 'I want 2 liters of wine and 10 million dollars.'\nquants = parser.parse(text)\n\nfor q in quants:\n    print(f\"Value: {q.value}, Unit: {q.unit.name}, Surface: '{q.surface}', Span: {q.span}\")\n\n# Example of inline parsing\ninline_text = parser.inline_parse(text)\nprint(f\"\\nInline parsed text: {inline_text}\")","lang":"python","description":"Demonstrates how to parse a string for quantities and access their attributes. It also shows the inline parsing utility."},"warnings":[{"fix":"Always use `pip install quantulum3` and `from quantulum3 import parser` for Python 3 projects.","message":"Users migrating from the older 'quantulum' library (Python 2) to Python 3 must install 'quantulum3'. Attempting to import 'quantulum' in a Python 3 environment will result in a ModuleNotFoundError or unexpected behavior.","severity":"breaking","affected_versions":"<=0.9.2 (quantulum) vs >=0.1.0 (quantulum3)"},{"fix":"Install with `pip install quantulum3[classifier]` to enable the full classifier functionality.","message":"The unit disambiguation classifier, which improves accuracy for ambiguous units, requires additional dependencies (e.g., scikit-learn). These are not installed by default with `pip install quantulum3`.","severity":"gotcha","affected_versions":"All versions"},{"fix":"For extracting properties of a specific unit string, prepend a numerical value like '1 ' to the string, e.g., `parser.parse('1 meter')`.","message":"The parser often fails to extract standalone unit names without a preceding numerical value, returning an empty list. E.g., `parser.parse('meter')` will yield no results.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Ensure quantulum3 is updated to the latest version. If persistent, check package integrity and Python environment paths.","message":"Older versions of quantulum3 (prior to a fix in 2018) occasionally had FileNotFoundError issues related to internal data files like 'common-4-letter-words.txt', particularly in non-standard installation environments.","severity":"gotcha","affected_versions":"<0.5.0 (fixed in later versions)"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Install `quantulum3` using `pip install quantulum3` and import with `from quantulum3 import parser`.","cause":"Attempting to import the Python 2 version 'quantulum' in a Python 3 environment, or after installing 'quantulum3' but trying to import the old name.","error":"ModuleNotFoundError: No module named 'quantulum'"},{"fix":"If you need to get unit information for a standalone word, consider prepending a number, e.g., `parser.parse('1 meter')`, then extract the unit from the resulting Quantity object.","cause":"The `parser.parse()` function is designed to extract quantities (number + unit). It typically requires a numerical value to identify a quantity, even if spelled out.","error":"[] (empty list returned) when parsing a single unit word."},{"fix":"Upgrade to the latest `quantulum3` version (`pip install --upgrade quantulum3`). If the problem persists, try reinstalling in a clean virtual environment.","cause":"This error, though largely fixed in newer versions, indicates that an internal data file expected by quantulum3 could not be located. This might stem from an incomplete installation or environment issues.","error":"FileNotFoundError: [Errno 2] No such file or directory: '.../quantulum3/common-4-letter-words.txt'"}]}