bindExplicit method

BindingResult bindExplicit({
  1. required Concept concept1,
  2. required Concept concept2,
  3. required RelationshipType relationshipType,
  4. double? strength,
  5. ConceptEdge? existingEdge,
  6. String label = '',
})

Explicitly binds concept1 to concept2 with a specified relationshipType and optional strength.

If existingEdge is non-null it is reinforced rather than replaced.

Implementation

BindingResult bindExplicit({
  required Concept concept1,
  required Concept concept2,
  required RelationshipType relationshipType,
  double? strength,
  ConceptEdge? existingEdge,
  String label = '',
}) {
  if (existingEdge != null) {
    final reinforced = math.min(
      1.0,
      existingEdge.strength + _reinforcementRate,
    );
    _logger.debug(
        'Reinforced binding: ${concept1.id} ↔ ${concept2.id} '
        '(${existingEdge.strength.toStringAsFixed(2)} → '
        '${reinforced.toStringAsFixed(2)})');
    return BindingResult(
      conceptId1: concept1.id,
      conceptId2: concept2.id,
      strength: reinforced,
      relationshipType: relationshipType,
      label: label,
      wasReinforced: true,
    );
  }

  final s = strength ?? _baseBindingStrength;
  _logger.debug(
      'New binding: "${concept1.content}" ↔ "${concept2.content}" '
      '(${relationshipType.name}, ${s.toStringAsFixed(2)})');
  return BindingResult(
    conceptId1: concept1.id,
    conceptId2: concept2.id,
    strength: s,
    relationshipType: relationshipType,
    label: label,
    wasReinforced: false,
  );
}