对所有表达式求值，只返回最后一个表达式的值
545914
public Object eval(Scope scope) {
		// 优化：绝大多数情况下 length 等于 1
		if (exprArray.length == 1) {
			return exprArray[0].eval(scope);
		}
		
		if (exprArray.length == 0) {
			return null;
		}
		
		int end = exprArray.length - 1;
		for (int i=0; i<end; i++) {
			exprArray[i].eval(scope);
		}
		return exprArray[end].eval(scope);
	}
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)
  }
90025
private static int getProcessPiece() {
		// 进程码
		// 因为静态变量类加载可能相同,所以要获取进程ID + 加载对象的ID值
		final int processPiece;
		// 进程ID初始化
		int processId;
		try {
			// 获取进程ID
			final String processName =ManagementFactory.getRuntimeMXBean().getName();
			final int atIndex = processName.indexOf('@');
			if (atIndex > 0) {
				processId = Integer.parseInt(processName.substring(0, atIndex));
			} else {
				processId = processName.hashCode();
			}
		} catch (Throwable t) {
			processId = RandomUtil.randomInt();
		}

		final ClassLoader loader = ClassLoaderUtil.getClassLoader();
		// 返回对象哈希码,无论是否重写hashCode方法
		int loaderId = (loader != null) ? System.identityHashCode(loader) : 0;

		// 进程ID + 对象加载ID
		StringBuilder processSb = new StringBuilder();
		processSb.append(Integer.toHexString(processId));
		processSb.append(Integer.toHexString(loaderId));
		// 保留前2位
		processPiece = processSb.toString().hashCode() & 0xFFFF;

		return processPiece;
	}
303479
function Overload() {
		if (arguments.length == 0) {
			throw new ERR.Arguments('1+', 0);
		}
		var args = Array.from(arguments);

		var method = args.pop();
		if (typeof method == 'function') {
			this.method = method;
		}
		else {
			throw new ERR.Generic('overloading implementation function missed');
		}

		// 支持可变长度参数后，用于代表值组长度的数字，也可以用 Param 实例来表征。
		// 在此我们仍保留 argLength，是出于提高性能的考虑。
		if (typeof args[0] == 'number' && args.length == 1) {
			// if (args.length > 1) {
			// 	throw new ERR.Arguments(2, args.length + 1);
			// }
			this.argLength = args[0];
		}
		else if (args[0] instanceof ParamList) {
			if (args.length > 1) {
				throw new ERR.Arguments(2, args.length + 1);
			}
			this.params = args[0];
		}
		else {
			this.params = ParamList.parse.apply(null, args);
		}
	}
219430
function queryBat (queue, cb) {
  const res = []

  queue.forEach(item => {
    const { selector, single, fields, component } = item
    // selector 的容器节点
    /* eslint-disable */
    const container = (
      component !== null ?
        (Nerv.findDOMNode(component) || document) :
        document
    )
    /* eslint-enable */

    // 特殊处理 ---- 选自己
    let selectSelf = false
    if (container !== document) {
      const $nodeList = container.parentNode.querySelectorAll(selector)
      for (let i = 0, len = $nodeList.length; i < len; ++i) {
        if (container === $nodeList[i]) {
          selectSelf = true
          break
        }
      }
    }

    if (single) {
      const el = selectSelf === true ? container : container.querySelector(selector)
      res.push(filter(fields, el, selector))
    } else {
      const $children = container.querySelectorAll(selector)
      const children = []
      selectSelf === true && children.push(container)
      for (let i = 0, len = $children.length; i < len; ++i) {
        children.push($children[i])
      }
      res.push(children.map(dom => filter(fields, dom)))
    }
  })
  cb(res)
}
1180319
private Map<String, Integer> getWordFrequency(String title, String snippet) {
        List<String> titleNames = new ArrayList<>();
        List<String> snippetNames = new ArrayList<>();

        //处理title
        List<Word> words = WordParser.parse(title);
        for (Word word : words) {
            if (word.getPartOfSpeech().getPos().startsWith(question.getQuestionType().getPos())) {
                titleNames.add(word.getText());
            }
        }
        //处理snippet
        words = WordParser.parse(snippet);
        for (Word word : words) {
            if (word.getPartOfSpeech().getPos().startsWith(question.getQuestionType().getPos())) {
                snippetNames.add(word.getText());
            }
        }
	    //统计词频
        //title中出现一次算两次
        //snippet中出现一次算一次
        Map<String, Integer> map = new HashMap<>();
        for (String name : titleNames) {
            Integer count = map.get(name);
            if (count == null) {
                count = TITLE_WEIGHT;
            } else {
                count += TITLE_WEIGHT;
            }
            map.put(name, count);
        }
        for (String name : snippetNames) {
            Integer count = map.get(name);
            if (count == null) {
                count = 1;
            } else {
                count++;
            }
            map.put(name, count);
        }

        return map;
    }
75607
protected void taggingWeightWithWordFrequency(List<Word> words1, List<Word> words2){
        if(words1.get(0).getWeight() != null || words2.get(0).getWeight() != null){
            if(LOGGER.isDebugEnabled()){
                LOGGER.debug("词已经被指定权重，不再使用词频进行标注");
            }
            return;
        }
        //词频统计
        Map<String, AtomicInteger> frequency1 = frequency(words1);
        Map<String, AtomicInteger> frequency2 = frequency(words2);
        //输出词频统计信息
        if(LOGGER.isDebugEnabled()){
            LOGGER.debug("词频统计1：\n{}", formatWordsFrequency(frequency1));
            LOGGER.debug("词频统计2：\n{}", formatWordsFrequency(frequency2));
        }
        //权重标注
        words1.parallelStream().forEach(word->{
            word.setWeight(frequency1.get(word.getText()).floatValue());
        });
        words2.parallelStream().forEach(word->{
            word.setWeight(frequency2.get(word.getText()).floatValue());
        });
    }
1351501
public ArrayList<Instance> readData(int limit, boolean keepNonProjective, boolean labeled, boolean rootFirst, boolean lowerCased, IndexMaps maps) throws IOException
    {
        HashMap<String, Integer> wordMap = maps.getWordId();
        ArrayList<Instance> instanceList = new ArrayList<Instance>();

        String line;
        ArrayList<Integer> tokens = new ArrayList<Integer>();
        ArrayList<Integer> tags = new ArrayList<Integer>();
        ArrayList<Integer> cluster4Ids = new ArrayList<Integer>();
        ArrayList<Integer> cluster6Ids = new ArrayList<Integer>();
        ArrayList<Integer> clusterIds = new ArrayList<Integer>();

        HashMap<Integer, Edge> goldDependencies = new HashMap<Integer, Edge>();
        int sentenceCounter = 0;
        while ((line = fileReader.readLine()) != null)
        {
            line = line.trim();
            if (line.length() == 0) // 句子分隔空白行
            {
                if (tokens.size() > 0)
                {
                    sentenceCounter++;
                    if (!rootFirst)
                    {
                        for (Edge edge : goldDependencies.values())
                        {
                            if (edge.headIndex == 0)
                                edge.headIndex = tokens.size() + 1;
                        }
                        tokens.add(0);
                        tags.add(0);
                        cluster4Ids.add(0);
                        cluster6Ids.add(0);
                        clusterIds.add(0);
                    }
                    Sentence currentSentence = new Sentence(tokens, tags, cluster4Ids, cluster6Ids, clusterIds);
                    Instance instance = new Instance(currentSentence, goldDependencies);
                    if (keepNonProjective || !instance.isNonprojective())
                        instanceList.add(instance);
                    goldDependencies = new HashMap<Integer, Edge>();
                    tokens = new ArrayList<Integer>();
                    tags = new ArrayList<Integer>();
                    cluster4Ids = new ArrayList<Integer>();
                    cluster6Ids = new ArrayList<Integer>();
                    clusterIds = new ArrayList<Integer>();
                }
                else
                {
                    goldDependencies = new HashMap<Integer, Edge>();
                    tokens = new ArrayList<Integer>();
                    tags = new ArrayList<Integer>();
                    cluster4Ids = new ArrayList<Integer>();
                    cluster6Ids = new ArrayList<Integer>();
                    clusterIds = new ArrayList<Integer>();
                }
                if (sentenceCounter >= limit)
                {
                    System.out.println("buffer full..." + instanceList.size());
                    break;
                }
            }
            else
            {
                String[] cells = line.split("\t");
                if (cells.length < 8)
                    throw new IllegalArgumentException("invalid conll format");
                int wordIndex = Integer.parseInt(cells[0]);
                String word = cells[1].trim();
                if (lowerCased)
                    word = word.toLowerCase();
                String pos = cells[3].trim();

                int wi = getId(word, wordMap);
                int pi = getId(pos, wordMap);

                tags.add(pi);
                tokens.add(wi);

                int headIndex = Integer.parseInt(cells[6]);
                String relation = cells[7];
                if (!labeled)
                    relation = "~";
                else if (relation.equals("_"))
                    relation = "-";

                if (headIndex == 0)
                    relation = "ROOT";

                int ri = getId(relation, wordMap);
                if (headIndex == -1)
                    ri = -1;

                int[] ids = maps.clusterId(word);
                clusterIds.add(ids[0]);
                cluster4Ids.add(ids[1]);
                cluster6Ids.add(ids[2]);

                if (headIndex >= 0)
                    goldDependencies.put(wordIndex, new Edge(headIndex, ri));
            }
        }
        if (tokens.size() > 0)
        {
            if (!rootFirst)
            {
                for (int gold : goldDependencies.keySet())
                {
                    if (goldDependencies.get(gold).headIndex == 0)
                        goldDependencies.get(gold).headIndex = goldDependencies.size() + 1;
                }
                tokens.add(0);
                tags.add(0);
                cluster4Ids.add(0);
                cluster6Ids.add(0);
                clusterIds.add(0);
            }
            sentenceCounter++;
            Sentence currentSentence = new Sentence(tokens, tags, cluster4Ids, cluster6Ids, clusterIds);
            instanceList.add(new Instance(currentSentence, goldDependencies));
        }

        return instanceList;
    }
1165842
private List<Word>[] fullSeg(String text){
        //文本长度
        final int textLen = text.length();
        //以每一个字作为词的开始，所能切分的词
        final List<String>[] sequence = new LinkedList[textLen];
        if(isParallelSeg()){
            //并行化
            List<Integer> list = new ArrayList<>(textLen);
            for(int i=0; i<textLen; i++){
                list.add(i);
            }
            list.parallelStream().forEach(i->sequence[i] = fullSeg(text, i));
        }else {
            //串行化
            for (int i = 0; i < textLen; i++) {
                sequence[i] = fullSeg(text, i);
            }
        }
        if(LOGGER.isDebugEnabled()){
            LOGGER.debug("全切分中间结果：");
            int i=1;
            for(List<String> list : sequence){
                LOGGER.debug("\t"+(i++)+"、"+list);
            }
        }
        //树叶
        List<Node> leaf = new LinkedList<>();
        for(String word : sequence[0]){
            //树根
            Node node = new Node(word);
            //把全切分中间结果（二维数组）转换为合理切分
            buildNode(node, sequence, word.length(), leaf);
        }
        //清理无用数据
        for(int j=0; j<sequence.length; j++){
            sequence[j].clear();
            sequence[j] = null;
        }
        //从所有树叶开始反向遍历出全切分结果
        List<Word>[] res = toWords(leaf);
        leaf.clear();
        return res;
    }
338923
private List<Statement> trim(List<Statement> nodes) throws ParseException {
        if (!removeDirectiveBlankLine) {
            return nodes;
        }

        // 待移除的空的 Text Node (主要是 Text Node 不允许为空的内容，只能在循环外把它delete了)
        List<Integer> empty_text_index_list = new ArrayList<Integer>();

        for (int i = 0; i < nodes.size(); i++) {
            Statement node = nodes.get(i);

            if (isTrimableDirective(node)) {
                if (i > 0) {
                    int prev_index = i - 1;
                    Statement prev = nodes.get(prev_index);

                    if (isNoLiteralText(prev)
                            && !empty_text_index_list.contains(prev_index)) {
                        // 删除上一个文本节点最后一个\n之后的所有空白符
                        String text = ((Text) prev).getContent();
                        int pos = text.lastIndexOf('\n');
                        if (pos >= 0) {
                            String tail = text.substring(pos + 1);
                            if (tail.length() > 0 && tail.trim().length() == 0) {
                                text = text.substring(0, pos + 1);
                                if (text.length() == 0) {
                                    empty_text_index_list.add(prev_index); // 将会是空节点，加入到待删除队列
                                } else {
                                    nodes.set(prev_index, new Text(text, false,
                                            prev.getOffset())); // 修改
                                }
                            }
                        }
                    }
                } // prev text node

                if (i + 1 < nodes.size()) {
                    int next_index = i + 1;
                    Statement next = nodes.get(next_index);

                    if (isNoLiteralText(next)) {
                        // 删除下一个文本节点地一个\n之前的所有空白符
                        String text = ((Text) next).getContent();
                        int pos = text.indexOf('\n');
                        if (pos >= 0) {
                            String head = text.substring(0, pos);
                            if (head.trim().length() == 0) {
                                text = text.substring(pos + 1);
                                boolean isEmptyNode = false;
                                if (text.length() == 0) {
                                    empty_text_index_list.add(next_index); // 将会是空节点，加入到待删除队列
                                    isEmptyNode = true;
                                } else if (text.indexOf('\n') == -1
                                        && text.trim().length() == 0) {
                                    // 看看下面是不是还是个指令，是不是可以全部丢掉
                                    if (next_index + 1 < nodes.size()) {
                                        Statement next_next = nodes
                                                .get(next_index + 1);
                                        if (isTrimableDirective(next_next)) {
                                            empty_text_index_list
                                                    .add(next_index); // 将会是空节点，加入到待删除队列
                                            isEmptyNode = true;
                                        }
                                    }
                                }
                                if (!isEmptyNode) {
                                    nodes.set(next_index, new Text(text, false,
                                            next.getOffset())); // 修改
                                }
                            }
                        }
                        i++; // skip next
                    }
                } // next text node
            } // not Directive
        }

        // 删除需要删掉的空节点。
        if (empty_text_index_list.size() > 0) {
            // 必须先删除后面的node
            for (int i = empty_text_index_list.size() - 1; i >= 0; i--) {
                int index = empty_text_index_list.get(i); // 必须转成小 int,
                // 否则就是删除对象，不是删除指定的index
                nodes.remove(index);
            }
        }
        return nodes;
    }
389834
private List<Word>[] toWords(List<Node> leaf){
        List<Word>[] result = new ArrayList[leaf.size()];
        int i = 0;
        if(LOGGER.isDebugEnabled()) {
            LOGGER.debug("全切分结果：");
        }
        for(Node node : leaf){
            result[i++] = toWords(node);
            if(LOGGER.isDebugEnabled()) {
                LOGGER.debug("\t" + i + "：" + result[i - 1]);
            }
        }
        return result;
    }
1166125
public QuestionStructure getMainPart(String question, List<edu.stanford.nlp.ling.Word> words) {
        QuestionStructure questionStructure = new QuestionStructure();
        questionStructure.setQuestion(question);

        Tree tree = LP.apply(words);
        LOG.info("句法树: ");
        tree.pennPrint();
        questionStructure.setTree(tree);

        GrammaticalStructure gs = GSF.newGrammaticalStructure(tree);
        if(gs == null){
            return null;
        }
        //获取依存关系
        Collection<TypedDependency> tdls = gs.typedDependenciesCCprocessed(true);
        questionStructure.setTdls(tdls);
        Map<String, String> map = new HashMap<>();
        String top = null;
        String root = null;
        LOG.info("句子依存关系：");
        //依存关系
        List<String> dependencies = new ArrayList<>();
        for (TypedDependency tdl : tdls) {
            String item = tdl.toString();
            dependencies.add(item);
            LOG.info("\t" + item);
            if (item.startsWith("top")) {
                top = item;
            }
            if (item.startsWith("root")) {
                root = item;
            }
            int start = item.indexOf("(");
            int end = item.lastIndexOf(")");
            item = item.substring(start + 1, end);
            String[] attr = item.split(",");
            String k = attr[0].trim();
            String v = attr[1].trim();
            String value = map.get(k);
            if (value == null) {
                map.put(k, v);
            } else {
                //有值
                value += ":";
                value += v;
                map.put(k, value);
            }
        }
        questionStructure.setDependencies(dependencies);

        String mainPartForTop = null;
        String mainPartForRoot = null;
        if (top != null) {
            mainPartForTop = topPattern(top, map);
        }
        if (root != null) {
            mainPartForRoot = rootPattern(root, map);
        }
        questionStructure.setMainPartForTop(mainPartForTop);
        questionStructure.setMainPartForRoot(mainPartForRoot);

        if (questionStructure.getMainPart() == null) {
            LOG.error("未能识别主谓宾：" + question);
        } else {
            LOG.info("主谓宾：" + questionStructure.getMainPart());
        }
        return questionStructure;
    }
306460
function merge(need, options, level){
    // 如果没有传第三个参数，默认无限递归右边覆盖左边
    if (level == undefined) level = -1;
    if (options === undefined) options = {};
    if (need.length == 1) return need[0];
    var res = {};
    for (var i = 0; i < need.length; i++){
        _merge(res, need[i], options, level - 1);
    }
    return res;
}
1020087
@Override
    public void recognition(Term[] terms) {
        int length = terms.length - 1;
        Term from = null;
        Term to = null;
        Term temp = null;
        for (int i = 0; i < length; i++) {
            if (terms[i] == null) {
                continue;
            } else if (".".equals(terms[i].getName()) || "．".equals(terms[i].getName())) {
                // 如果是.前后都为数字进行特殊处理
                to = terms[i].to();
                from = terms[i].from();
                if (from.termNatures().numAttr.flag && to.termNatures().numAttr.flag) {
                    from.setName(from.getName() + "." + to.getName());
                    TermUtil.termLink(from, to.to());
                    terms[to.getOffe()] = null;
                    terms[i] = null;
                    i = from.getOffe() - 1;
                }
                continue;
            } else if (!terms[i].termNatures().numAttr.flag) {
                continue;
            }

            temp = terms[i];
            // 将所有的数字合并
            while ((temp = temp.to()).termNatures().numAttr.flag) {
                terms[i].setName(terms[i].getName() + temp.getName());
            }
            // 如果是数字结尾
            if (MyStaticValue.isQuantifierRecognition && temp.termNatures().numAttr.numEndFreq > 0) {
                terms[i].setName(terms[i].getName() + temp.getName());
                temp = temp.to();
            }

            // 如果不等,说明terms[i]发生了改变
            if (terms[i].to() != temp) {
                TermUtil.termLink(terms[i], temp);
                // 将中间无用元素设置为null
                for (int j = i + 1; j < temp.getOffe(); j++) {
                    terms[j] = null;
                }
                i = temp.getOffe() - 1;
            }
        }

    }
1114330
function (element) {
            var self = this;
            var $el = self.$el;    // 隐藏当然不包含了
            // 隐藏当然不包含了
            if (!self.get('visible') || !$el) {
                return false;
            }
            if ($el && ($el[0] === element || $el.contains(element))) {
                return true;
            }
            var children = self.get('children');
            for (var i = 0, count = children.length; i < count; i++) {
                var child = children[i];
                if (child.containsElement && child.containsElement(element)) {
                    return true;
                }
            }
            return false;
        }
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);
            }
        }
    }
487373
@Override
	public T get() {
		T result = reference.get();

		if (result == null) {
			result = init();
			if (false == reference.compareAndSet(null, result)) {
				// 其它线程已经创建好此对象
				result = reference.get();
			}
		}

		return result;
	}