registerAndBind method

List<BindingResult> registerAndBind(
  1. Concept concept,
  2. List<ConceptNode> allNodes
)

Registers a newly observed concept and attempts to bind it with recently observed concepts that are still within the temporal window.

Returns the list of binding results produced.

Implementation

List<BindingResult> registerAndBind(
  Concept concept,
  List<ConceptNode> allNodes,
) {
  _pruneExpiredBuffer();

  final results = <BindingResult>[];

  // Attempt temporal & semantic binding with buffered concepts
  for (final recent in _recentBuffer) {
    if (recent.concept.id == concept.id) continue;

    final result = _computeBinding(concept, recent.concept, allNodes);
    if (result != null) results.add(result);
  }

  // Buffer the new concept
  _recentBuffer.add(_TimestampedConcept(
    concept: concept,
    observedAt: DateTime.now(),
  ));

  if (results.isNotEmpty) {
    _logger.info(
        'Binding produced ${results.length} link(s) for "${concept.content}"');
  }
  return results;
}