Get suggestions.
194901
def get(self, **kwargs):
        """"""
        completions = []
        size = request.values.get('size', type=int)

        for k in self.suggesters.keys():
            val = request.values.get(k)
            if val:
                # Get completion suggestions
                opts = copy.deepcopy(self.suggesters[k])

                if 'context' in opts.get('completion', {}):
                    ctx_field = opts['completion']['context']
                    ctx_val = request.values.get(ctx_field)
                    if not ctx_val:
                        raise SuggestMissingContextRESTError
                    opts['completion']['context'] = {
                        ctx_field: ctx_val
                    }

                if size:
                    opts['completion']['size'] = size

                completions.append((k, val, opts))

        if not completions:
            raise SuggestNoCompletionsRESTError(
                ', '.join(sorted(self.suggesters.keys())))

        # Add completions
        s = self.search_class()
        for field, val, opts in completions:
            source = opts.pop('_source', None)
            if source is not None and ES_VERSION[0] >= 5:
                s = s.source(source).suggest(field, val, **opts)
            else:
                s = s.suggest(field, val, **opts)

        if ES_VERSION[0] == 2:
            # Execute search
            response = s.execute_suggest().to_dict()
            for field, _, _ in completions:
                for resp in response[field]:
                    for op in resp['options']:
                        if 'payload' in op:
                            op['_source'] = copy.deepcopy(op['payload'])
        elif ES_VERSION[0] >= 5:
            response = s.execute().to_dict()['suggest']

        result = dict()
        for field, val, opts in completions:
            result[field] = response[field]

        return make_response(jsonify(result))
990162
def run(self):
        """"""
        if len(self._argv) > 1 and len(self._argv[1]) > 0:
            oper = self._argv[1]
        else:
            oper = 'fetch'
        if oper == 'fetch':
            ret = self.fetch()
        elif oper == 'config':
            ret = self.config()
            if ret and self._dirtyConfig:
                ret = self.fetch()
        elif oper == 'autoconf':
            ret = self.autoconf()
            if ret:
                print "yes"
            else:
                print "no"
            ret = True
        elif oper == 'suggest':
            ret = self.suggest()
        else:
            raise AttributeError("Invalid command argument: %s" % oper)
        return ret
357529
def find_suggestions(filelist):
    """"""
    suggestions = set()
    unknowns = []
    for filename in filelist:
        if os.path.isdir(filename):
            # it's impossible to add empty directories via MANIFEST.in anyway,
            # and non-empty directories will be added automatically when we
            # specify patterns for files inside them
            continue
        for pattern, suggestion in SUGGESTIONS:
            m = pattern.match(filename)
            if m is not None:
                suggestions.add(pattern.sub(suggestion, filename))
                break
        else:
            unknowns.append(filename)
    return sorted(suggestions), unknowns
1069523
private static void addSuggestion(List<LocationSuggestion> suggestions, String address) {

        suggestions.add(new LocationSuggestion(address));
    }
1348197
function suggest (opts) {
  return new Promise(function (resolve) {
    if (!opts && !opts.term) {
      throw Error('term missing');
    }

    return resolve(BASE_URL + encodeURIComponent(opts.term));
  })
    .then(url => common.request(url, {}, opts.requestOptions))
    .then(parseXML)
    .then(extractSuggestions);
}
765049
def update_iteration_num_suggestions(self, num_suggestions):
        """"""
        iteration_config = self.experiment_group.iteration_config

        iteration_config.num_suggestions = num_suggestions
        self._update_config(iteration_config)
499539
def suggest(url)
      options = create_params({url: url})
      suggested = self.class.get('/posts/suggest', options)['suggested']
      popular = suggested['popular']
      popular = [] if popular.nil?
      popular = [popular] if popular.class != Array

      recommended = suggested['recommended']
      recommended = [] if recommended.nil?
      recommended = [recommended] if recommended.class != Array

      {:popular => popular, :recommended => recommended}
    end
1320648
public SuggestIndexResponse index(final SuggestItem[] items) {
        // TODO parallel?
        final SuggestItem[] array = Stream.of(items).filter(item -> !item.isBadWord(badWords)).toArray(n -> new SuggestItem[n]);

        try {
            final long start = System.currentTimeMillis();
            final SuggestWriterResult result = suggestWriter.write(client, settings, index, array, true);
            return new SuggestIndexResponse(items.length, items.length, result.getFailures(), System.currentTimeMillis() - start);
        } catch (Exception e) {
            throw new SuggestIndexException("Failed to write items[" + items.length + "] to " + index, e);
        }
    }
335641
function (suggestionsList, suggestion) {
                for (var i = 0, l = suggestionsList.length; i < l; i++) {
                    if (suggestion.label == suggestionsList[i].label) {
                        return i;
                    }
                }
                return -1;
            }
420748
def suggest_move(self, position):
        
        start = time.time()

        if self.timed_match:
            while time.time() - start < self.seconds_per_move:
                self.tree_search()
        else:
            current_readouts = self.root.N
            while self.root.N < current_readouts + self.num_readouts:
                self.tree_search()
            if self.verbosity > 0:
                dbg("%d: Searched %d times in %.2f seconds\n\n" % (
                    position.n, self.num_readouts, time.time() - start))

        # print some stats on moves considered.
        if self.verbosity > 2:
            dbg(self.root.describe())
            dbg('\n\n')
        if self.verbosity > 3:
            dbg(self.root.position)

        return self.pick_move()
1164587
def suggestion_list(input_: str, options: Collection[str]):
    
    options_by_distance = {}
    input_threshold = len(input_) // 2

    for option in options:
        distance = lexical_distance(input_, option)
        threshold = max(input_threshold, len(option) // 2, 1)
        if distance <= threshold:
            options_by_distance[option] = distance

    return sorted(options_by_distance, key=options_by_distance.get)
670931
def search_suggestion(self, query):
		

		response = self._call(
			mc_calls.QuerySuggestion,
			query
		)
		suggested_queries = response.body.get('suggested_queries', [])

		return [
			suggested_query['suggestion_string']
			for suggested_query in suggested_queries
		]
976258
function (suggestions) {

                if (typesUtil.isArray(suggestions)) {
                    var newSuggestions = [], suggestionsLabel = this._options.labelKey, suggestionsCode = this._options.codeKey;
                    if (this._options.sortingMethod && typesUtil.isFunction(this._options.sortingMethod)) {
                        suggestions.sort(this._options.sortingMethod);
                    } else {
                        suggestions.sort(function (a, b) {
                            return (a[suggestionsLabel] < b[suggestionsLabel])
                                    ? 1
                                    : (a[suggestionsLabel] > b[suggestionsLabel]) ? -1 : 0;
                        });
                    }

                    for (var index = 0, l = suggestions.length; index < l; index++) {
                        var suggestion = suggestions[index], eachSuggestion = {};
                        if (this.__islabelCode && !jsonValidator.check(suggestion, this.SUGGESTION_BEAN)) {
                            return this.$logError(this.INVALID_SUGGESTIONS, null, suggestions);

                        } else if (!(suggestion.hasOwnProperty(suggestionsLabel) && suggestion.hasOwnProperty(suggestionsCode))) {
                            return this.$logError(this.INVALID_KEYCODE, null, suggestions);
                        }
                        eachSuggestion.label = suggestion[suggestionsLabel];
                        eachSuggestion.code = suggestion[suggestionsCode];
                        var newSuggestion = {
                            label : stringUtil.stripAccents(eachSuggestion.label).toLowerCase(),
                            code : stringUtil.stripAccents(eachSuggestion.code).toLowerCase(),
                            original : eachSuggestion
                        };
                        if (this._labelMatchAtWordBoundaries) {
                            newSuggestion.wordBoundaries = this.__getWordBoundaries(newSuggestion.label);
                        }
                        newSuggestions.push(newSuggestion);
                    }
                    this._suggestions = newSuggestions;

                } else {
                    return this.$logError(this.INVALD_SUGGESTION_TYPE, null, suggestions);
                }

            }
1001503
def domain_suggestions(self, query, **kwargs):
        """"""
        return self._results('domain-suggestions', '/v1/domain-suggestions', query=delimited(query, ' '),
                            items_path=('suggestions', ), **kwargs)
285254
function(suggestions, completer, token) {
    var hintList = [];
    for (var i = 0; i < suggestions.length; i++) {
      var suggestedString = suggestions[i];
      if (completer.postProcessToken) {
        suggestedString = completer.postProcessToken(token, suggestedString);
      }
      hintList.push({
        text: suggestedString,
        displayText: suggestedString,
        hint: selectHint
      });
    }

    var cur = yasqe.getCursor();
    var returnObj = {
      completionToken: token.string,
      list: hintList,
      from: {
        line: cur.line,
        ch: token.start
      },
      to: {
        line: cur.line,
        ch: token.end
      }
    };
    //if we have some autocompletion handlers specified, add these these to the object. Codemirror will take care of firing these
    if (completer.callbacks) {
      for (var callbackName in completer.callbacks) {
        if (completer.callbacks[callbackName]) {
          YASQE.on(returnObj, callbackName, completer.callbacks[callbackName]);
        }
      }
    }
    return returnObj;
  }
231302
def spelling_suggestions(self):
        """"""
        if not self.is_tagged(WORDS):
            self.tokenize_words()
        return [data[SUGGESTIONS] for data in vabamorf.spellcheck(self.word_texts, suggestions=True)]
590452
def gain_focus(self):
        """"""
        if (self.is_running and self.any_has_focus() and 
            not self.setting_data and self.hidden):
            self.unhide_tips()