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

Java Sets类代码示例

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

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



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

示例1: computeSimilarity

import edu.stanford.nlp.util.Sets; //导入依赖的package包/类
@Override
public double computeSimilarity(Concept c1, Concept c2) {
	if (c1.name.toLowerCase().equals(c2.name.toLowerCase()))
		return 1;

	Set<String> c1Stems = this.stem(c1);
	Set<String> c2Stems = this.stem(c2);

	Set<String> intsect = Sets.intersection(c1Stems, c2Stems);
	Set<String> union = Sets.union(c1Stems, c2Stems);

	double sim = 0;
	if (union.size() == 0)
		sim = 0;
	else
		sim = intsect.size() / (float) union.size();

	return sim;
}
 
开发者ID:UKPLab,项目名称:ijcnlp2017-cmaps,代码行数:20,代码来源:JaccardDistance.java


示例2: score

import edu.stanford.nlp.util.Sets; //导入依赖的package包/类
@Override
public Map<String, Double> score(JCas jcas) throws AnalysisEngineProcessException {
  List<JCas> views = ViewType.listViews(jcas, viewNamePrefix);
  List<Integer> negativeWordsCounts = new ArrayList<>();
  List<Integer> positiveWordsCounts = new ArrayList<>();
  Map<String, Double> features = new HashMap<>();
  for (JCas view : views) {
    Set<String> tokens = TypeUtil.getOrderedTokens(view).stream().flatMap(
            token -> Stream.of(token.getLemmaForm(), token.getCoveredText().toLowerCase()))
            .collect(toSet());
    Set<String> containedPositiveWords = Sets.intersection(tokens, positiveWords);
    positiveWordsCounts.add(containedPositiveWords.isEmpty() ? 0 : 1);
    containedPositiveWords.forEach(word -> features.put("[email protected]" + word, 1.0));
    Set<String> containedNegativeWords = Sets.intersection(tokens, negativeWords);
    negativeWordsCounts.add(containedNegativeWords.isEmpty() ? 0 : 1);
    containedNegativeWords.forEach(word -> features.put("[email protected]" + word, 1.0));
  }
  features.putAll(YesNoScorer.aggregateFeatures(negativeWordsCounts, "negative-words"));
  features.putAll(YesNoScorer.aggregateFeatures(positiveWordsCounts, "positive-words"));
  return features;
}
 
开发者ID:oaqa,项目名称:bioasq,代码行数:22,代码来源:SentimentYesNoScorer.java


示例3: lastF1

import edu.stanford.nlp.util.Sets; //导入依赖的package包/类
public ClassicCounter<OUT> lastF1() {
  ClassicCounter<OUT> result = new ClassicCounter<OUT>();
  Set<OUT> keys = Sets.union(previousGuessed.keySet(),previousGold.keySet());
  for(OUT key : keys) {
    result.setCount(key,lastF1(key));
  }
  return result;
}
 
开发者ID:FabianFriedrich,项目名称:Text2Process,代码行数:9,代码来源:EquivalenceClassEval.java


示例4: f1

import edu.stanford.nlp.util.Sets; //导入依赖的package包/类
public static <E> Counter<E> f1(Counter<E> precision, Counter<E> recall) {
  Counter<E> result = precision.getFactory().create();
  for(E key : Sets.intersection(precision.keySet(),recall.keySet())) {
    result.setCount(key,f1(precision.getCount(key),recall.getCount(key)));
  }
  return result;
}
 
开发者ID:FabianFriedrich,项目名称:Text2Process,代码行数:8,代码来源:EquivalenceClassEval.java


示例5: intersection

import edu.stanford.nlp.util.Sets; //导入依赖的package包/类
/**
 * Returns a counter that is the intersection of c1 and c2.  If both c1 and c2 contain a
 * key, the min of the two counts is used.
 *
 * @return A counter that is the intersection of c1 and c2
 */
public static <E> Counter<E> intersection(Counter<E> c1, Counter<E> c2) {
  Counter<E> result = c1.getFactory().create();
  for (E key : Sets.union(c1.keySet(), c2.keySet())) {
    double count1 = c1.getCount(key);
    double count2 = c2.getCount(key);
    double minCount = (count1 < count2 ? count1 : count2);
    if (minCount > 0) {
      result.setCount(key, minCount);
    }
  }
  return result;
}
 
开发者ID:FabianFriedrich,项目名称:Text2Process,代码行数:19,代码来源:Counters.java


示例6: jaccardCoefficient

import edu.stanford.nlp.util.Sets; //导入依赖的package包/类
/**
 * Returns the Jaccard Coefficient of the two counters. Calculated as
 * |c1 intersect c2| / ( |c1| + |c2| - |c1 intersect c2|
 *
 * @return The Jaccard Coefficient of the two counters
 */
public static <E> double jaccardCoefficient(Counter<E> c1, Counter<E> c2) {
  double minCount = 0.0, maxCount = 0.0;
  for (E key : Sets.union(c1.keySet(), c2.keySet())) {
    double count1 = c1.getCount(key);
    double count2 = c2.getCount(key);
    minCount += (count1 < count2 ? count1 : count2);
    maxCount += (count1 > count2 ? count1 : count2);
  }
  return minCount / maxCount;
}
 
开发者ID:FabianFriedrich,项目名称:Text2Process,代码行数:17,代码来源:Counters.java


示例7: product

import edu.stanford.nlp.util.Sets; //导入依赖的package包/类
/**
 * Returns the product of c1 and c2.
 *
 * @return The product of c1 and c2.
 */
public static <E> Counter<E> product(Counter<E> c1, Counter<E> c2) {
  Counter<E> result = c1.getFactory().create();
  for (E key : Sets.intersection(c1.keySet(), c2.keySet())) {
    result.setCount(key, c1.getCount(key) * c2.getCount(key));
  }
  return result;
}
 
开发者ID:FabianFriedrich,项目名称:Text2Process,代码行数:13,代码来源:Counters.java


示例8: absoluteDifference

import edu.stanford.nlp.util.Sets; //导入依赖的package包/类
/**
 * Returns |c1 - c2|.
 *
 * @return The difference between sets c1 and c2.
 */
public static <E> Counter<E> absoluteDifference(Counter<E> c1, Counter<E> c2) {
  Counter<E> result = c1.getFactory().create();
  for (E key : Sets.union(c1.keySet(), c2.keySet())) {
    double newCount = Math.abs(c1.getCount(key) - c2.getCount(key));
    if (newCount > 0) {
      result.setCount(key, newCount);
    }
  }
  return result;
}
 
开发者ID:FabianFriedrich,项目名称:Text2Process,代码行数:16,代码来源:Counters.java


示例9: division

import edu.stanford.nlp.util.Sets; //导入依赖的package包/类
/**
 * Returns c1 divided by c2.  Note that this can create NaN if c1 has non-zero counts for keys that
 * c2 has zero counts.
 *
 * @return c1 divided by c2.
 */
public static <E> Counter<E> division(Counter<E> c1, Counter<E> c2) {
  Counter<E> result = c1.getFactory().create();
  for (E key : Sets.union(c1.keySet(), c2.keySet())) {
    result.setCount(key, c1.getCount(key) / c2.getCount(key));
  }
  return result;
}
 
开发者ID:FabianFriedrich,项目名称:Text2Process,代码行数:14,代码来源:Counters.java


示例10: diff

import edu.stanford.nlp.util.Sets; //导入依赖的package包/类
public static <T> Counter<T> diff(Counter<T> goldFeatures, Counter<T> guessedFeatures) {
  Counter<T> result = goldFeatures.getFactory().create();
  for (T key : Sets.union(goldFeatures.keySet(), guessedFeatures.keySet())) {
    result.setCount(key, goldFeatures.getCount(key) - guessedFeatures.getCount(key));
  }
  retainNonZeros(result);
  return result;
}
 
开发者ID:FabianFriedrich,项目名称:Text2Process,代码行数:9,代码来源:Counters.java


示例11: intersection

import edu.stanford.nlp.util.Sets; //导入依赖的package包/类
/**
 * Returns a counter that is the intersection of c1 and c2. If both c1 and c2
 * contain a key, the min of the two counts is used.
 *
 * @return A counter that is the intersection of c1 and c2
 */
public static <E> Counter<E> intersection(Counter<E> c1, Counter<E> c2) {
  Counter<E> result = c1.getFactory().create();
  for (E key : Sets.union(c1.keySet(), c2.keySet())) {
    double count1 = c1.getCount(key);
    double count2 = c2.getCount(key);
    double minCount = (count1 < count2 ? count1 : count2);
    if (minCount > 0) {
      result.setCount(key, minCount);
    }
  }
  return result;
}
 
开发者ID:paulirwin,项目名称:Stanford.NER.Net,代码行数:19,代码来源:Counters.java


示例12: jaccardCoefficient

import edu.stanford.nlp.util.Sets; //导入依赖的package包/类
/**
 * Returns the Jaccard Coefficient of the two counters. Calculated as |c1
 * intersect c2| / ( |c1| + |c2| - |c1 intersect c2|
 *
 * @return The Jaccard Coefficient of the two counters
 */
public static <E> double jaccardCoefficient(Counter<E> c1, Counter<E> c2) {
  double minCount = 0.0, maxCount = 0.0;
  for (E key : Sets.union(c1.keySet(), c2.keySet())) {
    double count1 = c1.getCount(key);
    double count2 = c2.getCount(key);
    minCount += (count1 < count2 ? count1 : count2);
    maxCount += (count1 > count2 ? count1 : count2);
  }
  return minCount / maxCount;
}
 
开发者ID:paulirwin,项目名称:Stanford.NER.Net,代码行数:17,代码来源:Counters.java


示例13: add

import edu.stanford.nlp.util.Sets; //导入依赖的package包/类
public static <E> Counter<E> add(Counter<E> c1, Counter<E> c2) {
  Counter<E> result = c1.getFactory().create();
  for (E key : Sets.union(c1.keySet(), c2.keySet())) {
    result.setCount(key, c1.getCount(key) + c2.getCount(key));
  }
  retainNonZeros(result);
  return result;
}
 
开发者ID:paulirwin,项目名称:Stanford.NER.Net,代码行数:9,代码来源:Counters.java


示例14: division

import edu.stanford.nlp.util.Sets; //导入依赖的package包/类
/**
 * Returns c1 divided by c2. Note that this can create NaN if c1 has non-zero
 * counts for keys that c2 has zero counts.
 *
 * @return c1 divided by c2.
 */
public static <E> Counter<E> division(Counter<E> c1, Counter<E> c2) {
  Counter<E> result = c1.getFactory().create();
  for (E key : Sets.union(c1.keySet(), c2.keySet())) {
    result.setCount(key, c1.getCount(key) / c2.getCount(key));
  }
  return result;
}
 
开发者ID:paulirwin,项目名称:Stanford.NER.Net,代码行数:14,代码来源:Counters.java


示例15: isContextOverlapping

import edu.stanford.nlp.util.Sets; //导入依赖的package包/类
private static boolean isContextOverlapping(Mention m1, Mention m2) {
  Set<String> context1 = Generics.newHashSet();
  Set<String> context2 = Generics.newHashSet();
  context1.addAll(m1.getContext());
  context2.addAll(m2.getContext());
  return Sets.intersects(context1, context2);
}
 
开发者ID:benblamey,项目名称:stanford-nlp,代码行数:8,代码来源:Rules.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Java KeyModifier类代码示例发布时间:2022-05-22
下一篇:
Java PluginDescriptor类代码示例发布时间: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