Given a list of results sorted in decreasing importance, strip results that are close to another result with the same name
321585
function stripDuplicates(results) {
  var i;
  var placeshash = {};
  var stripped = [];
  for (i = 0; i < results.length; i++) {
    var lat = Number(results[i].location.split(",")[0]).toFixed(1);
    var lng = Number(results[i].location.split(",")[1]).toFixed(1);

    var hash = results[i].name + "_" + lat + " " + lng;
    if (!defined(placeshash[hash])) {
      placeshash[hash] = results[i];
      stripped.push(results[i]);
    }
  }
  return stripped;
}
462006
function filterResults(results, maximum) {
  var filteredResults = []
  var indices = []
  var matrix = {}
  var column
  var key
  var score
  var interpolated
  var index
  var otherIndex
  var maxScore

  for (key in results) {
    score = results[key].score

    if (!matrix[score]) {
      matrix[score] = []
      indices.push(score)
    }

    matrix[score].push(results[key])
  }

  indices.sort(reverse)

  maxScore = indices[0]

  index = -1

  while (indices[++index]) {
    score = indices[index]
    column = matrix[score]

    interpolated = score / maxScore
    otherIndex = -1

    while (column[++otherIndex]) {
      column[otherIndex].score = interpolated
    }

    filteredResults = filteredResults.concat(column)

    if (filteredResults.length >= maximum) {
      break
    }
  }

  return filteredResults
}
343710
def __process_results(results):
    
    if 'no match' in results and 'returning 0 elements' in results:
        return []

    result_list = []

    # Splts the result and cuts first and last dataset which are comments
    split = results.split(sep='\n\n')[1:-1]

    for entry in split:
        entry_dict = {}
        for value in entry.split('\n'):
            if len(value) < 1:
                continue
            (desc, val) = value.split(': ')
            entry_dict[desc.replace('-', '')] = val.strip(' ')
        result_list.append(entry_dict)
    return result_list
933411
def strip_prefix_from_list(list, strip):
    
    for i in range(len(list)):
        list[i] = strip_prefix(list[i], strip)
1275828
def get_close_matches(word, possibilities, n=None, cutoff=0.6):
    """"""
    if n is None:
        n = settings.num_close_matches
    return difflib_get_close_matches(word, possibilities, n, cutoff)
525356
private function pruneResults(/*iterable*/ $results)
    {
        $buffer = [];
        foreach ($results as $item) {
            $buffer[] = $item;

            if (count($buffer) > 50) {
                $this->clearTokenBuffer($buffer);
                $buffer = [];
            }
        }

        $this->clearTokenBuffer($buffer);
    }
1051318
def _prune(self, pop_candidates):
        
        return set(
            sorted(pop_candidates, key=self._score, reverse=True)
            [:self.args.max_pop]
        )
500680
def cancelAllPendingResults( self ):
        """"""
        for k in self._results.keys():
            rs = self._results[k]
            self._results[k] = [ j for j in rs if isinstance(j, dict) ]
        self._pending = dict()
372025
def trim(self, count, approximate=True):
        
        return self.database.xtrim(self.key, count, approximate)
1022690
def remove_duplicates(seq, idfun=None):
    
    # order preserving
    if idfun is None:

        def idfun(x):
            return x

    seen = {}
    result = []
    for item in seq:
        marker = idfun(item)
        # in old Python versions:
        # if seen.has_key(marker)
        # but in new ones:
        if marker in seen: continue
        seen[marker] = 1
        result.append(item)
    return result
137665
def sortBy(self, *args):
        ''''''
        criteria = ['seeds', 'size']
        for k in args:
            if k in criteria:
                self.results = sorted(
                    self.results, key=attrgetter(k), reverse=True)
        return self
920194
def remove_duplicates(list_to_prune: List) -> List:
    
    temp_dict = collections.OrderedDict()
    for item in list_to_prune:
        temp_dict[item] = None

    return list(temp_dict.keys())
558096
def _compare_rows(from_recs, to_recs, keys):
    ""
    return set(
        k for k in keys
        if sorted(from_recs[k].items()) != sorted(to_recs[k].items())
    )
1029413
def filter(self, table, mappings, filter_string):
        """"""
        q = filter_string.lower()
        return [mapping for mapping in mappings
                if q in mapping.ud.lower()]
983956
def strip_tail(sequence, values):
    """"""
    return list(reversed(list(strip_head(reversed(sequence), values))))
971909
def defer_reduce(func, items, test, accum=None):
    '''
    '''
    removals = []

    for k, item in enumerate(items):
        if test(item, accum):
            removals.append(k)
            if accum is None:
                accum = item
            else:
                accum = func(accum, item)
        
    deferred = indices_removed(items, removals)
    
    if deferred == items or not deferred:
        return accum, deferred

    return defer_reduce(func, deferred, test, accum)
990713
def last_n_results(self, n):
        
        return list(
            itertools.islice(
                self.results, len(self.results) - n, len(self.results)
            )
        )