示例#1
0
// getTypeName return variable type name
func getTypeName(t VariableType, mod int) string {
	mod = mathutil.Between(mod, 0, 4)

	switch t {
	case VAR_TYPE_STRING:
		return []string{"String", "string", "STRING", "S", "s"}[mod]
	case VAR_TYPE_NUMBER:
		return []string{"Number", "number", "NUMBER", "N", "n"}[mod]
	case VAR_TYPE_BOOLEAN:
		return []string{"Boolean", "boolean", "BOOLEAN", "B", "b"}[mod]
	default:
		return ""
	}
}
示例#2
0
// Suggest suggest words for given word or word part
func (m *Model) Suggest(word string, max int) []string {
	if len(m.terms) == 0 {
		return []string{word}
	}

	if max == 1 {
		return []string{m.Correct(word)}
	}

	sis := getSuggestSlice(m.terms, word)

	sort.Sort(sis)

	var result []string

	for i := 0; i < mathutil.Between(max, 1, len(sis)); i++ {
		result = append(result, sis[i].term)
	}

	return result
}