//
// Create a WordCompleter and initialize with list of words
//
354719
func NewWordCompleter(words CompleterWords, cond CompleterCond) *WordCompleter {
	return &WordCompleter{Words: words, Cond: cond}
}
224688
func (c *Console) AutoCompleteInput(line string, pos int) (string, []string, string) {
	// No completions can be provided for empty inputs
	if len(line) == 0 || pos == 0 {
		return "", nil, ""
	}
	// Chunck data to relevant part for autocompletion
	// E.g. in case of nested lines eth.getBalance(eth.coinb<tab><tab>
	start := pos - 1
	for ; start > 0; start-- {
		// Skip all methods and namespaces (i.e. including the dot)
		if line[start] == '.' || (line[start] >= 'a' && line[start] <= 'z') || (line[start] >= 'A' && line[start] <= 'Z') {
			continue
		}
		// Handle web3 in a special way (i.e. other numbers aren't auto completed)
		if start >= 3 && line[start-3:start] == "web3" {
			start -= 3
			continue
		}
		// We've hit an unexpected character, autocomplete form here
		start++
		break
	}
	return line[:start], c.jsre.CompleteKeywords(line[start:pos]), line[pos:]
}
217379
func go_libedit_getcompletions(cI C.int, cWord *C.char) **C.char {
	if int(cI) < 0 || int(cI) >= len(editors) {
		return nil
	}
	st := &editors[int(cI)]
	if st.completer == nil {
		return nil
	}

	word := C.GoString(cWord)
	matches := st.completer.GetCompletions(word)
	if len(matches) == 0 {
		return nil
	}

	array := (**C.char)(C.malloc(C.size_t(C.sizeof_pchar * (len(matches) + 1))))
	for i, m := range matches {
		C.go_libedit_set_string_array(array, C.int(i), C.CString(m))
	}
	C.go_libedit_set_string_array(array, C.int(len(matches)), nil)
	return array
}
354397
func (d *Document) GetWordAfterCursorWithSpace() string {
	x := d.TextAfterCursor()
	return x[:d.FindEndOfCurrentWordWithSpace()]
}
378040
func NewSentenceTokenizer(s *Storage) *DefaultSentenceTokenizer {
	lang := NewPunctStrings()
	word := NewWordTokenizer(lang)

	annotations := NewAnnotations(s, lang, word)

	tokenizer := &DefaultSentenceTokenizer{
		Storage:       s,
		PunctStrings:  lang,
		WordTokenizer: word,
		Annotations:   annotations,
	}

	return tokenizer

}
96774
func (l *List) Init() *List {
	l.root.next = &l.root
	l.root.prev = &l.root
	l.len = 0
	return l
}
1251829
func (model *Model) Autocomplete(input string) ([]string, error) {
	model.RLock()
	defer model.RUnlock()
	if !model.UseAutocomplete {
		return []string{}, errors.New("Autocomplete is disabled")
	}
	if len(input) == 0 {
		return []string{}, errors.New("Input cannot have length zero")
	}
	express := "\x00" + input + "[^\x00]*"
	match, err := regexp.Compile(express)
	if err != nil {
		return []string{}, err
	}
	matches := model.SuffixArr.FindAllIndex(match, -1)
	a := &Autos{Results: make([]string, 0, len(matches)), Model: model}
	for _, m := range matches {
		str := strings.Trim(model.SuffixArrConcat[m[0]:m[1]], "\x00")
		if count, ok := model.Data[str]; ok {
			if count.Corpus > model.Threshold || count.Query > 0 {
				a.Results = append(a.Results, str)
			}
		}
	}
	sort.Sort(a)
	if len(a.Results) >= 10 {
		return a.Results[:10], nil
	}
	return a.Results, nil
}
751680
func (s *TasksListService) WaitForCompletion(waitForCompletion bool) *TasksListService {
	s.waitForCompletion = &waitForCompletion
	return s
}
671125
func doBreakWords(words []string, limit int) []string {
	var result []string

	for _, word := range words {
		if len(word) > limit {
			var parts []string
			var partBuf bytes.Buffer

			for _, char := range word {
				atLimit := partBuf.Len() == limit

				if atLimit {
					parts = append(parts, partBuf.String())

					partBuf.Reset()
				}

				partBuf.WriteRune(char)
			}

			if partBuf.Len() > 0 {
				parts = append(parts, partBuf.String())
			}

			for _, part := range parts {
				result = append(result, part)
			}
		} else {
			result = append(result, word)
		}
	}

	return result
}
735499
func (set WordSet) ContainsAll(i ...string) bool {
	for _, v := range i {
		if !set.Contains(v) {
			return false
		}
	}
	return true
}
616777
func WordWrap(in string, opts WordWrapOpts) string {
	opts = wwDefaults(opts)
	return goutils.WrapCustom(in, int(opts.Width), opts.LBSeq, false)
}
1230178
func MyWordCompleter(line string, pos int) (head string, c []string, tail string) {

	beg := []rune(line[:pos])
	end := line[pos:]
	Q("\nline = '%s' pos=%v\n", line, pos)
	Q("\nbeg = '%v'\nend = '%s'\n", string(beg), end)
	// find most recent paren in beg
	n := len(beg)
	last := n - 1
	var i int
	var p int = -1
outer:
	for i = last; i >= 0; i-- {
		Q("\nbeg[i=%v] is '%v'\n", i, string(beg[i]))
		switch beg[i] {
		case ' ':
			break outer
		case '(':
			p = i
			Q("\n found paren at p = %v\n", i)
			break outer
		}
	}
	Q("p=%d\n", p)
	prefix := string(beg)
	extendme := ""
	if p == 0 {
		prefix = ""
		extendme = string(beg)
	} else if p > 0 {
		prefix = string(beg[:p])
		extendme = string(beg[p:])
	}
	Q("prefix = '%s'\nextendme = '%s'\n", prefix, extendme)

	for _, n := range completion_keywords {
		if strings.HasPrefix(n, strings.ToLower(extendme)) {
			Q("n='%s' has prefix  = '%s'\n", n, extendme)
			c = append(c, n)
		}
	}

	return prefix, c, end
}
619116
func (s *ReindexService) WaitForCompletion(waitForCompletion bool) *ReindexService {
	s.waitForCompletion = &waitForCompletion
	return s
}
870487
func init() {
	docsProvider := func() map[string]interface{} {
		docs := make(map[string]interface{})

		docs["formats"] = DefaultFormats
		docs["layouts"] = createLayoutExamples()
		return docs
	}

	docshelper.AddDocProvider("output", docsProvider)
}
1026626
func (p *parser) atomWords() (a atom, start int, err error) {
	i := p.peek()
	start = i.start
	a = atom{}
	switch i.typ {
	case tokenLiteral:
		err = newParseExpError(noLiteralSupport, *i)
		return
	case tokenQuotedLiteral:
		err = newParseExpError(noQuotedLiteralSupport, *i)
		return
	case tokenColon:
		err = newParseExpError(predicateError, *i)
		return
	case tokenPredicate:
		i := p.next()
		a.predicate = i.val
	}
	for {
		switch p.peek().typ {
		case tokenColon:
			p.next()
			continue
		case tokenArg:
			i := p.next()
			a.args = append(a.args, i.val)
			continue
		case tokenQuotedArg:
			i := p.next()
			var uq string
			uq, err = strconv.Unquote(i.val)
			if err != nil {
				return
			}
			a.args = append(a.args, uq)
			continue
		}
		return
	}
}
761800
func (model *Model) TrainWord(term string) {
	model.Lock()
	if t, ok := model.Data[term]; ok {
		t.Corpus++
	} else {
		model.Data[term] = &Counts{1, 0}
	}
	// Set the max
	if model.Data[term].Corpus > model.Maxcount {
		model.Maxcount = model.Data[term].Corpus
		model.SuffDivergence++
	}
	// If threshold is triggered, store delete suggestion keys
	if model.Data[term].Corpus == model.Threshold {
		model.createSuggestKeys(term)
	}
	model.Unlock()
}
404951
func NewWordWrapWriter(w io.Writer, limit uint) io.Writer {
	return &wordWrapWriter{
		limit:  limit,
		writer: w,
	}
}