public static utteranceLabelsToJsonString()

in packages/orchestratorlib/src/labelresolver.ts [226:629]


  public static utteranceLabelsToJsonString(
    utteranceIntentEntityLabels: {
      utteranceLabelsMap: Map<string, Set<string>>;
      utteranceLabelDuplicateMap: Map<string, Set<string>>;
      utteranceEntityLabelsMap: Map<string, Label[]>;
      utteranceEntityLabelDuplicateMap: Map<string, Label[]>; }): string {
    Utility.debuggingLog('CALLING LabelResolver.utteranceLabelsToJsonString()');
    Utility.debuggingLog(`LabelResolver.utteranceLabelsToJsonString(): utteranceIntentEntityLabels.utteranceLabelsMap.size=${utteranceIntentEntityLabels.utteranceLabelsMap.size}`);
    Utility.debuggingLog(`LabelResolver.utteranceLabelsToJsonString(): utteranceIntentEntityLabels.utteranceLabelDuplicateMap.size=${utteranceIntentEntityLabels.utteranceLabelDuplicateMap.size}`);
    Utility.debuggingLog(`LabelResolver.utteranceLabelsToJsonString(): utteranceIntentEntityLabels.utteranceEntityLabelsMap.size=${utteranceIntentEntityLabels.utteranceEntityLabelsMap.size}`);
    Utility.debuggingLog(`LabelResolver.utteranceLabelsToJsonString(): utteranceIntentEntityLabels.utteranceEntityLabelDuplicateMap.size=${utteranceIntentEntityLabels.utteranceEntityLabelDuplicateMap.size}`);
    // -----------------------------------------------------------------------
    const utteranceLabelsMap: Map<string, Set<string>> = utteranceIntentEntityLabels.utteranceLabelsMap;
    Utility.debuggingLog(`LabelResolver.utteranceLabelsToJsonString(): utteranceIntentEntityLabels.utteranceLabelsMap.size=${utteranceIntentEntityLabels.utteranceLabelsMap.size}`);
    Utility.debuggingLog(`LabelResolver.utteranceLabelsToJsonString(): utteranceIntentEntityLabels.utteranceLabelDuplicateMap.size=${utteranceIntentEntityLabels.utteranceLabelDuplicateMap.size}`);
    let numberUtterancesProcessedUtteranceLabelsMap: number = 0;
    // -----------------------------------------------------------------------
    const utteranceEntityLabelsMap: Map<string, Label[]> = utteranceIntentEntityLabels.utteranceEntityLabelsMap;
    Utility.debuggingLog(`LabelResolver.utteranceLabelsToJsonString(): utteranceIntentEntityLabels.utteranceEntityLabelsMap.size=${utteranceIntentEntityLabels.utteranceEntityLabelsMap.size}`);
    Utility.debuggingLog(`LabelResolver.utteranceLabelsToJsonString(): utteranceIntentEntityLabels.utteranceEntityLabelDuplicateMap.size=${utteranceIntentEntityLabels.utteranceEntityLabelDuplicateMap.size}`);
    let numberUtterancesProcessedUtteranceEntityLabelsMap: number = 0;
    // -----------------------------------------------------------------------
    // ---- Utility.toPrintDetailedDebuggingLogToConsole = true; // ---- NOTE ---- disable after detailed tracing is done.
    const batchJsonifiedStringArray: string[] = [];
    batchJsonifiedStringArray.push('{"examples": [');
    let isFirstUtterance: boolean = true;
    for (const utterance of utteranceLabelsMap.keys()) {
      if (isFirstUtterance) {
        isFirstUtterance = false;
      } else {
        batchJsonifiedStringArray.push(',');
      }
      batchJsonifiedStringArray.push(`{"text": ${JSON.stringify(utterance)},`);
      if (Utility.toPrintDetailedDebuggingLogToConsole) {
        Utility.debuggingLog(`LabelResolver.utteranceLabelsToJsonString(): processing utterance='${utterance}'`);
      }
      batchJsonifiedStringArray.push('"intents": [');
      {
        const labels: Set<string> = utteranceLabelsMap.get(utterance) as Set<string>;
        if (Utility.toPrintDetailedDebuggingLogToConsole) {
          Utility.debuggingLog(`LabelResolver.utteranceLabelsToJsonString()-Intent: Adding { labels.size: ${labels.size}, text: ${utterance} }`);
        }
        if (labels && (labels.size > 0)) {
          let isFirst: boolean = true;
          for (const label of labels) {
            if (isFirst) {
              isFirst = false;
            } else {
              batchJsonifiedStringArray.push(',');
            }
            batchJsonifiedStringArray.push(`{"name": ${JSON.stringify(label)}, "offset": 0, "length": 0}`);
          }
        }
        numberUtterancesProcessedUtteranceLabelsMap++;
        if ((numberUtterancesProcessedUtteranceLabelsMap % Utility.NumberOfInstancesPerProgressDisplayBatchForIntent) === 0) {
          Utility.debuggingLog(`LabelResolver.utteranceLabelsToJsonString(): Added numberUtterancesProcessedUtteranceLabelsMap=${numberUtterancesProcessedUtteranceLabelsMap}`);
        }
      }
      batchJsonifiedStringArray.push('],'); // ---- "intents"
      batchJsonifiedStringArray.push('"entities": [');
      // eslint-disable-next-line no-lone-blocks
      {
        if (utteranceEntityLabelsMap.has(utterance)) {
          const labelsEntities: Label[] = utteranceEntityLabelsMap.get(utterance) as Label[];
          if (Utility.toPrintDetailedDebuggingLogToConsole) {
            Utility.debuggingLog(`LabelResolver.utteranceLabelsToJsonString()-Entity: Adding { labelsEntities.length: ${labelsEntities.length}, text: ${utterance} }`);
          }
          if (labelsEntities && (labelsEntities.length > 0)) {
            let isFirst: boolean = true;
            for (const labelEntity of labelsEntities) {
              // eslint-disable-next-line max-depth
              if (isFirst) {
                isFirst = false;
              } else {
                batchJsonifiedStringArray.push(',');
              }
              batchJsonifiedStringArray.push(`{"name": ${JSON.stringify(labelEntity.name)}, "offset": ${labelEntity.span.offset}, "length": ${labelEntity.span.length}}`);
            }
          }
          numberUtterancesProcessedUtteranceEntityLabelsMap++;
          if ((numberUtterancesProcessedUtteranceEntityLabelsMap % Utility.NumberOfInstancesPerProgressDisplayBatchForEntity) === 0) {
            Utility.debuggingLog(`LabelResolver.utteranceLabelsToJsonString(): Added numberUtterancesProcessedUtteranceEntityLabelsMap=${numberUtterancesProcessedUtteranceEntityLabelsMap}`);
          }
        }
      }
      batchJsonifiedStringArray.push(']'); // ---- "entities"
      batchJsonifiedStringArray.push('}'); // ---- example / "text"
    }
    batchJsonifiedStringArray.push(']}'); // ---- "examples"
    Utility.debuggingLog(`LabelResolver.utteranceLabelsToJsonString(): Added numberUtterancesProcessedUtteranceLabelsMap=${numberUtterancesProcessedUtteranceLabelsMap}`);
    Utility.debuggingLog(`LabelResolver.utteranceLabelsToJsonString(): Added numberUtterancesProcessedUtteranceEntityLabelsMap=${numberUtterancesProcessedUtteranceEntityLabelsMap}`);
    // -----------------------------------------------------------------------
    Utility.debuggingLog('LEAVING LabelResolver.utteranceLabelsToJsonString()');
    return batchJsonifiedStringArray.join(' ');
  }

  // eslint-disable-next-line complexity
  public static utteranceLabelsToObjectJsonString(
    utteranceIntentEntityLabels: {
      utteranceLabelsMap: Map<string, Set<string>>;
      utteranceLabelDuplicateMap: Map<string, Set<string>>;
      utteranceEntityLabelsMap: Map<string, Label[]>;
      utteranceEntityLabelDuplicateMap: Map<string, Label[]>; }): string {
    Utility.debuggingLog('CALLING LabelResolver.utteranceLabelsToObjectJsonString()');
    Utility.debuggingLog(`LabelResolver.utteranceLabelsToObjectJsonString(): utteranceIntentEntityLabels.utteranceLabelsMap.size=${utteranceIntentEntityLabels.utteranceLabelsMap.size}`);
    Utility.debuggingLog(`LabelResolver.utteranceLabelsToObjectJsonString(): utteranceIntentEntityLabels.utteranceLabelDuplicateMap.size=${utteranceIntentEntityLabels.utteranceLabelDuplicateMap.size}`);
    Utility.debuggingLog(`LabelResolver.utteranceLabelsToObjectJsonString(): utteranceIntentEntityLabels.utteranceEntityLabelsMap.size=${utteranceIntentEntityLabels.utteranceEntityLabelsMap.size}`);
    Utility.debuggingLog(`LabelResolver.utteranceLabelsToObjectJsonString(): utteranceIntentEntityLabels.utteranceEntityLabelDuplicateMap.size=${utteranceIntentEntityLabels.utteranceEntityLabelDuplicateMap.size}`);
    // -----------------------------------------------------------------------
    const batch: {
      'examples': Array<{
        'text': string;
        'intents': Array<{
          'name': string;
          'offset': number;
          'length': number;
        }>;
        'entities': Array<{
          'name': string;
          'offset': number;
          'length': number;
        }>;
      }>;
    } = LabelResolver.utteranceLabelsToObject(utteranceIntentEntityLabels);
    // -----------------------------------------------------------------------
    UtilityDispatcher.debuggingLog('LabelResolver.utteranceLabelsToObjectJsonString(): ready to call JSON.stringify()');
    const batchJsonified: string = JSON.stringify(batch);
    UtilityDispatcher.debuggingLog('LabelResolver.utteranceLabelsToObjectJsonString(): finished calling JSON.stringify()');
    if (UtilityDispatcher.toPrintDetailedDebuggingLogToConsole) {
      UtilityDispatcher.debuggingNamedLog1('LabelResolver.utteranceLabelsToObjectJsonString(): batchJsonified', batchJsonified, 'batchJsonified');
    }
    // -----------------------------------------------------------------------
    Utility.debuggingLog('LEAVING LabelResolver.utteranceLabelsToObjectJsonString()');
    return batchJsonified;
  }

  // eslint-disable-next-line complexity
  public static utteranceLabelsToObject(
    utteranceIntentEntityLabels: {
      utteranceLabelsMap: Map<string, Set<string>>;
      utteranceLabelDuplicateMap: Map<string, Set<string>>;
      utteranceEntityLabelsMap: Map<string, Label[]>;
      utteranceEntityLabelDuplicateMap: Map<string, Label[]>; }): {
        'examples': Array<{
          'text': string;
          'intents': Array<{
            'name': string;
            'offset': number;
            'length': number;
          }>;
          'entities': Array<{
            'name': string;
            'offset': number;
            'length': number;
          }>;
        }>;
      } {
    Utility.debuggingLog('CALLING LabelResolver.utteranceLabelsToObject()');
    Utility.debuggingLog(`LabelResolver.utteranceLabelsToObject(): utteranceIntentEntityLabels.utteranceLabelsMap.size=${utteranceIntentEntityLabels.utteranceLabelsMap.size}`);
    Utility.debuggingLog(`LabelResolver.utteranceLabelsToObject(): utteranceIntentEntityLabels.utteranceLabelDuplicateMap.size=${utteranceIntentEntityLabels.utteranceLabelDuplicateMap.size}`);
    Utility.debuggingLog(`LabelResolver.utteranceLabelsToObject(): utteranceIntentEntityLabels.utteranceEntityLabelsMap.size=${utteranceIntentEntityLabels.utteranceEntityLabelsMap.size}`);
    Utility.debuggingLog(`LabelResolver.utteranceLabelsToObject(): utteranceIntentEntityLabels.utteranceEntityLabelDuplicateMap.size=${utteranceIntentEntityLabels.utteranceEntityLabelDuplicateMap.size}`);
    // -----------------------------------------------------------------------
    const examples: Array<{
      'text': string;
      'intents': Array<{
        'name': string;
        'offset': number;
        'length': number;
      }>;
      'entities': Array<{
        'name': string;
        'offset': number;
        'length': number;
      }>;
    }> = new Array<{
      text: string;
      intents: Array<{
        name: string;
        offset: number;
        length: number;
      }>;
      entities: Array<{
        name: string;
        offset: number;
        length: number;
      }>;
    }>();
    const batch: {
      'examples': Array<{
        'text': string;
        'intents': Array<{
          'name': string;
          'offset': number;
          'length': number;
        }>;
        'entities': Array<{
          'name': string;
          'offset': number;
          'length': number;
        }>;
      }>;
    } = {
      examples,
    };
    // -----------------------------------------------------------------------
    UtilityDispatcher.debuggingNamedLog1('LabelResolver.utteranceLabelsToObject(), empty batch', batch, 'batch');
    // -----------------------------------------------------------------------
    const utteranceLabelsMap: Map<string, Set<string>> = utteranceIntentEntityLabels.utteranceLabelsMap;
    Utility.debuggingLog(`LabelResolver.utteranceLabelsToObject(): utteranceIntentEntityLabels.utteranceLabelsMap.size=${utteranceIntentEntityLabels.utteranceLabelsMap.size}`);
    Utility.debuggingLog(`LabelResolver.utteranceLabelsToObject(): utteranceIntentEntityLabels.utteranceLabelDuplicateMap.size=${utteranceIntentEntityLabels.utteranceLabelDuplicateMap.size}`);
    let numberUtterancesProcessedUtteranceLabelsMap: number = 0;
    // -----------------------------------------------------------------------
    const utteranceEntityLabelsMap: Map<string, Label[]> = utteranceIntentEntityLabels.utteranceEntityLabelsMap;
    Utility.debuggingLog(`LabelResolver.utteranceLabelsToObject(): utteranceIntentEntityLabels.utteranceEntityLabelsMap.size=${utteranceIntentEntityLabels.utteranceEntityLabelsMap.size}`);
    Utility.debuggingLog(`LabelResolver.utteranceLabelsToObject(): utteranceIntentEntityLabels.utteranceEntityLabelDuplicateMap.size=${utteranceIntentEntityLabels.utteranceEntityLabelDuplicateMap.size}`);
    let numberUtterancesProcessedUtteranceEntityLabelsMap: number = 0;
    // -----------------------------------------------------------------------
    // ---- Utility.toPrintDetailedDebuggingLogToConsole = true; // ---- NOTE ---- disable after detailed tracing is done.
    for (const utterance of utteranceLabelsMap.keys()) {
      if (Utility.toPrintDetailedDebuggingLogToConsole) {
        Utility.debuggingLog(`LabelResolver.utteranceLabelsToObject(): processing utterance='${utterance}'`);
      }
      const intents: Array<{
        'name': string;
        'offset': number;
        'length': number;
      }> = [];
      {
        const labels: Set<string> = utteranceLabelsMap.get(utterance) as Set<string>;
        if (Utility.toPrintDetailedDebuggingLogToConsole) {
          Utility.debuggingLog(`LabelResolver.utteranceLabelsToObject()-Intent: Adding { labels.size: ${labels.size}, text: ${utterance} }`);
        }
        if (labels && (labels.size > 0)) {
          for (const label of labels) {
            intents.push({
              name: label,
              offset: 0,
              length: 0,
            });
          }
        }
        numberUtterancesProcessedUtteranceLabelsMap++;
        if ((numberUtterancesProcessedUtteranceLabelsMap % Utility.NumberOfInstancesPerProgressDisplayBatchForIntent) === 0) {
          Utility.debuggingLog(`LabelResolver.utteranceLabelsToObject(): Added numberUtterancesProcessedUtteranceLabelsMap=${numberUtterancesProcessedUtteranceLabelsMap}`);
        }
      }
      const entities: Array<{
        'name': string;
        'offset': number;
        'length': number;
      }> = [];
      // eslint-disable-next-line no-lone-blocks
      {
        if (utteranceEntityLabelsMap.has(utterance)) {
          const labelsEntities: Label[] = utteranceEntityLabelsMap.get(utterance) as Label[];
          if (Utility.toPrintDetailedDebuggingLogToConsole) {
            Utility.debuggingLog(`LabelResolver.utteranceLabelsToObject()-Entity: Adding { labelsEntities.length: ${labelsEntities.length}, text: ${utterance} }`);
          }
          if (labelsEntities && (labelsEntities.length > 0)) {
            for (const labelEntity of labelsEntities) {
              entities.push({
                name: labelEntity.name,
                offset: labelEntity.span.offset,
                length: labelEntity.span.length,
              });
            }
          }
          numberUtterancesProcessedUtteranceEntityLabelsMap++;
          if ((numberUtterancesProcessedUtteranceEntityLabelsMap % Utility.NumberOfInstancesPerProgressDisplayBatchForEntity) === 0) {
            Utility.debuggingLog(`LabelResolver.utteranceLabelsToObject(): Added numberUtterancesProcessedUtteranceEntityLabelsMap=${numberUtterancesProcessedUtteranceEntityLabelsMap}`);
          }
        }
      }
      examples.push({
        text: utterance,
        intents: intents,
        entities: entities,
      });
    }
    Utility.debuggingLog(`LabelResolver.utteranceLabelsToObject(): Added numberUtterancesProcessedUtteranceLabelsMap=${numberUtterancesProcessedUtteranceLabelsMap}`);
    Utility.debuggingLog(`LabelResolver.utteranceLabelsToObject(): Added numberUtterancesProcessedUtteranceEntityLabelsMap=${numberUtterancesProcessedUtteranceEntityLabelsMap}`);
    // -----------------------------------------------------------------------
    Utility.debuggingLog('LEAVING LabelResolver.utteranceLabelsToObject()');
    return batch;
  }

  // eslint-disable-next-line complexity
  public static addExamples(
    utteranceIntentEntityLabels: {
      utteranceLabelsMap: Map<string, Set<string>>;
      utteranceLabelDuplicateMap: Map<string, Set<string>>;
      utteranceEntityLabelsMap: Map<string, Label[]>;
      utteranceEntityLabelDuplicateMap: Map<string, Label[]>; },
    labelResolver: any = null) {
    Utility.debuggingLog('CALLING LabelResolver.addExamples()');
    if (labelResolver === null) {
      labelResolver = LabelResolver.LabelResolver;
    }
    Utility.debuggingLog(`processed utteranceIntentEntityLabels.utteranceLabelsMap.size=${utteranceIntentEntityLabels.utteranceLabelsMap.size}`);
    Utility.debuggingLog(`processed utteranceIntentEntityLabels.utteranceLabelDuplicateMap.size=${utteranceIntentEntityLabels.utteranceLabelDuplicateMap.size}`);
    Utility.debuggingLog(`processed utteranceIntentEntityLabels.utteranceEntityLabelsMap.size=${utteranceIntentEntityLabels.utteranceEntityLabelsMap.size}`);
    Utility.debuggingLog(`processed utteranceIntentEntityLabels.utteranceEntityLabelDuplicateMap.size=${utteranceIntentEntityLabels.utteranceEntityLabelDuplicateMap.size}`);
    // -----------------------------------------------------------------------
    const utteranceLabelsMap: Map<string, Set<string>> = utteranceIntentEntityLabels.utteranceLabelsMap;
    Utility.debuggingLog(`processed utteranceIntentEntityLabels.utteranceLabelsMap.size=${utteranceIntentEntityLabels.utteranceLabelsMap.size}`);
    Utility.debuggingLog(`processed utteranceIntentEntityLabels.utteranceLabelDuplicateMap.size=${utteranceIntentEntityLabels.utteranceLabelDuplicateMap.size}`);
    let numberUtterancesProcessedUtteranceLabelsMap: number = 0;
    Utility.debuggingLog(`READY to call labelResolver.addExample() on utteranceLabelsMap utterances and labels, utteranceLabelsMap.size=${utteranceLabelsMap.size}`);
    // ---- Utility.toPrintDetailedDebuggingLogToConsole = true; // ---- NOTE ---- disable after detailed tracing is done.
    // eslint-disable-next-line guard-for-in
    for (const utterance of utteranceLabelsMap.keys()) {
      if (Utility.toPrintDetailedDebuggingLogToConsole) {
        Utility.debuggingLog(`processing utterance=${utterance}`);
      }
      const labels: Set<string> = utteranceLabelsMap.get(utterance) as Set<string>;
      if (Utility.toPrintDetailedDebuggingLogToConsole) {
        Utility.debuggingLog(`LabelResolver.addExample()-Intent: Adding { labels.size: ${labels.size}, text: ${utterance} }`);
      }
      if (labels && (labels.size > 0)) {
        for (const label of labels) {
          try {
            const success: any = labelResolver.addExample({label: label, text: utterance});
            // eslint-disable-next-line max-depth
            if (success) {
              // eslint-disable-next-line max-depth
              if (Utility.toPrintDetailedDebuggingLogToConsole) {
                Utility.debuggingLog(`LabelResolver.addExample()-Intent: Added { label: ${label}, text: ${utterance} }`);
              }
            } else {
              Utility.debuggingLog(`LabelResolver.addExample()-Intent: Failed adding { label: ${label}, text: ${utterance} }`);
            }
          } catch (error) {
            Utility.debuggingThrow(`LabelResolver.addExample()-Intent: Failed adding { label: ${label}, text: ${utterance} }\n${error}`);
          }
        }
      }
      numberUtterancesProcessedUtteranceLabelsMap++;
      if ((numberUtterancesProcessedUtteranceLabelsMap % Utility.NumberOfInstancesPerProgressDisplayBatchForIntent) === 0) {
        Utility.debuggingLog(`LabelResolver.addExamples(): Added numberUtterancesProcessedUtteranceLabelsMap=${numberUtterancesProcessedUtteranceLabelsMap}`);
      }
    }
    // -----------------------------------------------------------------------
    const utteranceEntityLabelsMap: Map<string, Label[]> = utteranceIntentEntityLabels.utteranceEntityLabelsMap;
    Utility.debuggingLog(`processed utteranceIntentEntityLabels.utteranceEntityLabelsMap.size=${utteranceIntentEntityLabels.utteranceEntityLabelsMap.size}`);
    Utility.debuggingLog(`processed utteranceIntentEntityLabels.utteranceEntityLabelDuplicateMap.size=${utteranceIntentEntityLabels.utteranceEntityLabelDuplicateMap.size}`);
    let numberUtterancesProcessedUtteranceEntityLabelsMap: number = 0;
    Utility.debuggingLog(`READY to call labelResolver.addExample() on utteranceEntityLabelsMap utterances and labels, utteranceEntityLabelsMap.size=${utteranceEntityLabelsMap.size}`);
    // eslint-disable-next-line guard-for-in
    for (const utterance of utteranceEntityLabelsMap.keys()) {
      if (Utility.toPrintDetailedDebuggingLogToConsole) {
        Utility.debuggingLog(`processing utterance=${utterance}`);
      }
      const labels: Label[] = utteranceEntityLabelsMap.get(utterance) as Label[];
      if (Utility.toPrintDetailedDebuggingLogToConsole) {
        Utility.debuggingLog(`LabelResolver.addExample()-Entity: Added { labels.length: ${labels.length}, text: ${utterance} }`);
      }
      if (labels && (labels.length > 0)) {
        for (const label of labels) {
          const entity: string = label.name;
          const spanOffset: number = label.span.offset;
          const spanLength: number = label.span.length;
          try {
            const success: any = labelResolver.addExample({
              text: utterance,
              labels: [{
                name: entity,
                label_type: 2,
                span: {
                  offset: spanOffset,
                  length: spanLength}}]});
            // eslint-disable-next-line max-depth
            if (success) {
              // eslint-disable-next-line max-depth
              if (Utility.toPrintDetailedDebuggingLogToConsole) {
                Utility.debuggingLog(`LabelResolver.addExample()-Entity: Added { label: ${label}, text: ${utterance}, offset: ${spanOffset}, length: ${spanLength} }`);
              }
            } else {
              Utility.debuggingLog(`LabelResolver.addExample()-Entity: Failed adding { label: ${label}, text: ${utterance}, offset: ${spanOffset}, length: ${spanLength} }`);
            }
          } catch (error) {
            Utility.debuggingThrow(`LabelResolver.addExample()-Entity: Failed adding { label: ${label}, text: ${utterance}, offset: ${spanOffset}, length: ${spanLength} }\n${error}`);
          }
        }
      }
      numberUtterancesProcessedUtteranceEntityLabelsMap++;
      if ((numberUtterancesProcessedUtteranceEntityLabelsMap % Utility.NumberOfInstancesPerProgressDisplayBatchForEntity) === 0) {
        Utility.debuggingLog(`LabelResolver.addExamples(): Added numberUtterancesProcessedUtteranceEntityLabelsMap=${numberUtterancesProcessedUtteranceEntityLabelsMap}`);
      }
    }
    // -----------------------------------------------------------------------
    Utility.debuggingLog('LEAVING LabelResolver.addExamples()');
  }

  private static ensureLabelResolver(labelResolver: any) {
    if (!labelResolver) {
      labelResolver = LabelResolver.LabelResolver;
    }
    if (!labelResolver) {
      throw new Error('LabelResolver was not initialized');
    }
    return labelResolver;
  }
}