搜索歌曲，支持搜索歌曲、歌手、专辑等

    :param keyword: 关键词
    :param type: (optional) 搜索类型，1: 单曲, 100: 歌手, 1000: 歌单, 1002: 用户
    :param offset: (optional) 分段起始位置，默认 0
    :param limit: (optional) 数据上限多少行，默认 30
339283
def search(keyword, type=1, offset=0, limit=30):
    
    if keyword is None:
        raise ParamsError()
    r = NCloudBot()
    r.method = 'SEARCH'
    r.data = {
        's': keyword,
        'limit': str(limit),
        'type': str(type),
        'offset': str(offset)
    }
    r.send()

    return r.response
771213
function _numberToKey(index, totalChar, offset) {
    var aArr = [],
      currentChar = index;
    totalChar = totalChar || 26;
    offset = offset || 65;
    while (currentChar >= totalChar) {
      aArr.push((currentChar % totalChar) + offset);
      currentChar = Math.floor(currentChar / totalChar - 1);
    }
    aArr.push(currentChar + offset);
    return aArr.reverse();
  }
1082516
def prepare(query, params):
    
    def repl(match):
        name = match.group(1)[1:]
        if name in params:
            return marshal(params[name])
        return ":%s" % name

    new, count = re.subn(_param_re, repl, query)

    if len(params) > count:
        raise cql.ProgrammingError("More keywords were provided "
                                   "than parameters")
    return new
136540
def all(cls, start_position="", max_results=100, qb=None):
        
        return cls.where("", start_position=start_position, max_results=max_results, qb=qb)
1167743
def metrolyrics(song):
    
    translate = {URLESCAPE: '', ' ': '-'}
    title = song.title.lower()
    title = normalize(title, translate)
    title = re.sub(r'\-{2,}', '-', title)
    artist = song.artist.lower()
    artist = normalize(artist, translate)
    artist = re.sub(r'\-{2,}', '-', artist)

    url = 'http://www.metrolyrics.com/{}-lyrics-{}.html'.format(title, artist)
    soup = get_url(url)
    body = soup.find(id='lyrics-body-text')
    if body is None:
        return ''

    text = ''
    verses = body.find_all('p')
    for verse in verses:
        text += verse.get_text().strip()
        text += '\n\n'

    return text.strip()
236488
def getMusicAlbumList(self, tagtype = 0, startnum = 0, pagingrow = 100):
        

        url = nurls['setProperty']

        data = {'userid': self.user_id,
                'useridx': self.useridx,
                'tagtype': tagtype,
                'startnum': startnum,
                'pagingrow': pagingrow,
                }

        r = self.session.post(url = url, data = data)

        return resultManager(r.text)
200361
def top_playlist_highquality(cat='全部', offset=0, limit=20):
    
    r = NCloudBot()
    r.method = 'TOP_PLAYLIST_HIGHQUALITY'
    r.data = {'cat': cat, 'offset': offset, 'limit': limit}
    r.send()

    return r.response
109424
def param_keywords(self):
        
        return dict((key, self[key]) for key in self if key not in self.extra_keywords())
985028
private String limitString() {
        if(params.length != 2){
            throw new IllegalArgumentException("Wrong number of Parameters for limit string expression");
        }

        final String field = record.getValueByFieldName(params[0]);
        int limit = Integer.parseInt(params[1]);

        if (field.isEmpty() || field.length() < limit){
            return field;
        }

        String result = field.substring(0, limit) + "...";
        return result;
    }
1246637
function simpleparser (options) {
  var parameterLimit = options.parameterLimit !== undefined
    ? options.parameterLimit
    : 1000
  var parse = parser('querystring')

  if (isNaN(parameterLimit) || parameterLimit < 1) {
    throw new TypeError('option parameterLimit must be a positive number')
  }

  if (isFinite(parameterLimit)) {
    parameterLimit = parameterLimit | 0
  }

  return function queryparse (body) {
    var paramCount = parameterCount(body, parameterLimit)

    if (paramCount === undefined) {
      debug('too many parameters')
      throw createError(413, 'too many parameters')
    }

    debug('parse urlencoding')
    return parse(body, undefined, undefined, {maxKeys: parameterLimit})
  }
}
811495
def popular_songs(type = 'daily')
      fail ArgumentError, 'Invalid type' unless %w(daily monthly).include?(type)
      request('popularGetSongs', type: type)['songs'].map { |s| Song.new(s) }
    end
131899
def collection(self, user_id):
        
        # TODO further evaluation of the page param, I don't know where the
        # limit is.
        dct = {'userID': user_id, 'page': 0}
        r = 'userGetSongsInLibrary'
        result = self.connection.request(r, dct, self.connection.header(r))
        songs = result[1]['Songs']
        return [Song.from_response(song, self.connection) for song in songs]
1353015
def keywords(s, top=10, **kwargs):
    
    return parser.find_keywords(s, top=top, frequency=parser.frequency)
310827
def query_all(**kwargs):
        '''
        
        '''
        kind = kwargs.get('kind', '1')
        limit = kwargs.get('limit', 10)

        return TabPost.select().where(
            (TabPost.kind == kind) &
            (TabPost.valid == 1)
        ).order_by(
            TabPost.time_update.desc()
        ).limit(limit)
178785
def get_tracks(self, offset=0, limit=50):
        
        response = self.client.get(
            self.client.USER_TRACKS % (self.name, offset, limit))
        return self._parse_response(response, strack)
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)
1065811
private Summary explan(List<Keyword> keywords, String content) {

        SmartForest<Double> sf = new SmartForest<>();

        for (Keyword keyword : keywords) {
            sf.add(keyword.getName(), keyword.getScore());
        }

        // 先断句
        List<Sentence> sentences = toSentenceList(content.toCharArray());

        for (Sentence sentence : sentences) {
            computeScore(sentence, sf);
        }

        double maxScore = 0;
        int maxIndex = 0;

        MapCount<String> mc = new MapCount<>();

        for (int i = 0; i < sentences.size(); i++) {
            double tempScore = sentences.get(i).score;
            int tempLength = sentences.get(i).value.length();
            mc.addAll(sentences.get(i).mc.get());

            if (tempLength >= len) {
                tempScore = tempScore * mc.get().size();
                if (maxScore < tempScore) {
                    maxScore = tempScore;
                    maxIndex = i;
                    continue;
                }
                mc.get().clear();
            }
            for (int j = i + 1; j < sentences.size(); j++) {
                tempScore += sentences.get(j).score;
                tempLength += sentences.get(j).value.length();
                mc.addAll(sentences.get(j).mc.get());

                if (tempLength >= len) {
                    tempScore = tempScore * mc.get().size();
                    if (maxScore < tempScore) {
                        maxScore = tempScore;
                        maxIndex = i;
                    }
                    mc.get().clear();
                    break;
                }
            }

            if (tempLength < len) {
                tempScore = tempScore * mc.get().size();
                if (maxScore < tempScore) {
                    maxScore = tempScore;
                    maxIndex = i;
                    break;
                }
                mc.get().clear();
            }
        }

        StringBuilder sb = new StringBuilder();
        for (int i = maxIndex; i < sentences.size(); i++) {
            sb.append(sentences.get(i).value);
            if (sb.length() > len) {
                break;
            }
        }

        String summaryStr = sb.toString();

        /**
         * 是否强制文本长度。对于abc这种字符算半个长度
         */

        if (isSplitSummary && sb.length() > len) {
            double value = len;

            StringBuilder newSummary = new StringBuilder();
            char c = 0;
            for (int i = 0; i < sb.length(); i++) {
                c = sb.charAt(i);
                if (c < 256) {
                    value -= 0.5;
                } else {
                    value -= 1;
                }

                if (value < 0) {
                    break;
                }

                newSummary.append(c);
            }

            summaryStr = newSummary.toString();
        }

        return new Summary(keywords, summaryStr);
    }