MCPcopy Create free account
hub / github.com/TheAlgorithms/Go / GetWord

Function GetWord

strings/ahocorasick/shared.go:49–58  ·  view source on GitHub ↗

GetWord Function that returns word found in text 't' at position range 'begin' to 'end'.

(begin, end int, t string)

Source from the content-addressed store, hash-verified

47
48// GetWord Function that returns word found in text 't' at position range 'begin' to 'end'.
49func GetWord(begin, end int, t string) string {
50 for end >= len(t) {
51 return ""
52 }
53 d := make([]uint8, end-begin+1)
54 for j, i := 0, begin; i <= end; i, j = i+1, j+1 {
55 d[j] = t[i]
56 }
57 return string(d)
58}
59
60// ComputeAlphabet Function that returns string of all the possible characters in given patterns.
61func ComputeAlphabet(p []string) (s string) {

Callers 2

AhoCorasickFunction · 0.85
AdvancedFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected