quantulum3

0.10.0 · active · verified Thu Apr 16

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.

Common errors

Warnings

Install

Imports

Quickstart

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}")

view raw JSON →