Enhanced themes¶
V2ENHANCEDTHEMES uses the same matcher as Themes, retaining the offset of every matched phrase.
Requirements¶
Prepare the field's dictionaries using Build resources. Models and additional dependencies are needed only for the selected workflow.
Example¶
from gdelt_regkg.fields.themes import analyze_themes
text = "Heavy rain caused flooding."
print(analyze_themes(text).to_gkg(enhanced=True))
result = analyze_themes(text)
assert text[result.mentions[0].start : result.mentions[0].end] == "flooding"
Behavior¶
Each mention is written as CODE,offset;. Offsets are zero-based character positions in the analyzed body. Repeated and overlapping phrase hits are separate. Several labels can share an offset.
Use analyze_themes(text).to_gkg(enhanced=True) to reuse one analysis for both fields. Context conditions and label coverage are the same as for standard themes. After translation, offsets refer to the English body.
Limitations¶
The extraction limitations are the same as for themes. After translation, offsets refer to the analyzed English body.