Skip to content

Relations

Ptrhnk edited this page Jan 10, 2023 · 24 revisions

I Information

This page summarizes the work and discussions on Semantic Relations from the technological and implementation perspective:

II Links

III Relation models

III-1 SuperClass

rules

allowedEntitiesPattern: [
  [EntityEnums.Class.Action, EntityEnums.Class.Action],
  [EntityEnums.Class.Concept, EntityEnums.Class.Concept],
],
allowedSameEntityEnums.ClassesOnly: true,
asymmetrical: true,
multiple: true,
cloudType: false,
treeType: true,
attributes: [],

examples

[
  {type: RelationType.Superclass, entityIds: ["pug", "dog"]},
  {type: RelationType.Superclass, entityIds: ["poodle", "dog"]},
  {type: RelationType.Superclass, entityIds: ["dog", "mammal"]},
  {type: RelationType.Superclass, entityIds: ["dog", "human companion"]},
  {type: RelationType.Superclass, entityIds: ["cat", "mammal"]},
  {type: RelationType.Superclass, entityIds: ["mammal", "animal"]},
  {type: RelationType.Superclass, entityIds: ["animal", "life form"]},
  {type: RelationType.Superclass, entityIds: ["life form", "everything"]},
]

III-2 SuperordinateLocation

rules

  allowedEntitiesPattern: [[EntityEnums.Class.Location, EntityEnums.Class.Location]],
  allowedSameEntityEnums.ClassesOnly: true,
  asymmetrical: true,
  multiple: true,
  cloudType: false,
  treeType: true,
  attributes: [],

example

[
  {type: RelationType.SuperordinateLocation, entityIds: ["Brno", "South Moravia"]},
  {type: RelationType.SuperordinateLocation, entityIds: ["Brno", "Margraviate of Moravia"]},
  {type: RelationType.SuperordinateLocation, entityIds: ["South Moravia", "Czech Republic"]},
  {type: RelationType.SuperordinateLocation, entityIds: ["House of David", "Brno"]},
]

III-3 Synonym

rules

  allowedEntitiesPattern: [[EntityEnums.Class.Action], [EntityEnums.Class.Concept]],
  allowedSameEntityEnums.ClassesOnly: false,
  asymmetrical: false,
  multiple: false,
  cloudType: true,
  treeType: false,
  attributes: [],

example

[
  {type: RelationType.Synonym, entityIds: ["dog", "pes", "doggie", "hafík"]},
]

III-4 Antonym

rules

  allowedEntitiesPattern: [
    [EntityEnums.Class.Action, EntityEnums.Class.Action],
    [EntityEnums.Class.Concept, EntityEnums.Class.Concept],
  ],
  allowedSameEntityEnums.ClassesOnly: true,
  asymmetrical: false,
  multiple: true,
  cloudType: false,
  treeType: false,
  attributes: [],

example

[
  {type: RelationType.Antonym, entityIds: ["big", "small"]},
  {type: RelationType.Antonym, entityIds: ["to starve", "to eat"]},
]

III-5 Troponym

PROBABLY DEPRECATED

A verb that indicates more precisely the manner of doing something by replacing a verb of a more generalized meaning. E.g, ‘Stroll’ is a troponym of ‘walk’, since it involves a slow and relaxed sort of walking.

rules

  allowedEntitiesPattern: [[EntityEnums.Class.Action]],
  allowedSameEntityEnums.ClassesOnly: true,
  asymmetrical: false,
  multiple: false,
  cloudType: true,
  treeType: false,
  attributes: [],

example

[
  {type: RelationType.Troponym, entityIds: ["talk", "gossip", "scream", "whisper"]},
]

III-6 PropertyReciprocal

rules

  allowedEntitiesPattern: [[EntityEnums.Class.Concept, EntityEnums.Class.Concept]],
  allowedSameEntityEnums.ClassesOnly: true,
  asymmetrical: false,
  multiple: false,
  cloudType: false,
  treeType: false,
  attributes: [],

example

[
  {type: RelationType.PropertyReciprocal, entityIds: []},
]

III-7 SubjectActant1Reciprocal

rules

  allowedEntitiesPattern: [[EntityEnums.Class.Action, EntityEnums.Class.Action]],
  allowedSameEntityEnums.ClassesOnly: true,
  asymmetrical: false,
  multiple: false,
  cloudType: false,
  treeType: false,
  attributes: [],

example

[
  {type: RelationType.SubjectActant1Reciprocal, entityIds: ["talk", "listen"]},
]

III-8 ActionEventEquivalent

rules

  allowedEntitiesPattern: [
    [EntityEnums.Class.Action, EntityEnums.Class.Concept],
  ],
  allowedSameEntityEnums.ClassesOnly: false,
  asymmetrical: false,
  multiple: false,
  cloudType: false,
  treeType: false,
  attributes: [],

example

[
  {type: RelationType.ActionEventEquivalent, entityIds: []},
]

III-9 Related

rules

  allowedEntitiesPattern: [], // any combination is allowed
  allowedSameEntityEnums.ClassesOnly: false,
  asymmetrical: false,
  multiple: true,
  cloudType: false,
  treeType: false,
  attributes: [],

example

[
  {type: RelationType.Related, entityIds: ["pen", "paper"]},
  {type: RelationType.Related, entityIds: ["paper", "to write"]},
  {type: RelationType.Related, entityIds: ["paper", "banknote"]},
]

III-10 Classification

rules

  allowedEntitiesPattern: [
    [EntityEnums.Class.Person, EntityEnums.Class.Concept],
    [EntityEnums.Class.Location, EntityEnums.Class.Concept],
    [EntityEnums.Class.Object, EntityEnums.Class.Concept],
    [EntityEnums.Class.Group, EntityEnums.Class.Concept],
    [EntityEnums.Class.Being, EntityEnums.Class.Concept],
    [EntityEnums.Class.Event, EntityEnums.Class.Concept],
    [EntityEnums.Class.Statement, EntityEnums.Class.Concept],
    [EntityEnums.Class.Territory, EntityEnums.Class.Concept],
    [EntityEnums.Class.Resource, EntityEnums.Class.Concept],
  ],
  allowedSameEntityEnums.ClassesOnly: false,
  asymmetrical: true,
  multiple: true,
  cloudType: false,
  treeType: true,
  attributes: [],

example

[
  {type: RelationType.Classification, entityIds: ["P:David", "C:human"]},
  {type: RelationType.Classification, entityIds: ["O:pen", "C:pen"]},
  {type: RelationType.Classification, entityIds: ["L:David's home", "C:townhouse"]},
]

III-11 Identification

rules

  allowedEntitiesPattern: [], // any combination is allowed
  allowedSameEntityEnums.ClassesOnly: false,
  asymmetrical: false,
  multiple: true,
  cloudType: true,
  treeType: false,
  attributes: [Certainty],

example

[
  {type: RelationType.Identification, entityIds: ["David from text 1", "David from text 2"], certainty: [Certainty.Certain]},
  {type: RelationType.Identification, entityIds: ["David from text 1", "David from text 14"], certainty: [Certainty.AlmostCertain]},
  {type: RelationType.Identification, entityIds: ["David from text 2", "Batman"], certainty: [Certainty.Possible]},
  {type: RelationType.Identification, entityIds: ["Batman", "Spiderman"], certainty: [Certainty.False]},
]

III-12 Holonym

Holonymy is part -> whole relation. It is needed e.g. to study places (real-life example on gates of a religious house in this article): e.g. an interrogation happens at the gate of a religious house. Here, of course, it is not enough to know that this happened at a C gate; we also need to maintain the relation to the C "religious house" (i.e. we need to know that this L gate was a gate of a religious house). This relation if of course is not one of superclass: the C "gate of a religious house" is not an instance of a religious house (hypernymy aka superclass), but a part of one (holonymy). Solution: this Location "gate of Sant'Eustorgio convent in Milan" has the class C "gate of a religious house", and this C "gate of a religious house" has the holonym C religious house.

rules

  allowedEntitiesPattern: [[EntityEnums.Class.Concept, EntityEnums.Class.Concept]],
  allowedSameEntityEnums.ClassesOnly: true,
  asymmetrical: true,
  multiple: true,
  cloudType: false,
  treeType: true,
  attributes: [],

example

[
  {type: RelationType.Holonym, entityIds: ["gate of a religious house", "religious house"]},
]

III-13 Implication

Implication (aka entailment, but I take the liberty of choosing a more general-usage word) means that an action implies another. E.g., A "entered" (a space) also implies "was moving", and "was drunk" implies "was (previously) drinking alcohol". It is essentially there to enrich data with implied DDB2 relations (BTW at elvl4).

rules

  allowedEntitiesPattern: [[EntityEnums.Class.Action, EntityEnums.Class.Action]],
  allowedSameEntityEnums.ClassesOnly: true,
  asymmetrical: true,
  multiple: true,
  cloudType: false,
  treeType: true,
  attributes: [],

example

[
  {type: RelationType.Implication, entityIds: ["entered", "moved"]},
  {type: RelationType.Implication, entityIds: ["was drunk", "was drinking (before)"]},
]

IV FE Implementation

Relations on FE are generated and set up by attributes in packages/shared/types/relation.ts
Conditions to choose UI type are processed in this order:

  1. is cloudType
  2. is treeType
  3. is multiple

Order of relations is preserved in packages/shared/enums/relations.ts

const EntityDetailTypes -> order and what relations are shown in detail
const TooltipTypes -> order and what relations are shown in tooltip

Conditions for choosing entityClasses for suggester:

relationRule.allowedEntitiesPattern:
isEmpty -> all entities are allowed (e.g. Type.Related)

nonEmpty ->

  1. isCloudType allowedSameEntityClassesOnly ? current entity.class | allowedEntitiesPattern (collect all)

  2. ...rest -> Finds allowedEntitiesPattern(s) with current EntityClass on the left and returns the right side of this pair.
    (symmetrical patterns only have same classes as the 2nd in pair)

Conditions for filtering relations in detail:

Rule is selected to detail when allowedEntitiesPattern:

  1. isEmpty
  2. some of the pairs has current entity on the 1st position
    (inverse logic for inversions - current entity on 2nd position)

V Roadmap

"Pure" Entity Relations

  • models in shared/types/relations.ts
  • API endpoints
  • BE implementation
  • GUI design and implementation in Detail

In-Statement "Relations" (actant classifications and identifications)

  • Updated IStatement model + BE implementation
  • Updated IResponseStatement model (just add entityIds) + BE implementation
  • GUI design + implementation

In-Statement "Relations" for Details

EntityTag Tooltip info

  • IResponseTagInfo model
  • BE implementation
  • API endpoint
  • GUI design
  • GUI implementation - new query for the component

Parsing (@tom)

Later

  • Validate relations based on the RelationRule dictionaries
  • Apply relations to the template system
  • Test relations in GUI