Skip to content

Latest commit

 

History

History
271 lines (213 loc) · 24.7 KB

JSON pattern.md

File metadata and controls

271 lines (213 loc) · 24.7 KB

V1 Patterns - JSON-based Representation

V1 pattern element types

JSON name V1 pattern element type visual representation
Start Pattern Start V1
Concrete Concrete Entity V1
Typed Typed Entity V1
Untyped Untyped Entity V1
Rel Relationship V1
EExpr Entity's Expression V1
RExpr   Relationship's Expression V1
Quant Quantifier V1
Comb Combiner V1
Path Path V1
PathSeg Path Segment V1
HQuant Horizontal Quantifier V1
HComb Horizontal Combiner V1
A1   A1 Aggregator V1
A2   A2 Aggregator V1
A3   A3 Aggregator V1
M1   M1 Aggregator V1
M2   M2 Aggregator V1
M3   M3 Aggregator V1
R1   R1 Aggregator V1

Wrappers (for Rel / Path / Quant)

X - Negator V1 N - relationship/path negator V1 O - Optional V1

JSON structure

Mandatory Name Type Description
+ schema string Schema name
+ name string Pattern name
+ elements [...] Elements composing the pattern
nonidentical [...] nonidenticality constraints between entity tags
order [...] order constraints between entity tags

JSON fields: for each pattern element:

Mandatory Name Type Description
+ elNum int Element number. Distinct value for each pattern element
+       type     string Element type (e.g. "Start", "Concrete", "Quant")

Additional JSON fields for pattern elements:

Pattern Start (type = "Start")

There must be a single element with type "Start". Its elNum must be 0.

Mandatory Name Type Description
+ next int elNum of next element.
Valid element types: Concrete, Typed, Untyped, Quant
      chained int elNum of chained element.
Valid element types: A1, A3, M1, M3

Concrete Entity (type = "Concrete")

Mandatory Name Type Description
+       eTag   string entity tag (e.g. "A")
+ eID string Technical ID of the entity
+       eType   int Entity type (e.g. of 'Person')
According to the schema (eType)
+ eName string Cached display name of the entity (e.g. "Brandon Stark"). This was the display name when the pattern was stored
expLatent bool true if explicit latent (default: false)
      next   int elNum of next element.
Valid element types: Rel, EExpr, Quant, Path

Typed Entity (type = "Typed")

Mandatory Name Type Description
+       eTag   string entity tag (e.g. "A")
+       eType   int Entity type (e.g. of 'Person')
According to the schema (eType) / 0 (null entity type)
expLatent bool true if explicit latent (default: false)
      next   int elNum of next element.
Valid element types: Rel, EExpr, Quant, Path

Untyped Entity (type = "Untyped")

Mandatory Name Type Description
+       eTag   string entity tag (e.g. "A")
      ett   int entity type tag to assign (unique positive integer)
valid bool true if etts and eTypes are lists of valid types, false if lists of invalid types (default: true)
      etts [int] non-empty list of entity type tags
      eTypes [int] non-empty list of entity types. According to the schema (eType) / 0 (null entity type)
expLatent bool true if explicit latent (default: false)
      next   int elNum of next element.
Valid element types: Rel, EExpr, Quant, Path

Relationship (type = "Rel")

Mandatory Name Type Description
      rType   int Relationship type (e.g. of 'own')
According to the schema (rType)
either rType or [rtt] [valid] [rtts] [rTypes]
      rtt   int relationship type tag to assign (unique positive integer)
+ dir string "-": non-directional, "O": Outgoing to next element, "I": Incoming from next element
valid bool true if rtts and rTypes are lists of valid types, false if lists of invalid types (default: true)
      rtts [int] non-empty list of relationship type tags
      rTypes [int] non-empty list of relationship types. According to the schema (rType)
wrapper string valid wrappers: X,N,XN,O,ON
+       next   int elNum of next element.
Valid element types: Concrete, Typed, Untyped, Comb
        chained   int   elNum of chained element.
Valid element types:
  • RExpr
  • HQuant
  • A1 (Rel wrappers: O,N,ON)
  • A2 (Rel wrappers: O)
  • A3 (Rel wrappers: O,N,ON)
  • M1 (Rel wrappers: O,N,ON)
  • M2 (Rel wrappers: O)
  • M3 (Rel wrappers: O,N,ON)
  • R1 (Rel wrappers: O)

Entity's Expression (type = "EExpr")

Mandatory Name Type Description
+       EAtag   int EA tag to assign (unique positive integer)
+       expr     string Entity's expression.
Property types are according to the schema (pType)
for untyped entity: property types should be valid for all valid (implicitly and explicitly) entity types
con {...} Constraint
op: string - Constraint operator ("=" / "≠" / "∈" / "∉" / ... / "is null" / "not null")
When op ≠ "is null" and op ≠ "not null":
- expr: string - Constraint expression
- null: bool - how to evaluate the constraint when the expression is evaluated to null (default: false - the constraint is not satisfied)

Relationship's Expression (type = "RExpr")

Mandatory Name Type Description
+       EAtag int EA tag to assign (unique positive integer)
+       expr   string Relationship's Expression.
Property types are according to the schema (pType) (e.g. "$(1).$(.2)" for "tf.till" of "member of")
con {...} Constraint
op: string - Constraint operator ("=" / "≠" / "∈" / "∉" / ... / "is null" / "not null")
When op ≠ "is null" and op ≠ "not null":
- expr: string - Constraint expression
- null: bool - how to evaluate the constraint when the expression is evaluated to null (default: false - the constraint is not satisfied)
chained int elNum of chained element.
Valid element types:
  • RExpr
  • HQuant
  • HComb
  • A1 (Rel wrappers: O,N,ON) (Not in an HQuant's branch)
  • A2 (Rel wrappers: O) (Not in an HQuant's branch)
  • A3 (Rel wrappers: O,N,ON) (Not in an HQuant's branch)
  • M1 (Rel wrappers: O,N,ON) (Not in an HQuant's branch)
  • M2 (Rel wrappers: O) (Not in an HQuant's branch)
  • M3 (Rel wrappers: O,N,ON) (Not in an HQuant's branch)
  • R1 (Rel wrappers: O) (Not in an HQuant's branch)

Quantifier (type = "Quant")

Mandatory Name Type Description
+ qType string "all"/"some"/"gt"/"ge"/"notall"/"none"/"eq"/"ne"/"lt"/"le"/"range"/"notrange"
qVal int mandatory if qType = "gt"/"ge"/"eq"/"ne"/"lt"/"le"
qVal [int] mandatory if qType = "range"/"notrange": array [int] of two elements
wrapper string valid wrappers: O
+ next [int] elNum of first element in each branch (0 or more branches).
Next to a sequence of Quants that is directly next to Start -
Valid element types: Concrete, Typed, Untyped, Quant
Otherwise -
Valid element types: Rel, Path, EExpr, Quant
chained int elNum of chained element (chained to the quantifier's input)
Valid element types:
  • A1
  • A2
  • A3
  • M1
  • M2
  • M3

Combiner (type = "Comb")

Mandatory Name Type Description
+ next int elNum of next element.
Valid element types: Concrete, Typed, Untyped, Comb

Path (type = "Path")

Mandatory Name Type Description
      rTypes [{...}] Relationship types and constraints
For each:
mandatory rType: int - Relationship type. According to the schema (rType)
not mandatory dir - string - direction ("O"/"I") (see "Rel")
not mandatory con: {...} - op: string, expr: string - constraint over a non-negative integer expression (number of relationships of this type [and direction] along the path)
con {...} Constraint for path length (positive integer)
op: string - Constraint operator ("=" / "<" / "≤" / "∈" only)
expr: string - Constraint expression
shortest bool Shortest paths only.
There must either be a con field or "shortest" is true
      eTypes [{...}] Entity types and constraints
For each:
mandatory eType: int - entity type. According to the schema (eType)
not mandatory con: {...} - op: string, expr: string - constraint over a non-negative integer expression (number of entities of this type along the path)
wrapper string valid wrappers: X,N,XN,O,ON
+       next   int elNum of next element.
Valid element types: Concrete, Typed, Untyped, Comb
chained int elNum of chained element.
Valid element types:
  • A1 (valid wrappers: O,N,ON)
  • A2 (valid wrappers: O)
  • A3 (valid wrappers: O,N,ON)
  • M1 (valid wrappers: O,N,ON)
  • M2 (valid wrappers: O)
  • M3(valid wrappers: O,N,ON)

Path Segment (type = "PathSeg")

Mandatory Name Type Description
todo

Horizontal Quantifier (type = "HQuant")

Mandatory Name Type Description
+ qType string "some"/"gt"/"ge"/"notall"/"none"/"eq"/"ne"/"lt"/"le"/"range"/"notrange"
qVal int mandatory if qType = "gt"/"ge"/"eq"/"ne"/"lt"/"le"
qVal [int] mandatory if qType = "range"/"notrange": array [int] of two elements
+ chained [int] elNum of first element in each branch (0 or more branches).
Valid element types: RExpr, HQuant

Horizontal Combiner (type = "HComb")

Mandatory Name Type Description
+ chained int elNum of chained element.
Valid element types:
  • RExpr
  • HQuant
  • HComb
  • A1 (Rel wrappers: O,N,ON)
  • A2 (Rel wrappers: O)
  • A3 (Rel wrappers: O,N,ON)
  • M1 (Rel wrappers: O,N,ON)
  • M2 (Rel wrappers: O)
  • M3 (Rel wrappers: O,N,ON)
  • R1 (Rel wrappers: O)

A1 Aggregator (type = "A1")

Mandatory Name Type Description
+ EAtag int EA tag to assign (unique positive integer)
per {...} elements composing the per clause:
eTags: [string] - one or more entity tags (e.g. "A", "B") or a single string: "<", ">" or "<>" (for ←,→,↔)
exprs: [string] expressions (e.g. "$(1).$(.1).date"). Property types are according to the schema (pType)
etts: [int] - entity type tags (e.g. 1 for "⟨1⟩")
rtts: [int] - relationship type tags (e.g. 1 for "⟪1⟫")
+ eTags [[string]] entity tags in the "et × et × ... ∪ ..." clause (union of Cartesian products), or a single clause of a single string: "<", ">" or "<>" (for ←,→,↔)
con {...} Constraint over non-negative integer expression
op: string - Constraint operator ("=" / "≠" / "∈" / "∉" / ...)
expr: string - Constraint expression
chained int elNum of chained element.
Valid element types:
  • A1 (Rel wrappers: O,N,ON)
  • A2 (Rel wrappers: O)
  • A3 (Rel wrappers: O,N,ON)
  • M1 (Rel wrappers: O,N,ON)
  • M2 (Rel wrappers: O)
  • M3 (Rel wrappers: O,N,ON)
  • R1 (Rel wrappers: O)

A2 Aggregator (type = "A2")

Mandatory Name Type Description
+ EAtag int EA tag to assign (unique positive integer)
per {...} elements composing the per clause:
eTags: [string] - one or more entity tags (e.g. "A", "B") or a single string: "<", ">" or "<>" (for ←,→,↔)
exprs: [string] expressions (e.g. "$(1).$(.1).date"). Property types are according to the schema (pType)
etts: [int] - entity type tags (e.g. 1 for "⟨1⟩")
rtts: [int] - relationship type tags (e.g. 1 for "⟪1⟫")
con {...} Constraint over non-negative integer expression
op: string - Constraint operator ("=" / "≠" / "∈" / "∉" / ...)
expr: string - Constraint expression
chained int elNum of chained element.
Valid element types:
  • A1 (Rel wrappers: O,N,ON)
  • A2 (Rel wrappers: O)
  • A3 (Rel wrappers: O,N,ON)
  • M1 (Rel wrappers: O,N,ON)
  • M2 (Rel wrappers: O)
  • M3 (Rel wrappers: O,N,ON)
  • R1 (Rel wrappers: O)

A3 Aggregator (type = "A3")

Mandatory Name Type Description
+ EAtag int EA tag to assign (unique positive integer)
per {...} elements composing the per clause:
eTags: [string] - one or more entity tags (e.g. "A", "B") or a single string: "<", ">" or "<>" (for ←,→,↔)
exprs: [string] expressions (e.g. "$(1).$(.1).date"). . Property types are according to the schema (pType)
etts: [int] - entity type tags (e.g. 1 for "⟨1⟩")
rtts: [int] - relationship type tags (e.g. 1 for "⟪1⟫")
+ aggOp string aggregation operator: min/max/avg/sum/distinct/set/bag/union/intersection
+ expr string expression to aggregate.
Property types are according to the schema (pType) (e.g. "$(1).$(.2)" for "tf.till" of "member of")
con {...} Constraint
op: string - Constraint operator ("=" / "≠" / "∈" / "∉" / ... / "is null" / "not null")
When op ≠ "is null" and op ≠ "not null":
- expr: string - Constraint expression
- null: bool - how to evaluate the constraint when the expression is evaluated to null (default: false - the constraint is not satisfied)
chained int elNum of chained element.
Valid element types:
  • A1 (Rel wrappers: O,N,ON)
  • A2 (Rel wrappers: O)
  • A3 (Rel wrappers: O,N,ON)
  • M1 (Rel wrappers: O,N,ON)
  • M2 (Rel wrappers: O)
  • M3 (Rel wrappers: O,N,ON)
  • R1 (Rel wrappers: O)

M1 Aggregator (type = "M1")

Mandatory Name Type Description
per {...} elements composing the per clause:
eTags: [string] - one or more entity tags (e.g. "A", "B") or a single string: "<", ">" or "<>" (for ←,→,↔)
exprs: [string] expressions (e.g. "$(1).$(.1).date")
etts: [int] - entity type tags (e.g. 1 for "⟨1⟩")
rtts: [int] - relationship type tags (e.g. 1 for "⟪1⟫")
+ k int number of min/max entities. negative value means "all but ..."
+ els {...} elements composing the '[all but] k ...' clause: at least one of the following:
eTags: [string] - one or more entity tags (e.g. "A", "B") or a single string: "<", ">" or "<>" (for ←,→,↔)
exprs: [string] - one or more expressions (e.g. "$(1).$(.1).date")
etts: [int] - on or more entity type tags (e.g. 1 for "⟨1⟩")
rtts: [int] - on or more relationship type tags (e.g. 1 for "⟪1⟫")
+ op string min/max
+ eTags [[string]] entity tags in the 'with min/max et × et × ... ∪ ..." clause (union of Cartesian products), or a single clause of a single string: "<", ">" or "<>" (for ←,→,↔)
chained int elNum of chained element.
Valid element types:
  • A1 (Rel wrappers: O,N,ON)
  • A2 (Rel wrappers: O)
  • A3 (Rel wrappers: O,N,ON)
  • M1 (Rel wrappers: O,N,ON)
  • M2 (Rel wrappers: O)
  • M3 (Rel wrappers: O,N,ON)
  • R1 (Rel wrappers: O)

M2 Aggregator (type = "M2")

Mandatory Name Type Description
per {...} elements composing the per clause:
eTags: [string] - one or more entity tags (e.g. "A", "B") or a single string: "<", ">" or "<>" (for ←,→,↔)
exprs: [string] expressions (e.g. "$(1).$(.1).date")
etts: [int] - entity type tags (e.g. 1 for "⟨1⟩")
rtts: [int] - relationship type tags (e.g. 1 for "⟪1⟫")
+ k int number of min/max entities. negative value means "all but ..."
+ els {...} elements composing the '[all but] k ...' clause: at least one of the following:
eTags: [string] - one or more entity tags (e.g. "A", "B") or a single string: "<", ">" or "<>" (for ←,→,↔)
exprs: [string] - one or more expressions (e.g. "$(1).$(.1).date")
etts: [int] - on or more entity type tags (e.g. 1 for "⟨1⟩")
rtts: [int] - on or more relationship type tags (e.g. 1 for "⟪1⟫")
+ op string min/max
        chained   int     elNum of chained element.
Valid element types:
  • A1 (Rel wrappers: O,N,ON)
  • A2 (Rel wrappers: O)
  • A3 (Rel wrappers: O,N,ON)
  • M1 (Rel wrappers: O,N,ON)
  • M2 (Rel wrappers: O)
  • M3 (Rel wrappers: O,N,ON)
  • R1 (Rel wrappers: O)

M3 Aggregator (type = "M3")

Mandatory Name Type Description
per {...} elements composing the per clause:
eTags: [string] - one or more entity tags (e.g. "A", "B") or a single string: "<", ">" or "<>" (for ←,→,↔)
exprs: [string] expressions (e.g. "$(1).$(.1).date")
etts: [int] - entity type tags (e.g. 1 for "⟨1⟩")
rtts: [int] - relationship type tags (e.g. 1 for "⟪1⟫")
+ k int number of min/max entities. negative value means "all but ..."
+ els {...} elements composing the '[all but] k ...' clause: at least one of the following:
eTags: [string] - one or more entity tags (e.g. "A", "B") or a single string: "<", ">" or "<>" (for ←,→,↔)
exprs: [string] - one or more expressions (e.g. "$(1).$(.1).date")
etts: [int] - on or more entity type tags (e.g. 1 for "⟨1⟩")
rtts: [int] - on or more relationship type tags (e.g. 1 for "⟪1⟫")
+ op string min/max
+ expr string expression to aggregate.
Property types are according to the schema (pType) (e.g. "$(1).$(.2)" for "tf.till" of "member of")
        chained   int     elNum of chained element.
Valid element types:
  • A1 (Rel wrappers: O,N,ON)
  • A2 (Rel wrappers: O)
  • A3 (Rel wrappers: O,N,ON)
  • M1 (Rel wrappers: O,N,ON)
  • M2 (Rel wrappers: O)
  • M3 (Rel wrappers: O,N,ON)
  • R1 (Rel wrappers: O)

R1 Aggregator (type = "R1")

Mandatory Name Type Description
per {...} elements composing the per clause:
eTags: [string] - one or more entity tags (e.g. "A", "B") or a single string: "<", ">" or "<>" (for ←,→,↔)
exprs: [string] expressions (e.g. "$(1).$(.1).date")
etts: [int] - entity type tags (e.g. 1 for "⟨1⟩")
rtts: [int] - relationship type tags (e.g. 1 for "⟪1⟫")
+ k int number of min/max entities. negative value means "all but ..."
+ op string min/max
+     expr   string Relationship's Expression.
Property types are according to the schema (pType) (e.g. "$(1).$(.2)" for "tf.till" of "member of")
chained int elNum of chained element.
Valid element types:
  • A1 (Rel wrappers: O,N,ON)
  • A2 (Rel wrappers: O)
  • A3 (Rel wrappers: O,N,ON)
  • M1 (Rel wrappers: O,N,ON)
  • M2 (Rel wrappers: O)
  • M3 (Rel wrappers: O,N,ON)
  • R1 (Rel wrappers: O)

Nonidenticality Constraints between Entity Tags

The following snippet demonstrates nonidenticality constraints between entity tags "C≠E" and "C≠F":

"nonidentical": [ ["C", "E"] ["C", "F"] ]

Order Constraints between Entity Tags

The following snippet demonstrates order constraints between entity tags "C<E" and "C<F":

"order": [ ["C", "E"] ["C", "F"] ]

References in JSON Strings

References Examples
EA tag ${n} represents EA tag n. To differentiate from "{n}" - a set of one element
(sub)property $(n) represents property n of the attached entity/relationship.
$(.n) represents subproperty n of the last referred [sub]property.
$(1).$(.2) - subproperty 2 of property 1 of the attached entity/relationship
${1}.$(.2) - subproperty 2 of the expression referenced by EA tag 1
$(1).at(5).$(.2) - subproperty 2 of index 5 of list property 1
categorical value #color(2) - second value of the categorical type 'color'