String will convert the nGram contents to a string
()
| 38 | |
| 39 | // String will convert the nGram contents to a string |
| 40 | func (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 |
| 60 | func (n nGram) IsZero() bool { |