Registry / ai-ml / quantulum3

quantulum3

JSON →
library0.10.0pypypi✓ verified 87d ago

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.

pip install quantulum3
INSTALL
IMPORT
SIG · QUANTULUM3
Q
quantulum3
ai-mlpythonv0.10.0
Install
8.3s avg
Import
2603ms
Disk
44MB
Pass rate
5/ 10
Env Coverage5 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.10.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
glibc
py 3.10
4/8 runs
✓ 7.13s
py 3.11
4/8 runs
✓ 7.28s
py 3.12
4/8 runs
✓ 9.68s
py 3.13
4/8 runs
✓ 8.94s
py 3.9
4/8 runs
✓ 8.46s
44MB installed
● package 44MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

parser
from quantulum3 import parser
from quantulum import parser
quantulum is the Python 2 version; quantulum3 is for Python 3.
Quantity
from quantulum3.classes import Quantity
While directly importable, Quantity objects are usually returned by parser.parse().

Demonstrates how to parse a string for quantities and access their attributes. It also shows the inline parsing utility.

from quantulum3 import parser text = 'I want 2 liters of wine and 10 million dollars.' quants = parser.parse(text) for q in quants: print(f"Value: {q.value}, Unit: {q.unit.name}, Surface: '{q.surface}', Span: {q.span}") # Example of inline parsing inline_text = parser.inline_parse(text) print(f"\nInline parsed text: {inline_text}")
Debug
Known issues
breakingUsers 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.
fix
Always use `pip install quantulum3` and `from quantulum3 import parser` for Python 3 projects.
affects: <=0.9.2 (quantulum) vs >=0.1.0 (quantulum3)
gotchaThe 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`.
fix
Install with `pip install quantulum3[classifier]` to enable the full classifier functionality.
affects: All versions
gotchaThe 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.
fix
For extracting properties of a specific unit string, prepend a numerical value like '1 ' to the string, e.g., `parser.parse('1 meter')`.
affects: All versions
gotchaOlder 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.
fix
Ensure quantulum3 is updated to the latest version. If persistent, check package integrity and Python environment paths.
affects: <0.5.0 (fixed in later versions)
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'quantulum'
Attempting to import the Python 2 version 'quantulum' in a Python 3 environment, or after installing 'quantulum3' but trying to import the old name.
fix
Install `quantulum3` using `pip install quantulum3` and import with `from quantulum3 import parser`.
[] (empty list returned) when parsing a single unit word.
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.
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.
FileNotFoundError: [Errno 2] No such file or directory: '.../quantulum3/common-4-letter-words.txt'
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.
fix
Upgrade to the latest `quantulum3` version (`pip install --upgrade quantulum3`). If the problem persists, try reinstalling in a clean virtual environment.
Upgrade
Version history
0.10.0latest on PyPI · released Mar 9, 2026
Audit
Dependencies
inflectrequiredCore dependency for linguistic transformations (e.g., plurals, ordinals).
num2wordsrequiredCore dependency for converting numbers to words.
scikit-learnoptionalRequired for the unit disambiguation classifier functionality.
pymagnitudeoptionalRequired for training the disambiguation classifier and extracting nearest neighbors for units.
Agent activity
12 hits · last 30 days
node
10
OpenAI (training)
1
Resources
quantulum3 — pip install quantulum3 · libregistry