把带声调字符替换为没有声调的字符
164453
def replace_symbol_to_no_symbol(pinyin):
    """"""
    def _replace(match):
        symbol = match.group(0)  # 带声调的字符
        # 去掉声调: a1 -> a
        return RE_NUMBER.sub(r'', PHONETIC_SYMBOL_DICT[symbol])

    # 替换拼音中的带声调字符
    return RE_PHONETIC_SYMBOL.sub(_replace, pinyin)
323133
public void showConflict(){
        int emptySlot=0;
        //key:冲突长度 value:冲突个数
        Map<Integer, Integer> map = new HashMap<>();
        for(TrieNode<V> node : ROOT_NODES_INDEX){
            if(node == null){
                emptySlot++;
            }else{
                int i=0;
                while((node = node.getSibling()) != null){
                    i++;
                }
                if(i > 0){
                    Integer count = map.get(i);
                    if(count == null){
                        count = 1;
                    }else{
                        count++;
                    }
                    map.put(i, count);
                }
            }
        }
        int count=0;
        for(int key : map.keySet()){
            int value = map.get(key);
            count += key*value;
            LOGGER.info("冲突次数为："+key+" 的元素个数："+value);
        }
        LOGGER.info("冲突次数："+count);
        LOGGER.info("总槽数："+INDEX_LENGTH);
        LOGGER.info("用槽数："+(INDEX_LENGTH-emptySlot));
        LOGGER.info("使用率："+(float)(INDEX_LENGTH-emptySlot)/INDEX_LENGTH*100+"%");
        LOGGER.info("剩槽数："+emptySlot);
    }
371541
function () {

    var keys = Object.keys(wating);

    /*
     * 检测依赖关系，
     * FIXME 暂时未处理循环依赖.以及始终不满足执行条件的情况.
     */
    keys.forEach(function (name) {
        var args = [];
        var factory = wating[name][0];
        var depends = wating[name][1];
        var done = wating[name][2];

        var canDo = depends.every(function (name) {

            // 插件系统中内容优先，资源池中置后
            var value = working[name] || Resource[name];

            if (value) {
                args.push(value);
                return true;
            }

            return false;
        });

        if (canDo) {
            // 先移除，防止callback中检测依赖时产生的循环
            delete wating[name];

            //  判断异步及同步
            if (done) {
                args.push(done);
                factory.apply( {}, args);
            } else {
                try {
                    var value = working[name] = factory.apply( {}, args);

                    oldDefineOfPlugin.call(Plugin, name, value);
                }catch(err) {
                    stdLog(['%s, can not start the plug-in [%s], \nstack:', err.stack, name], 'crash');
                    process.exit(0);
                    return;
                }
            }
        }
    });
}
1134077
public boolean isSimpleCount(PlainSelect select) {
        //包含group by的时候不可以
        if (select.getGroupByColumnReferences() != null) {
            return false;
        }
        //包含distinct的时候不可以
        if (select.getDistinct() != null) {
            return false;
        }
        for (SelectItem item : select.getSelectItems()) {
            //select列中包含参数的时候不可以，否则会引起参数个数错误
            if (item.toString().contains("?")) {
                return false;
            }
            //如果查询列中包含函数，也不可以，函数可能会聚合列
            if (item instanceof SelectExpressionItem) {
                Expression expression = ((SelectExpressionItem) item).getExpression();
                if (expression instanceof Function) {
                    String name = ((Function) expression).getName();
                    if (name != null) {
                        String NAME = name.toUpperCase();
                        if(skipFunctions.contains(NAME)){
                            //go on
                        } else if(falseFunctions.contains(NAME)){
                            return false;
                        } else {
                            for (String aggregateFunction : AGGREGATE_FUNCTIONS) {
                                if(NAME.startsWith(aggregateFunction)){
                                    falseFunctions.add(NAME);
                                    return false;
                                }
                            }
                            skipFunctions.add(NAME);
                        }
                    }
                }
            }
        }
        return true;
    }
389516
function (cell, bottom, ignoreRange) {
            try {
                var cellInfo = this.getCellInfo(cell),
                    nextRowIndex, nextColIndex;
                var len = this.selectedTds.length && !ignoreRange,
                    range = this.cellsRange;
                //末行或者末列没有后置单元格
                if ((!bottom && (cellInfo.rowIndex == 0)) || (bottom && (!len ? (cellInfo.rowIndex + cellInfo.rowSpan > this.rowsNum - 1) : (range.endRowIndex == this.rowsNum - 1)))) return null;

                nextRowIndex = !bottom ? ( !len ? cellInfo.rowIndex - 1 : range.beginRowIndex - 1)
                    : ( !len ? (cellInfo.rowIndex + cellInfo.rowSpan) : range.endRowIndex + 1);
                nextColIndex = !len ? cellInfo.colIndex : range.beginColIndex;
                return this.getCell(this.indexTable[nextRowIndex][nextColIndex].rowIndex, this.indexTable[nextRowIndex][nextColIndex].cellIndex);
            } catch (e) {
                showError(e);
            }
        }
119460
function () {
                    var index = 0;

                    while (index < fireLength) {

                        if ([].indexOf.call(arguments, list[index]) !== -1) {

                            // 从队列中删除当前回调
                            list.splice(index, 1);

                            // 如果当前回调队列被多层嵌套执行
                            // 上几层队列也可能会受到影响
                            if (firing) {
                                if (fireQueue.length) {
                                    fireQueue.forEach(function (value, key) {
                                        // 被删除的回调位于当前索引位置前面
                                        // 当前索引位置自减1
                                        if (index <= value) {
                                            fireQueue[key]--;
                                        }
                                    });
                                }

                                // 如果被删除的函数的索引位置在fireIndex的前面
                                // fireIndex自减1

                                if (index <= fireIndex) {
                                    fireIndex--;
                                }
                            }

                            // 回调列表长度改变
                            fireLength--;
                        } else {
                            index++;
                        }
                    }

                    return this;
                }
429831
public function init()
    {
        /**
         * 设置默认时区
         */
        if ($this->timezone)
        {
            date_default_timezone_set($this->timezone);
        }

        /**
         * 设置地区信息（地域信息）
         */
        if ($this->locale)
        {
            setlocale(LC_ALL, $this->locale);
        }

        if ($this->charset && function_exists('mb_internal_encoding'))
        {
            mb_internal_encoding($this->charset);
        }

        /**
         * 当输入字符的编码是无效的，或者字符代码不存在于输出的字符编码中时，可以为其指定一个替代字符。
         *
         * @link http://www.php.net/manual/function.mb-substitute-character.php
         */
        mb_substitute_character('none');

        // 确保输入的数据安全
        $_GET = Security::sanitize($_GET);
        $_POST = Security::sanitize($_POST);
        $_COOKIE = Security::sanitize($_COOKIE);

        self::cleanComponents();
    }
1236450
function (len, min, dataTypeName, chars) {
      // 疑是 id 字段
      if (utils.isLikeId(dataTypeName)) {
        return String(utils.getId());
      }
      // 对疑是 xxx time 或者 xxx date 的字段, 返回当前时间之前一个月内的随机时间
      if (utils.isLikeTime(dataTypeName) || utils.isLikeDate(dataTypeName)) {
        return String(Date.now() - this._getNum(2592000));
      }
      // 疑是 email 字段
      if (utils.isLikeEmail(dataTypeName)) {
        return this._getStr(9, 6) + '@' + this._getStr(5) + '.' + this._getStr(3, null, null, ALPHA_LOWER_CASE_CHARS);
      }
      // 疑是 url 字段
      if (utils.isLikeUrl(dataTypeName)) {
        return 'http://' + this._getStr(3, null, null, ALPHA_LOWER_CASE_CHARS) + '.' + this._getStr(5, 15, null, ALPHA_LOWER_CASE_CHARS) + '.' + this._getStr(2, 8, null, ALPHA_LOWER_CASE_CHARS);
      }
      len = len || 10;
      if (min != undefined) {
        len = this._getNum(len, min);
      }
      var i;
      var str = '';
      chars = chars || ALPHA_NUMERIC_CHARS;
      var charsCount = chars.length;
      for (i = 0; i < len; i++) {
        str += chars[Math.floor(Math.random() * charsCount)];
      }
      return str;
    }
215406
function () {
                var self = this, cs = [], i, c = self.constructor, attrs = self.getAttrs();
                while (c) {
                    cs.push(c);
                    c = c.superclass && c.superclass.constructor;
                }
                cs.reverse();    // from super class to sub class
                // from super class to sub class
                for (i = 0; i < cs.length; i++) {
                    var ATTRS = cs[i].ATTRS || {};
                    for (var attributeName in ATTRS) {
                        if (attributeName in attrs) {
                            var attributeValue, onSetMethod;
                            var onSetMethodName = ON_SET + ucfirst(attributeName);    // 存在方法，并且用户设置了初始值或者存在默认值，就同步状态
                            // 存在方法，并且用户设置了初始值或者存在默认值，就同步状态
                            if ((onSetMethod = self[onSetMethodName]) && // 用户如果设置了显式不同步，就不同步，
                                // 比如一些值从 html 中读取，不需要同步再次设置
                                attrs[attributeName].sync !== 0 && (attributeValue = self.get(attributeName)) !== undefined) {
                                onSetMethod.call(self, attributeValue);
                            }
                        }
                    }
                }
            }
559251
public function ping()
    {
        $ping_data = $this->pingData ? (string)$this->pingData : null;
        $raw = false;
        if ($this->protocolAccelerate && $ping_data && $this->protocol) {
            $ping_data = $this->preEncodeForClient($ping_data);
            $raw = true;
        }
        // 遍历所有客户端连接
        foreach ($this->_clientConnections as $connection) {
            // 上次发送的心跳还没有回复次数大于限定值就断开
            if ($this->pingNotResponseLimit > 0 &&
                $connection->pingNotResponseCount >= $this->pingNotResponseLimit * 2
            ) {
                $connection->destroy();
                continue;
            }
            // $connection->pingNotResponseCount 为 -1 说明最近客户端有发来消息，则不给客户端发送心跳
            $connection->pingNotResponseCount++;
            if ($ping_data) {
                if ($connection->pingNotResponseCount === 0 ||
                    ($this->pingNotResponseLimit > 0 && $connection->pingNotResponseCount % 2 === 1)
                ) {
                    continue;
                }
                $connection->send($ping_data, $raw);
            }
        }
    }
697634
private static String getColumnNameFromGetter(Method getter,Field f){
		String columnName = "";
		Column columnAnno = getter.getAnnotation(Column.class);
		if(columnAnno != null){
			//如果是列注解就读取name属性
			columnName = columnAnno.name();
		}
		
		if(columnName == null || "".equals(columnName)){
			//如果没有列注解就用命名方式去猜
			columnName = IdUtils.toUnderscore(f.getName());
		}
		return columnName;
	}
934460
function(id) {
            for (var i in this.ids) {
                if (this.ids[i][id]) {
                    return this.ids[i][id];
                }
            }
            return null;
        }
1072419
function getCustomDeps(info) {
    var res = [];

    if (info.modules && Array.isArray(info.modules)) {
        info = info.modules;
    }
    else {
        info = [];
    }

    info.forEach(function (item) {
        // 只包含额外需要包含的模块
        // 对额外排除的模块不做处理
        if (item.charAt(0) === '~') {
            res.push(item.substring(1));
        }
    });

    return res;
}
662178
function mergeDetail(allEle, addEle, attrName, type) {

    if (allEle[attrName] && addEle[attrName]) {
        if (type == 1) {
            for (var k in allEle[attrName]) {
                //todo 现在没有考虑两个文件中同一项覆盖率的统计行数不一致的问题
                if ( parseInt(allEle[attrName][k])==0 &&  parseInt(addEle[attrName][k]) ==1) {
                    allEle[attrName][k] = 1;
                }
            }
        }
        else if (type == 2) {
            for (var k in allEle[attrName]) {
                //todo 现在没有考虑两个文件中同一项覆盖率的统计行数不一致的问题
                if (addEle[attrName][k]) {
                    if (parseInt(allEle[attrName][k][0])==0 &&parseInt(addEle[attrName][k][0])==1 ) {
                        allEle[attrName][k][0] = 1;
                    }
                    if (parseInt(allEle[attrName][k][1])==0 &&parseInt(addEle[attrName][k][1])==1 ) {
                        allEle[attrName][k][1] = 1;
                    }
                }
            }
        }
    }
    return allEle;
}
746962
private AbstractHelperDialect getDialect(MappedStatement ms) {
        //改为对dataSource做缓存
        DataSource dataSource = ms.getConfiguration().getEnvironment().getDataSource();
        String url = getUrl(dataSource);
        if (urlDialectMap.containsKey(url)) {
            return urlDialectMap.get(url);
        }
        try {
            lock.lock();
            if (urlDialectMap.containsKey(url)) {
                return urlDialectMap.get(url);
            }
            if (StringUtil.isEmpty(url)) {
                throw new PageException("无法自动获取jdbcUrl，请在分页插件中配置dialect参数!");
            }
            String dialectStr = fromJdbcUrl(url);
            if (dialectStr == null) {
                throw new PageException("无法自动获取数据库类型，请通过 helperDialect 参数指定!");
            }
            AbstractHelperDialect dialect = initDialect(dialectStr, properties);
            urlDialectMap.put(url, dialect);
            return dialect;
        } finally {
            lock.unlock();
        }
    }
109656
private boolean hasRegisterMapper(Class<?> mapperInterface){
        //如果一个都没匹配上，很可能是还没有注册 mappers，此时通过 @RegisterMapper 注解进行判断
        Class<?>[] interfaces = mapperInterface.getInterfaces();
        boolean hasRegisterMapper = false;
        if (interfaces != null && interfaces.length > 0) {
            for (Class<?> anInterface : interfaces) {
                //自动注册标记了 @RegisterMapper 的接口
                if(anInterface.isAnnotationPresent(RegisterMapper.class)){
                    hasRegisterMapper = true;
                    //如果已经注册过，就避免在反复调用下面会迭代的方法
                    if (!registerMapper.containsKey(anInterface)) {
                        registerMapper(anInterface);
                    }
                }
                //如果父接口的父接口存在注解，也可以注册
                else if(hasRegisterMapper(anInterface)){
                    hasRegisterMapper = true;
                }
            }
        }
        return hasRegisterMapper;
    }
569714
function(results) {
    /*
    将所有集合求其交集; 第一个集合是最小的数组
    */
    results.sort(function(a, b) {
      a.length - b.length
    })

    var firstArr  = results[0].length
      , objectIDs = []

    for (var i = 0; i < results[0].length; i++) {
      var item = results[0][i]
        , flag = true

      for (var j = 1; j < results.length; j++) {
        if (results[j].indexOf(item) < 0) {
          flag = false
          j = results.length
        }
      }

      flag && objectIDs.push(item)
    }

    getFromIDs(objectIDs)
  }