buildVocab function presentation

Last updated: 2026-02-24T19:46:21.733Z

Metrics

LOC: 9 Complexity: 4 Params: 1

Signature

buildVocab(texts: string[]): : Map<string, number>

Source Code

function buildVocab(texts: string[]): Map<string, number> {
  const vocab = new Map<string, number>();
  for (const text of texts) {
    for (const ng of charNgrams(text)) {
      if (!vocab.has(ng)) vocab.set(ng, vocab.size);
    }
  }
  return vocab;
}

Dependencies (Outgoing)

graph LR buildVocab["buildVocab"] charNgrams["charNgrams"] buildVocab -->|calls| charNgrams style buildVocab fill:#dbeafe,stroke:#2563eb,stroke-width:2px click buildVocab "775e3614ccc16f3a.html" click charNgrams "4a9652b5a506b435.html"
TargetType
charNgrams calls

Impact (Incoming)

graph LR buildVocab["buildVocab"] trainModelFromDataset["trainModelFromDataset"] trainModelFromDataset -->|calls| buildVocab style buildVocab fill:#dbeafe,stroke:#2563eb,stroke-width:2px click buildVocab "775e3614ccc16f3a.html" click trainModelFromDataset "116a4fd1e25c7132.html"
SourceType
trainModelFromDataset calls