• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java CollectionUtils类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: hIndex

import edu.stanford.nlp.util.CollectionUtils; //导入依赖的package包/类
/**
 * Calculate h-Index (Hirsch, 2005) of an author.
 *
 * A scientist has index h if h of their Np papers have at least h citations each,
 * and the other (Np − h) papers have at most h citations each.
 *
 * @param citationCounts Citation counts for each of the articles written by the
 *                       author. The keys can be anything, but the values should
 *                       be integers.
 * @return               The h-Index of the author.
 */
public static <E> int hIndex(Counter<E> citationCounts) {
  Counter<Integer> countCounts = new ClassicCounter<Integer>();
  for (double value: citationCounts.values()) {
    for (int i = 0; i <= value; ++i) {
      countCounts.incrementCount(i);
    }
  }
  List<Integer> citationCountValues = CollectionUtils.sorted(countCounts.keySet());
  Collections.reverse(citationCountValues);
  for (int citationCount: citationCountValues) {
    double occurrences = countCounts.getCount(citationCount);
    if (occurrences >= citationCount) {
      return citationCount;
    }
  }
  return 0;
}
 
开发者ID:FabianFriedrich,项目名称:Text2Process,代码行数:29,代码来源:Counters.java


示例2: hIndex

import edu.stanford.nlp.util.CollectionUtils; //导入依赖的package包/类
/**
 * Calculate h-Index (Hirsch, 2005) of an author.
 *
 * A scientist has index h if h of their Np papers have at least h citations
 * each, and the other (Np − h) papers have at most h citations each.
 *
 * @param citationCounts
 *          Citation counts for each of the articles written by the author.
 *          The keys can be anything, but the values should be integers.
 * @return The h-Index of the author.
 */
public static <E> int hIndex(Counter<E> citationCounts) {
  Counter<Integer> countCounts = new ClassicCounter<Integer>();
  for (double value : citationCounts.values()) {
    for (int i = 0; i <= value; ++i) {
      countCounts.incrementCount(i);
    }
  }
  List<Integer> citationCountValues = CollectionUtils.sorted(countCounts.keySet());
  Collections.reverse(citationCountValues);
  for (int citationCount : citationCountValues) {
    double occurrences = countCounts.getCount(citationCount);
    if (occurrences >= citationCount) {
      return citationCount;
    }
  }
  return 0;
}
 
开发者ID:paulirwin,项目名称:Stanford.NER.Net,代码行数:29,代码来源:Counters.java


示例3: 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


示例4: toStringSorted

import edu.stanford.nlp.util.CollectionUtils; //导入依赖的package包/类
/**
   * Write the features in text order.
   */
  public String toStringSorted() {
    StringBuffer sb = new StringBuffer(_docSource + "\t" + _relation.toString());
    
    for (String key : CollectionUtils.sorted(_featureCounts.keySet())) {
      sb.append("\t");
      sb.append(key);
//      sb.append("\t");
//      sb.append((int)_featureCounts.getCount(key));
    }
//    sb.append(Counters.toSortedByKeysString(_featureCounts, "%1$s %2$f", "\t", "HAPPY"));
    
    return sb.toString();
  }
 
开发者ID:nchambers,项目名称:schemas,代码行数:17,代码来源:TLinkDatum.java


示例5: getConnectedComponents

import edu.stanford.nlp.util.CollectionUtils; //导入依赖的package包/类
public static <V, E> List<Set<V>> getConnectedComponents(DirectedMultiGraph<V, E> graph) {
  List<Set<V>> ccs = new ArrayList<Set<V>>();
  LinkedList<V> todo = new LinkedList<V>();
  // TODO: why not a set?
  List<V> verticesLeft = CollectionUtils.toList(graph.getAllVertices());
  while (verticesLeft.size() > 0) {
    todo.add(verticesLeft.get(0));
    verticesLeft.remove(0);
    ccs.add(bfs(todo, graph, verticesLeft));
  }
  return ccs;
}
 
开发者ID:benblamey,项目名称:stanford-nlp,代码行数:13,代码来源:ConnectedComponents.java


示例6: maxInPlace

import edu.stanford.nlp.util.CollectionUtils; //导入依赖的package包/类
/**
 * Places the maximum of first and second keys values in the first counter.
 * @param <E>
 */
public static <E> void maxInPlace(Counter<E> target, Counter<E> other) {
 for(E e: CollectionUtils.union(other.keySet(), target.keySet())){
   target.setCount(e, Math.max(target.getCount(e), other.getCount(e)));
 }
}
 
开发者ID:paulirwin,项目名称:Stanford.NER.Net,代码行数:10,代码来源:Counters.java


示例7: minInPlace

import edu.stanford.nlp.util.CollectionUtils; //导入依赖的package包/类
/**
 * Places the minimum of first and second keys values in the first counter.
 * @param <E>
 */
public static <E> void minInPlace(Counter<E> target, Counter<E> other){
 for(E e: CollectionUtils.union(other.keySet(), target.keySet())){
   target.setCount(e, Math.min(target.getCount(e), other.getCount(e)));
 }
}
 
开发者ID:paulirwin,项目名称:Stanford.NER.Net,代码行数:10,代码来源:Counters.java


示例8: ExplicitTemporalSet

import edu.stanford.nlp.util.CollectionUtils; //导入依赖的package包/类
public ExplicitTemporalSet(Temporal... temporals) {
    this.temporals = CollectionUtils.asSet(temporals);
}
 
开发者ID:benblamey,项目名称:stanford-nlp,代码行数:4,代码来源:ExplicitTemporalSet.java


示例9: AttributesEqualMatchChecker

import edu.stanford.nlp.util.CollectionUtils; //导入依赖的package包/类
public AttributesEqualMatchChecker(Class... classes) {
  keys = CollectionUtils.asSet(classes);
}
 
开发者ID:benblamey,项目名称:stanford-nlp,代码行数:4,代码来源:CoreMapNodePattern.java


示例10: 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


示例11: getOutgoingEdges

import edu.stanford.nlp.util.CollectionUtils; //导入依赖的package包/类
public List<E> getOutgoingEdges(V v) {
  return CollectionUtils.flatten(outgoingEdges.get(v).values());
}
 
开发者ID:benblamey,项目名称:stanford-nlp,代码行数:4,代码来源:DirectedMultiGraph.java


示例12: getIncomingEdges

import edu.stanford.nlp.util.CollectionUtils; //导入依赖的package包/类
public List<E> getIncomingEdges(V v) {
  return CollectionUtils.flatten(incomingEdges.get(v).values());
}
 
开发者ID:benblamey,项目名称:stanford-nlp,代码行数:4,代码来源:DirectedMultiGraph.java


示例13: toSortedByKeysString

import edu.stanford.nlp.util.CollectionUtils; //导入依赖的package包/类
/**
 * Returns a string representation of a Counter, where (key, value) pairs are
 * sorted by key, and formatted as specified.
 *
 * @param counter       The Counter.
 * @param itemFormat    The format string for key/count pairs, where the key is
 *                      first and the value is second. To display the value first,
 *                      use argument indices, e.g. "%2$f %1$s".
 * @param joiner        The string used between pairs of key/value strings.
 * @param wrapperFormat The format string for wrapping text around the joined items,
 *                      where the joined item string value is "%s".
 * @return              The Counter, formatted as specified.
 */
public static <T extends Comparable<T>> String toSortedByKeysString(
    Counter<T> counter, String itemFormat, String joiner, String wrapperFormat) {
  List<String> strings = new ArrayList<String>();
  for (T key: CollectionUtils.sorted(counter.keySet())) {
    strings.add(String.format(itemFormat, key, counter.getCount(key)));
  }
  return String.format(wrapperFormat, StringUtils.join(strings, joiner));
}
 
开发者ID:FabianFriedrich,项目名称:Text2Process,代码行数:22,代码来源:Counters.java


示例14: toSortedByKeysString

import edu.stanford.nlp.util.CollectionUtils; //导入依赖的package包/类
/**
 * Returns a string representation of a Counter, where (key, value) pairs are
 * sorted by key, and formatted as specified.
 *
 * @param counter
 *          The Counter.
 * @param itemFormat
 *          The format string for key/count pairs, where the key is first and
 *          the value is second. To display the value first, use argument
 *          indices, e.g. "%2$f %1$s".
 * @param joiner
 *          The string used between pairs of key/value strings.
 * @param wrapperFormat
 *          The format string for wrapping text around the joined items, where
 *          the joined item string value is "%s".
 * @return The Counter, formatted as specified.
 */
public static <T extends Comparable<T>> String toSortedByKeysString(Counter<T> counter, String itemFormat, String joiner, String wrapperFormat) {
  List<String> strings = new ArrayList<String>();
  for (T key : CollectionUtils.sorted(counter.keySet())) {
    strings.add(String.format(itemFormat, key, counter.getCount(key)));
  }
  return String.format(wrapperFormat, StringUtils.join(strings, joiner));
}
 
开发者ID:paulirwin,项目名称:Stanford.NER.Net,代码行数:25,代码来源:Counters.java


示例15: compareArrays

import edu.stanford.nlp.util.CollectionUtils; //导入依赖的package包/类
/**
 * Provides a consistent ordering over arrays. First compares by the
 * first element. If that element is equal, the next element is
 * considered, and so on. This is the array version of
 * {@link edu.stanford.nlp.util.CollectionUtils#compareLists} 
 * and uses the same logic when the arrays are of different lengths.
 */
public static <T extends Comparable<T>> int compareArrays(T[] first, T[] second) {
 List<T> firstAsList = Arrays.asList(first);
 List<T> secondAsList = Arrays.asList(second);
 return CollectionUtils.compareLists(firstAsList, secondAsList);
}
 
开发者ID:UKPLab,项目名称:tac2015-event-detection,代码行数:13,代码来源:Arr.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java FeatureSequenceWithBigrams类代码示例发布时间:2022-05-22
下一篇:
Java ParagraphTextLayout类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap