buildKeywordsFromDictionary function presentation exported ✓ 100.0%

Last updated: 2026-02-24T21:07:57.551Z

Metrics

LOC: 21 Complexity: 4 Params: 0 Coverage: 100.0% (9/9 lines, 4x executed)

Signature

buildKeywordsFromDictionary(): : Record<FieldType, string[]>

Summary

Generates a Record<FieldType, string[]> keyword map directly from the field dictionary. This can replace / supplement the static FIELD_TYPE_KEYWORDS in tensorflow-generator.ts.

Source Code

export function buildKeywordsFromDictionary(): Record<FieldType, string[]> {
  const result = {} as Record<FieldType, string[]>;

  for (const entry of FIELD_DICTIONARY) {
    const keywords: string[] = [];

    // Derive keywords from tags (tags are the classification hints)
    if (entry.tags.length > 0) {
      keywords.push(...entry.tags);
    }

    // Derive keywords from entry type itself (e.g. "cpf" → ["cpf"])
    if (!keywords.includes(entry.type)) {
      keywords.push(entry.type);
    }

    result[entry.type] = [...new Set(keywords)]; // dedupe
  }

  return result;
}

Dependencies (Outgoing)

graph LR buildKeywordsFromDictionary["buildKeywordsFromDictionary"] FieldType["FieldType"] FIELD_DICTIONARY["FIELD_DICTIONARY"] flattenStructuredSignals["flattenStructuredSignals"] getTrainingDistribution["getTrainingDistribution"] TrainingSample["TrainingSample"] augmentShuffle["augmentShuffle"] augmentDrop["augmentDrop"] augmentTypo["augmentTypo"] checkDatasetHealth["checkDatasetHealth"] AccuracyThresholds["AccuracyThresholds"] DatasetHealthReport["DatasetHealthReport"] classifyField["classifyField"] FormField["FormField"] fromFlatSignals["fromFlatSignals"] buildKeywordsFromDictionary -->|uses| FieldType buildKeywordsFromDictionary -->|uses| FIELD_DICTIONARY buildKeywordsFromDictionary -->|uses| flattenStructuredSignals buildKeywordsFromDictionary -->|uses| getTrainingDistribution buildKeywordsFromDictionary -->|uses| TrainingSample buildKeywordsFromDictionary -->|uses| augmentShuffle buildKeywordsFromDictionary -->|uses| augmentDrop buildKeywordsFromDictionary -->|uses| augmentTypo buildKeywordsFromDictionary -->|uses| checkDatasetHealth buildKeywordsFromDictionary -->|uses| AccuracyThresholds buildKeywordsFromDictionary -->|uses| DatasetHealthReport buildKeywordsFromDictionary -->|uses| classifyField buildKeywordsFromDictionary -->|uses| FormField buildKeywordsFromDictionary -->|uses| fromFlatSignals style buildKeywordsFromDictionary fill:#dbeafe,stroke:#2563eb,stroke-width:2px click buildKeywordsFromDictionary "dfb7d9bfef2aba38.html" click FieldType "e49ed8a601306673.html" click FIELD_DICTIONARY "9c3a352ea31b8001.html" click flattenStructuredSignals "a5d367e2c926f76e.html" click getTrainingDistribution "a91cb4e44bdcf500.html" click TrainingSample "01996f51712dacc4.html" click augmentShuffle "e927efe70011297a.html" click augmentDrop "fc8dabee39176edb.html" click augmentTypo "d345acd14e868d5a.html" click checkDatasetHealth "3be8e84862588bff.html" click AccuracyThresholds "6615b48ce086e8dd.html" click DatasetHealthReport "31043e5ebc950c0b.html" click classifyField "aa03a8b1140f5f42.html" click FormField "85cdbded927c91b0.html" click fromFlatSignals "de70361bba9181a6.html"

Impact (Incoming)

graph LR buildKeywordsFromDictionary["buildKeywordsFromDictionary"] EvalMisclassified["EvalMisclassified"] FIELD_DICTIONARY["FIELD_DICTIONARY"] EvalMisclassified -->|uses| buildKeywordsFromDictionary FIELD_DICTIONARY -->|uses| buildKeywordsFromDictionary style buildKeywordsFromDictionary fill:#dbeafe,stroke:#2563eb,stroke-width:2px click buildKeywordsFromDictionary "dfb7d9bfef2aba38.html" click EvalMisclassified "4e0d00ef54656ad2.html" click FIELD_DICTIONARY "9c3a352ea31b8001.html"
SourceType
EvalMisclassified uses
FIELD_DICTIONARY uses