Amounts¶
V2.1AMOUNTS stores numeric quantities with an object description and offset. analyze_amounts works independently of event counts and needs no model or downloaded dictionary.
Requirements¶
Core package only. No external dictionary or NLP model is required.
Example¶
from gdelt_regkg.fields.amounts import analyze_amounts
text = "We sent twenty-five boxes and spent $1.25 million."
print(analyze_amounts(text).to_gkg())
result = analyze_amounts(text)
assert str(result.mentions[0].amount) == "25"
Behavior¶
Entries are amount,object,offset, separated by ;. Offsets point to the numeric span in the analyzed body. analyze_amounts retains original spans and Decimal values.
Recognizes Western comma grouping, decimals, signed values, English number words through trillions, magnitude suffixes such as 25m/2bn, and $, €, £, ₹, USD, EUR, GBP and INR prefixes. Currency prefixes become object names. Other objects use up to three following words, stopping at common verbs, prepositions and punctuation. Missing objects stay empty.
Percentages, date spans and common version/time/fraction forms are excluded. Repeated quantities are separate. No accepted amounts produces "".
Options¶
Pass numeric_order="mdy" or "dmy" to control slash-date exclusion consistently with the date extractor. The generator uses numeric_date_order= for both fields.
Limitations¶
Indefinite quantities such as “hundreds of boxes” receive no exact value. European decimal commas, scientific notation and grammatical object attachment are unsupported. The bounded object description can include an unrelated word or miss a distant object.