Enhanced counts¶
V2.1COUNTS uses the same extraction as Counts, with a zero-based character offset for the quantity.
Requirements¶
Core package only. Count geography additionally requires an English NER model and a prepared geographic reference.
Example¶
from gdelt_regkg.fields.counts import analyze_counts
from gdelt_regkg.fields.locations import analyze_locations
from gdelt_regkg.fields.ner import SpacyNER
from gdelt_regkg.fields.ner import analyze_entities
ner = SpacyNER.from_model("en_core_web_sm", name_policy="surface")
text = "Volunteers rescued 12 people in Paris, France."
entities = analyze_entities(text, recognizer=ner)
resolved = analyze_locations(text, ner=entities)
result = analyze_counts(text, locations=resolved.count_locations)
print(result.to_gkg(enhanced=True))
assert text[result.mentions[0].start : result.mentions[0].start + 2] == "12"
CRISISLEX_T08_MISSINGFOUNDTRAPPEDPEOPLE#12#people#4#Paris, France (General), France#FR#FR00#48.8667#2.33333#-1456928#19;
Behavior¶
Entries have the ten standard count components followed by the number offset, separated by # and terminated with ;. No ADM2 component is added.
Use analyze_counts(text).to_gkg(enhanced=True) when sharing one analysis across both count fields. Rules, geography and rejected-match diagnostics are the same as for standard counts. After translation, offsets refer to the analyzed English body.
Limitations¶
The extraction limitations are the same as for counts. After translation, offsets refer to the analyzed English body.