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


Java CollectionUtils.sorted方法代码示例

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


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

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

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


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