当前位置: 首页>>代码示例>>Java>>正文


Java CollectionUtils.asList方法代码示例

本文整理汇总了Java中edu.stanford.nlp.util.CollectionUtils.asList方法的典型用法代码示例。如果您正苦于以下问题:Java CollectionUtils.asList方法的具体用法?Java CollectionUtils.asList怎么用?Java CollectionUtils.asList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在edu.stanford.nlp.util.CollectionUtils的用法示例。


在下文中一共展示了CollectionUtils.asList方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getMergedList

import edu.stanford.nlp.util.CollectionUtils; //导入方法依赖的package包/类
public List<CoreMap> getMergedList(int... groups)
{
  List<CoreMap> res = new ArrayList<CoreMap>();
  int last = 0;
  List<Integer> orderedGroups = CollectionUtils.asList(groups);
  Collections.sort(orderedGroups);
  for (int group:orderedGroups) {
    int groupStart = start(group);
    if (groupStart >= last) {
      res.addAll(elements.subList(last,groupStart));
      int groupEnd = end(group);
      if (groupEnd - groupStart >= 1) {
        CoreMap merged = createMergedChunk(groupStart, groupEnd);
        res.add(merged);
        last = groupEnd;
      }
    }
  }
  res.addAll(elements.subList(last, elements.size()));
  return res;
}
 
开发者ID:benblamey,项目名称:stanford-nlp,代码行数:22,代码来源:CoreMapSequenceMatcher.java

示例2: apply

import edu.stanford.nlp.util.CollectionUtils; //导入方法依赖的package包/类
public SequenceMatchResult<CoreMap> apply(SequenceMatchResult<CoreMap> matchResult, int... groups)
{
  BasicSequenceMatchResult<CoreMap> res = matchResult.toBasicSequenceMatchResult();

  List<? extends CoreMap> elements = matchResult.elements();
  List<CoreMap> mergedElements = new ArrayList<CoreMap>();
  res.elements = mergedElements;

  int last = 0;
  int mergedGroup = 0;
  int offset = 0;
  List<Integer> orderedGroups = CollectionUtils.asList(groups);
  Collections.sort(orderedGroups);
  for (int group:orderedGroups) {
    int groupStart = matchResult.start(group);
    if (groupStart >= last) {
      // Add elements from last to start of group to merged elements
      mergedElements.addAll(elements.subList(last,groupStart));
      // Fiddle with matched group indices
      for (; mergedGroup < group; mergedGroup++) {
        if (res.matchedGroups[mergedGroup] != null) {
          res.matchedGroups[mergedGroup].matchBegin -= offset;
          res.matchedGroups[mergedGroup].matchEnd -= offset;
        }
      }
      // Get merged element
      int groupEnd = matchResult.end(group);
      if (groupEnd - groupStart >= 1) {
        CoreMap merged = aggregator.merge(elements, groupStart, groupEnd);
        mergedElements.add(merged);
        last = groupEnd;

        // Fiddle with matched group indices
        res.matchedGroups[mergedGroup].matchBegin = mergedElements.size()-1;
        res.matchedGroups[mergedGroup].matchEnd = mergedElements.size();
        mergedGroup++;
        while (mergedGroup < res.matchedGroups.length)  {
          if (res.matchedGroups[mergedGroup] != null) {
            if (res.matchedGroups[mergedGroup].matchBegin == matchResult.start(group) &&
                    res.matchedGroups[mergedGroup].matchEnd == matchResult.end(group)) {
              res.matchedGroups[mergedGroup].matchBegin = res.matchedGroups[group].matchBegin;
              res.matchedGroups[mergedGroup].matchEnd = res.matchedGroups[group].matchEnd;
            } else if (res.matchedGroups[mergedGroup].matchEnd <= matchResult.end(group)) {
              res.matchedGroups[mergedGroup] = null;
            } else {
              break;
            }
          }
          mergedGroup++;
        }
        offset = matchResult.end(group) - res.matchedGroups[group].matchEnd;
      }
    }
  }
  // Add rest of elements
  mergedElements.addAll(elements.subList(last, elements.size()));
  // Fiddle with matched group indices
  for (; mergedGroup < res.matchedGroups.length; mergedGroup++) {
    if (res.matchedGroups[mergedGroup] != null) {
      res.matchedGroups[mergedGroup].matchBegin -= offset;
      res.matchedGroups[mergedGroup].matchEnd -= offset;
    }
  }
  return res;
}
 
开发者ID:benblamey,项目名称:stanford-nlp,代码行数:66,代码来源:CoreMapSequenceMatchAction.java


注:本文中的edu.stanford.nlp.util.CollectionUtils.asList方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。