Looks up all clients associated with any of the given keywords.

    Args:
      keywords: A list of keywords we are interested in.

    Returns:
      A dict mapping each keyword to a list of matching clients.
353037
def ReadClientPostingLists(self, keywords):
    

    start_time, end_time, filtered_keywords, _ = self._AnalyzeKeywords(keywords)

    # TODO(user): Make keyword index datetime aware so that
    # AsMicrosecondsSinceEpoch is unecessary.
    return self.ReadPostingLists(
        filtered_keywords,
        start_time=start_time.AsMicrosecondsSinceEpoch(),
        end_time=end_time.AsMicrosecondsSinceEpoch())
686358
def parse_filters_kwargs(request, client_keywords=None):
    
    filters = {}
    kwargs = {}
    client_keywords = client_keywords or {}
    for param in request.GET:
        param_value = PARAM_MAPPING.get(request.GET[param], request.GET[param])
        if param in client_keywords:
            kwargs[param] = param_value
        else:
            filters[param] = param_value
    return filters, kwargs
1027401
def SearchClients(query_str, token=None, limit=1000):
  """"""
  client_schema = aff4.AFF4Object.classes["VFSGRRClient"].SchemaCls
  index = client_index.CreateClientIndex(token=token)

  client_list = index.LookupClients([query_str])
  result_set = aff4.FACTORY.MultiOpen(client_list, token=token)
  results = []
  for result in result_set:
    results.append((result, str(result.Get(client_schema.HOSTNAME)),
                    str(result.Get(client_schema.OS_VERSION)),
                    str(result.Get(client_schema.PING))))
    if len(results) >= limit:
      break

  return results
1359105
def keyword_informations(keyword, options={})
      response = connection.get do |req|
        req.url "insight/keywords/#{keyword}", options
      end
      return_error_or_body(response)
    end
445216
def set_keywords(self, keywords):
        """"""
        self.head.keywords.attr(content=", ".join(keywords))
        return self
6765
def _get_keywords(self, **kwargs):
        """"""
        if self.jurisdiction and 'jurisdiction_id' not in kwargs:
            kwargs['jurisdiction_id'] = self.jurisdiction
        if 'count' in kwargs:
            kwargs['page_size'] = kwargs.pop('count')
        if 'start' in kwargs:
            start = kwargs.pop('start')
            if 'end' in kwargs:
                end = kwargs.pop('end')
            else:
                end = date.today().strftime('%m-%d-%Y')
            start, end = self._format_dates(start, end)
            kwargs['start_date'] = start
            kwargs['end_date'] = end
        elif 'between' in kwargs:
            start, end = kwargs.pop('between')
            start, end = self._format_dates(start, end)
            kwargs['start_date'] = start
            kwargs['end_date'] = end
        return kwargs
1130204
def _keys(self, pattern):
        
        result = []
        for client in self.redis_clients:
            result.extend(list(client.scan_iter(match=pattern)))
        return result
748293
def keywords_market_by_domain(domain_id, options={})
      response = connection.get do |req|
        req.url "insight/domains/#{domain_id}/keywords", options
      end
      return_error_or_body(response)
    end
390875
def _get_core_keywords(skw_matches, ckw_matches, spires=False):
    
    output = {}
    category = {}

    def _get_value_kw(kw):
        """Help to sort the Core keywords."""
        i = 0
        while kw[i].isdigit():
            i += 1
        if i > 0:
            return int(kw[:i])
        else:
            return 0

    for skw, info in skw_matches:
        if skw.core:
            output[skw.output(spires)] = len(info[0])
            category[skw.output(spires)] = skw.type
    for ckw, info in ckw_matches:
        if ckw.core:
            output[ckw.output(spires)] = len(info[0])
        else:
            # test if one of the components is  not core
            i = 0
            for c in ckw.getComponents():
                if c.core:
                    output[c.output(spires)] = info[1][i]
                i += 1
    output = [{'keyword': key, 'number': value}
              for key, value in output.iteritems()]
    return sorted(output, key=lambda x: x['number'], reverse=True)
758860
def get_clients_groups(self) -> typing.Iterator['Group']:
        
        for group in self.groups:

            if group.group_is_client_group:
                yield group
476032
def search(self, keyword):
        ''''''
        if type(keyword) != unicode: q = keyword.decode('utf-8')
        req = self.fetch(self.search_url, {'q':q.encode('gbk')})
        if not req: return None
        html = req.content.decode('gbk').encode('utf-8')
        soup = BeautifulSoup(html, convertEntities=BeautifulSoup.HTML_ENTITIES, markupMassage=hexentityMassage)
        cats = self.cats_parser(soup)
        keywords = self.keywords_parser(soup)
        mall_items = self.mall_items_parser(soup)
        total = int(soup.find('div', attrs={'class':'user-easy'}).find('a').string)
        lists = self.lists_parser(soup)
        ads = self.ads_parser(soup)
        return SearchResults(keyword, total, lists, mall_items, ads, cats, keywords)
531369
def keywords(text):
    
    text = split_words(text)
    numWords = len(text)  # of words before removing blacklist words
    freq = Counter(x for x in text if x not in stopWords)

    minSize = min(10, len(freq))  # get first 10
    keywords = {x: y for x, y in freq.most_common(minSize)}  # recreate a dict

    for k in keywords:
        articleScore = keywords[k]*1.0 / numWords
        keywords[k] = articleScore * 1.5 + 1

    return keywords
752302
def get_keyword_query(self, **kw):
        
        query = dict()

        # Only known indexes get observed
        indexes = self.catalog.get_indexes()

        # Handle additional keyword parameters
        for k, v in kw.iteritems():
            # handle uid in keywords
            if k.lower() == "uid":
                k = "UID"
            # handle portal_type in keywords
            if k.lower() == "portal_type":
                if v:
                    v = _.to_list(v)
            if k not in indexes:
                logger.warn("Skipping unknown keyword parameter '%s=%s'" % (k, v))
                continue
            if v is None:
                logger.warn("Skip None value in kw parameter '%s=%s'" % (k, v))
                continue
            logger.debug("Adding '%s=%s' to query" % (k, v))
            query[k] = v

        return query
1240538
def create_order_keyword_list(keywords):
     
    result = []
    for keyword in keywords:
        result.append((keyword, ''))
        result.append(('-%s' % keyword, ''))
    return result
109424
def param_keywords(self):
        
        return dict((key, self[key]) for key in self if key not in self.extra_keywords())
1330300
def get_all_client_tags(self, params=None):
        
        return self._iterate_through_pages(
            get_function=self.get_client_tags_per_page,
            resource=CLIENT_TAGS,
            **{'params': params}
        )
409411
def chunk(keywords, lines):
    
    chunks = dict()
    chunk = []
      
    # Create an empty dictionary using all the keywords
    for keyword in keywords:
        chunks[keyword] = []
    
    # Populate dictionary with lists of chunks associated
    # with the keywords in the list   
    for line in lines:
        if line.strip():
            token = line.split()[0]
            if token in keywords:
                chunk = [line]   
                chunks[token].append(chunk)   
            else:
                chunk.append(line)

    return chunks