Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

...

The following code demonstrates how to specify a basic association (Note: The sample event specification and sample event output below is extracted from a sample MySql Database Source the full content of which can be viewed here.):

Code Block
titleBasic Event Specification Example
{
    //...
    "associations" : [
      {
        "entity1" : "$metadata.offense,$metadata.method",
        "verb" : "reported",
        "verb_category" : "crime",
        "time_start" : "$metadata.reportdatetime", 
        "geo_index" : "Location",
        "geotag" : {
           "lat" : "$metadata.latitude",
           "lon" : "$metadata.longitude"}
      },
    ],
    //...
}

...

  • event_type
    "Event", "Fact", "Summary"
    The "assoc_type" field sub-categorizes the "event" object into one of three types, "Event", "Fact", or "Summary". Examples provided below should make the distinction clearer, but it can be simply described as follows:
    • "Event": link multiple entities (via "entity1_index", "entity2_index", "geo_index") and represent a transient activity (eg travel)
    • "Fact": link multiple entities like "Events" but represent (transient or permanent) relationships (eg being president)
    • "Summary": generally link 1 entity to a free text (eg a quotation: "Obama says...").
Specifying Additive Events

...

Specifying Multiplicative Associations

Multiplicative association are associations that are created by "multiplying" a combination of entities, locations, and times together to determine the number of associations to extract from the source data. For example, in the following sample document describing a terrorist attack one terrorist (perpetrator) attacked two different types of victims (police officers and military personnel) in Sri Lanka. The association specification uses the multiplicative format to create events using the following math to determine the total number of associations: Entity1 (PersonPerpetrator) X * Entity2 (VictimType) X * Geo_index (Location) = Total Number of Associations.

...

Info

Association fields generated from the entity loop are placed in "_iterator". For example, for "iterateOver": "entity1/entity2/geo_index", an _iterator object with the following fields is available in the Javascript: "_iterator.entity1_index", "_iterator.entity2_index", "_iterator.geo_index".

These fields can be usefully used together with "creationCriteriaScript" scriptlets to filter out unwanted associations, eg when looping over entity1 and entity2 with the same entity type, the following script would ensure the association didn't involve the same entity:

"creationCriteriaScript": "$SCRIPT( return _iterator.entity1_index != _iterator.entity2_index; )", "iterateOver": "entity1/entity2", "entity1": "EmailAddress", "entity2": "EmailAddress", //etc

The creationCriteriaScript runs before the association is generated (so can be safely used to remove items that would return errors).

In the example source below there are four entities that are being shown: one location entity, two victim entities, and one perpetrator entity. These visible entities are the entities referenced in the example specification above.

...

Code Block
titleMultiplicative Event Output Example
{
    //...
    "associations" : [
        {
           "entity1" : "secular/political/anarchist from sri lanka",
           "entity1_index" : "secular/political/anarchist from sri lanka/personperpetrator",
           "verb" : "attacked",
           "verb_category" : "assault/attack",
           "entity2" : "targeted, police, adult from sri lanka",
           "entity2_index" : "targeted, police, adult from sri lanka/victimtype",
           "time_start" : "09/07/2005",
           "geotag" : {
                "lat" : "7.7166667",
                "lon" : "81.7"
           },
           "geo_index" : "batticaloa,north eastern province,sri lanka/location",
           "assoc_type" : "Event"
        },
        {
           "entity1" : "secular/political/anarchist from sri lanka",
           "entity1_index" : "secular/political/anarchist from sri lanka/personperpetrator",
           "verb" : "attacked",
           "verb_category" : "assault/attack",
           "entity2" : "targeted, military, adult, combatant from sri lanka",
           "entity2_index" : "targeted, military, adult, combatant from sri lanka/victimtype",
           "time_start" : "09/07/2005",
           "geotag" : {
                "lat" : "7.7166667",
                "lon" : "81.7"
           },
           "geo_index" : "batticaloa,north eastern province,sri lanka/location",
           "assoc_type" : "Event"
        }
    ],
    //...
}
Info
  • If the "iterateOver" field contains neither "," or "/" ("," is for additive associations, see below) then it is treated as an iterator over a metadata field, just as described under Specifying Entities, section "Create Entities from Arrays of Items".
  • To iterate just over a single entity type, use "dummy", eg "entity1/dummy" or "entity2,dummy" (The '/' vs ',' are equivalent in this case).
Specifying Additive Associations

Additive associations cover the less common case where (eg) 2 entity types have the same number of elements and are ordered "in lock step". For example:

Code Block
"entities": [
	{ "index": "alex/person", ... },
	{ "index": "craig/person", ... },
	{ "index": "baltimore/city", ... },
	{ "index": "washington dc/city", ...},
	...
]

In this case the additive association specification:

Code Block
{
	"iterateOver": "entity1,entity2", // note "," instead of "/"
	"entity1": "Person",
	"entity2": "City",
	"verb_category": "lives in",
	...
}

Would generate the 2 associations "alex/person lives in baltimore/city" and "craig/person lives in washintgon dc/city".

Further Reading