processTokens()

in src/nodes/shared/token-classification-viewer.ts [68:93]


  processTokens(tokens: ProcessedTokens[]) {
    const elements = [];
    for (const token of tokens) {
      let elem;
      if (token.type === "O") {
        elem = html`${token.text}`;
      } else {
        const [textColour, backgroundColour, tagColour] = NER_TAGS[token.type];
        elem = html`<span
          class="ner-container"
          style="background-color: ${backgroundColour}; color: ${textColour}"
        >
          ${token.text}
          <span
            title="${token.type}"
            class="ner-tag"
            style="background-color: ${tagColour}; color: ${backgroundColour}"
          >
            ${token.type}
          </span>
        </span>`;
      }
      elements.push(elem);
    }
    return elements;
  }