Look up a phrase on google
325873
def google(rest):
	""
	API_URL = 'https://www.googleapis.com/customsearch/v1?'
	try:
		key = pmxbot.config['Google API key']
	except KeyError:
		return "Configure 'Google API key' in config"
	# Use a custom search that searches everything normally
	# http://stackoverflow.com/a/11206266/70170
	custom_search = '004862762669074674786:hddvfu0gyg0'
	params = dict(
		key=key,
		cx=custom_search,
		q=rest.strip(),
	)
	url = API_URL + urllib.parse.urlencode(params)
	resp = requests.get(url)
	resp.raise_for_status()
	results = resp.json()
	hit1 = next(iter(results['items']))
	return ' - '.join((
		urllib.parse.unquote(hit1['link']),
		hit1['title'],
	))
774248
def _getPhrase( self, i, sentence, NPlabels ):
        ''' 
        ''' 
        phrase  = []
        indices = []
        if 0 <= i and i < len(sentence) and NPlabels[i] == 'B':
            phrase  = [ sentence[i] ]
            indices = [ i ]
            j = i + 1
            while ( j < len(sentence) ):
                if NPlabels[j] in ['B', '']:
                    break
                else:
                    phrase.append( sentence[j] )
                    indices.append( j )
                j += 1
        return phrase, indices
1292654
def search_reduced(self, text=None, lang=None, location=None, unit=None, limit=100, offset=0, local=None,
                       scope=SearchScope.PUBLIC):
        """"""
        return self.search(text, lang, location, unit, limit, offset, reduced=True, local=local, scope=scope)
1261895
def find(self, text):
        """"""
        for key, value in self:
            if (text in key) or (text in value):
                print(key, value)
1253418
function( text2search, noSearchPhrase, noSearchResult ) {

  Array.call( this );

  /**
   * Gets the text to search.
   * @type {string|null}
   */
  this.text2search = text2search || null;

  /**
   * Gets a message to display when search phrase is missing.
   * @type {string}
   */
  this.noSearchPhrase = noSearchPhrase;

  /**
   * Gets a message to display when search did not found the text in the contents.
   * @type {string}
   */
  this.noSearchResult = noSearchResult;
}
1000916
def candidates(word): 
    ""
    return (known([word]) or known(edits1(word)) or known(edits2(word)) or [word])
1367108
def _ExtractGMailSearchQuery(self, url):
    
    if 'search/' not in url:
      return None

    _, _, line = url.partition('search/')
    line, _, _ = line.partition('/')
    line, _, _ = line.partition('?')

    return line.replace('+', ' ')
975796
def getThesaurus(self, word):
        """"""
        response = requests.get(
            "http://api.wordnik.com:80/v4/word.json/%s/relatedWords?"
            "useCanonical=false&relationshipTypes=synonym&limitPer"
            "RelationshipType=15&api_key=%s" % (word, key)).json()
        try:
            return response[0]
        except IndexError:
            pass
1148170
function(item, term) {
            var numContextWords = 2;
            var text = item.content.match(
                "(?:\\s?(?:[\\w]+)\\s?){0,"+numContextWords+"}" +
                    term+"(?:\\s?(?:[\\w]+)\\s?){0,"+numContextWords+"}");
            item.context = text;
            return '<div class="autocomplete-suggestion" ' +
                'data-term="' + term + '" ' +
                'data-title="' + item.title + '" ' +
                'data-uri="'+ item.uri + '" ' +
                'data-context="' + item.context + '">' +
                '» ' + item.title +
                '<div class="context">' +
                (item.context || '') +'</div>' +
                '</div>';
        }
506968
def _phrase_query(self, term_list, field_name, field_type):
        
        term_list = [self._term_query(term, field_name, field_type,
                                      stemmed=False) for term in term_list]

        query = xapian.Query(xapian.Query.OP_PHRASE, term_list)
        return query
900653
def search(term)
      encoded_term = URI.encode(term)

      room_messages = connection.get("/search/#{encoded_term}.json")["messages"].select do |message|
        message[:room_id] == id
      end

      room_messages.map do |message|
        parse_message(message)
      end
    end
70198
function getKeyphrases(results, maximum) {
  var stemmedPhrases = {}
  var initialWords = []
  var stemmedPhrase
  var index
  var length
  var otherIndex
  var keyword
  var matches
  var phrase
  var stems
  var score
  var first
  var match

  // Iterate over all grouped important words...
  for (keyword in results) {
    matches = results[keyword].matches
    length = matches.length
    index = -1

    // Iterate over every occurence of a certain keyword...
    while (++index < length) {
      phrase = findPhrase(matches[index])
      stemmedPhrase = stemmedPhrases[phrase.value]
      first = phrase.nodes[0]

      match = {
        nodes: phrase.nodes,
        parent: matches[index].parent
      }

      // If we've detected the same stemmed phrase somewhere.
      if (own.call(stemmedPhrases, phrase.value)) {
        // Add weight per phrase to the score of the phrase.
        stemmedPhrase.score += stemmedPhrase.weight

        // If this is the first time we walk over the phrase (exact match but
        // containing another important word), add it to the list of matching
        // phrases.
        if (initialWords.indexOf(first) === -1) {
          initialWords.push(first)
          stemmedPhrase.matches.push(match)
        }
      } else {
        otherIndex = -1
        score = -1
        stems = phrase.stems

        initialWords.push(first)

        // For every stem in phrase, add its score to score.
        while (stems[++otherIndex]) {
          score += results[stems[otherIndex]].score
        }

        stemmedPhrases[phrase.value] = {
          score: score,
          weight: score,
          stems: stems,
          value: phrase.value,
          matches: [match]
        }
      }
    }
  }

  for (stemmedPhrase in stemmedPhrases) {
    phrase = stemmedPhrases[stemmedPhrase]

    // Modify its score to be the rounded result of multiplying it with the
    // number of occurances, and dividing it by the ammount of words in the
    // phrase.
    phrase.score = Math.round(
      (phrase.score * phrase.matches.length) / phrase.stems.length
    )
  }

  return filterResults(stemmedPhrases, maximum)
}
325311
def search(self, search_phrase, limit=None):
        

        query_parts = [
            'SELECT identifier, type, name, similarity(name, :word) AS sml',
            'FROM identifier_index',
            'WHERE name % :word',
            'ORDER BY sml DESC, name']

        query_params = {
            'word': search_phrase}

        if limit:
            query_parts.append('LIMIT :limit')
            query_params['limit'] = limit

        query_parts.append(';')

        query = text('\n'.join(query_parts))

        self.backend.library.database.set_connection_search_path()

        results = self.execute(query, **query_params).fetchall()

        for result in results:
            vid, type, name, score = result
            yield IdentifierSearchResult(
                score=score, vid=vid,
                type=type, name=name)
667314
def search_term(self):
        
        search_term = _c(self.request.get("searchTerm", ""))
        return search_term.lower().strip()
381523
def urban_lookup(word):
	'''
	
	'''
	url = "http://api.urbandictionary.com/v0/define"
	params = dict(term=word)
	resp = requests.get(url, params=params)
	resp.raise_for_status()
	res = resp.json()
	if not res['list']:
		return
	return res['list'][0]['definition']
649291
private List<String> getCorrectWords(List<String> wordsOrPhrases) {
    List<String> result = new ArrayList<>();
    for (String wordOrPhrase : wordsOrPhrases) {
      // this might be a phrase like "aufgrund dessen", so it needs to be split: 
      String[] words = tokenizeText(wordOrPhrase);
      boolean wordIsOkay = true;
      for (String word : words) {
        if (hunspellDict.misspelled(word)) {
          wordIsOkay = false;
          break;
        }
      }
      if (wordIsOkay) {
        result.add(wordOrPhrase);
      }
    }
    return result;
  }
1247649
def search_fast(self, text):
    """"""

    resp = self.impl.get(
        "{base_url}/{text}/json".format(base_url=self.base_url, text=text)
    )
    return resp.json()["info"]["package_url"]