ContextGraph constructor

ContextGraph(
  1. List<List<int>> tokenIds,
  2. List<KeywordPhrase> phrases
)

Implementation

ContextGraph(List<List<int>> tokenIds, List<KeywordPhrase> phrases)
  : root = ContextState(
      token: -1,
      tokenScore: 0,
      nodeScore: 0,
      outputScore: 0,
    ) {
  if (tokenIds.isEmpty || tokenIds.length != phrases.length) {
    throw ArgumentError('At least one tokenized phrase is required');
  }
  root.fail = root;
  _build(tokenIds, phrases);
  _fillFailureAndOutputLinks();
}