MCPcopy Create free account
hub / github.com/JordanCoin/codemap / newIndex

Function newIndex

skills/types.go:32–52  ·  view source on GitHub ↗

newIndex builds lookup maps from a slice of skills.

(skills []Skill)

Source from the content-addressed store, hash-verified

30
31// newIndex builds lookup maps from a slice of skills.
32func newIndex(skills []Skill) *SkillIndex {
33 idx := &SkillIndex{
34 Skills: skills,
35 ByName: make(map[string]*Skill),
36 ByKeyword: make(map[string][]*Skill),
37 ByLanguage: make(map[string][]*Skill),
38 }
39 for i := range idx.Skills {
40 s := &idx.Skills[i]
41 if s.Meta.Name != "" {
42 idx.ByName[s.Meta.Name] = s
43 }
44 for _, kw := range s.Meta.Keywords {
45 idx.ByKeyword[kw] = append(idx.ByKeyword[kw], s)
46 }
47 for _, lang := range s.Meta.Languages {
48 idx.ByLanguage[lang] = append(idx.ByLanguage[lang], s)
49 }
50 }
51 return idx
52}

Callers 6

TestNewIndexFunction · 0.85
TestMatchSkills_TopKFunction · 0.85
TestMatchSkills_EmptyFunction · 0.85
LoadSkillsFunction · 0.85

Calls

no outgoing calls

Tested by 5

TestNewIndexFunction · 0.68
TestMatchSkills_TopKFunction · 0.68
TestMatchSkills_EmptyFunction · 0.68