MCPcopy Create free account
hub / github.com/GopherML/bag / String

Method String

ngram.go:40–57  ·  view source on GitHub ↗

String will convert the nGram contents to a string

()

Source from the content-addressed store, hash-verified

38
39// String will convert the nGram contents to a string
40func (n *nGram) String() (out string) {
41 // Initialize buffer
42 buf := bytes.NewBuffer(nil)
43 // Iterate through nGram values
44 n.ForEach(func(value string) (end bool) {
45 if buf.Len() > 0 {
46 // Buffer is not empty, prefix the iterating value with a space
47 buf.WriteByte(' ')
48 }
49
50 // Write value to buffer
51 buf.WriteString(value)
52 return
53 })
54
55 // Return buffer as string
56 return buf.String()
57}
58
59// IsZero returns whether or not the nGram is empty
60func (n nGram) IsZero() bool {

Callers 2

toNGramsFunction · 0.95
toWordsFunction · 0.45

Calls 2

ForEachMethod · 0.80
LenMethod · 0.80

Tested by

no test coverage detected