edu.illinois.cs.cogcomp.lbjava.classify.Feature.equals()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(8.9k)|赞(0)|评价(0)|浏览(104)

本文整理了Java中edu.illinois.cs.cogcomp.lbjava.classify.Feature.equals()方法的一些代码示例,展示了Feature.equals()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Feature.equals()方法的具体详情如下:
包路径:edu.illinois.cs.cogcomp.lbjava.classify.Feature
类名称:Feature
方法名:equals

Feature.equals介绍

[英]Two Features are equal when their packages and generating classifiers are equivalent.
[中]当两个Feature的包和生成分类器相等时,它们是相等的。

代码示例

代码示例来源:origin: edu.illinois.cs.cogcomp/LBJava

/**
 * Two conjunctions are equivalent when their arguments are equivalent.
 *
 * @return <code>true</code> iff the argument is an equivalent <code>Feature</code>.
 **/
public boolean equals(Object o) {
  if (!super.equals(o))
    return false;
  RealConjunctiveFeature c = (RealConjunctiveFeature) o;
  return (left == c.left || left.equals(c.left))
      && (right == c.right || right.equals(c.right));
}

代码示例来源:origin: CogComp/cogcomp-nlp

public FeatureVector classify(Object __example)
{
 if (!(__example instanceof NEWord))
 {
  String type = __example == null ? "null" : __example.getClass().getName();
  System.err.println("Classifier 'FeaturesLevel1Only$$4(NEWord)' defined on line 370 of LbjTagger.lbj received '" + type + "' as input.");
  new Exception().printStackTrace();
  System.exit(1);
 }
 FeatureVector __result;
 __result = new FeatureVector();
 FeatureVector leftVector = left.classify(__example);
 int N = leftVector.featuresSize();
 FeatureVector rightVector = right.classify(__example);
 int M = rightVector.featuresSize();
 for (int i = 0; i < N; ++i)
 {
  Feature lf = leftVector.getFeature(i);
  for (int j = 0; j < M; ++j)
  {
   Feature rf = rightVector.getFeature(j);
   if (lf.equals(rf)) continue;
   __result.addFeature(lf.conjunction(rf, this));
  }
 }
 __result.sort();
 return __result;
}

代码示例来源:origin: CogComp/cogcomp-nlp

public FeatureVector classify(Object __example)
{
 if (!(__example instanceof Relation))
 {
  String type = __example == null ? "null" : __example.getClass().getName();
  System.err.println("Classifier 'combinedFeatures$$0(Relation)' defined on line 237 of extent.lbj received '" + type + "' as input.");
  new Exception().printStackTrace();
  System.exit(1);
 }
 FeatureVector __result;
 __result = new FeatureVector();
 FeatureVector leftVector = left.classify(__example);
 int N = leftVector.featuresSize();
 FeatureVector rightVector = right.classify(__example);
 int M = rightVector.featuresSize();
 for (int i = 0; i < N; ++i)
 {
  Feature lf = leftVector.getFeature(i);
  for (int j = 0; j < M; ++j)
  {
   Feature rf = rightVector.getFeature(j);
   if (lf.equals(rf)) continue;
   __result.addFeature(lf.conjunction(rf, this));
  }
 }
 __result.sort();
 return __result;
}

代码示例来源:origin: CogComp/cogcomp-nlp

public FeatureVector classify(Object __example)
{
 if (!(__example instanceof NEWord))
 {
  String type = __example == null ? "null" : __example.getClass().getName();
  System.err.println("Classifier 'FeaturesLevel2$$5(NEWord)' defined on line 521 of LbjTagger.lbj received '" + type + "' as input.");
  new Exception().printStackTrace();
  System.exit(1);
 }
 FeatureVector __result;
 __result = new FeatureVector();
 FeatureVector leftVector = left.classify(__example);
 int N = leftVector.featuresSize();
 FeatureVector rightVector = right.classify(__example);
 int M = rightVector.featuresSize();
 for (int i = 0; i < N; ++i)
 {
  Feature lf = leftVector.getFeature(i);
  for (int j = 0; j < M; ++j)
  {
   Feature rf = rightVector.getFeature(j);
   if (lf.equals(rf)) continue;
   __result.addFeature(lf.conjunction(rf, this));
  }
 }
 __result.sort();
 return __result;
}

代码示例来源:origin: edu.illinois.cs.cogcomp/illinois-ner

public FeatureVector classify(Object __example)
{
 if (!(__example instanceof NEWord))
 {
  String type = __example == null ? "null" : __example.getClass().getName();
  System.err.println("Classifier 'FeaturesLevel2$$5(NEWord)' defined on line 521 of LbjTagger.lbj received '" + type + "' as input.");
  new Exception().printStackTrace();
  System.exit(1);
 }
 FeatureVector __result;
 __result = new FeatureVector();
 FeatureVector leftVector = left.classify(__example);
 int N = leftVector.featuresSize();
 FeatureVector rightVector = right.classify(__example);
 int M = rightVector.featuresSize();
 for (int i = 0; i < N; ++i)
 {
  Feature lf = leftVector.getFeature(i);
  for (int j = 0; j < M; ++j)
  {
   Feature rf = rightVector.getFeature(j);
   if (lf.equals(rf)) continue;
   __result.addFeature(lf.conjunction(rf, this));
  }
 }
 __result.sort();
 return __result;
}

代码示例来源:origin: edu.illinois.cs.cogcomp/illinois-mlner

public FeatureVector classify(Object __example)
{
 if (!(__example instanceof NEWord))
 {
  String type = __example == null ? "null" : __example.getClass().getName();
  System.err.println("Classifier 'FeaturesLevel2$$5(NEWord)' defined on line 521 of LbjTagger.lbj received '" + type + "' as input.");
  new Exception().printStackTrace();
  System.exit(1);
 }
 FeatureVector __result;
 __result = new FeatureVector();
 FeatureVector leftVector = left.classify(__example);
 int N = leftVector.featuresSize();
 FeatureVector rightVector = right.classify(__example);
 int M = rightVector.featuresSize();
 for (int i = 0; i < N; ++i)
 {
  Feature lf = leftVector.getFeature(i);
  for (int j = 0; j < M; ++j)
  {
   Feature rf = rightVector.getFeature(j);
   if (lf.equals(rf)) continue;
   __result.addFeature(lf.conjunction(rf, this));
  }
 }
 __result.sort();
 return __result;
}

代码示例来源:origin: edu.illinois.cs.cogcomp/illinois-ner

public FeatureVector classify(Object __example)
{
 if (!(__example instanceof NEWord))
 {
  String type = __example == null ? "null" : __example.getClass().getName();
  System.err.println("Classifier 'FeaturesLevel1Only$$4(NEWord)' defined on line 370 of LbjTagger.lbj received '" + type + "' as input.");
  new Exception().printStackTrace();
  System.exit(1);
 }
 FeatureVector __result;
 __result = new FeatureVector();
 FeatureVector leftVector = left.classify(__example);
 int N = leftVector.featuresSize();
 FeatureVector rightVector = right.classify(__example);
 int M = rightVector.featuresSize();
 for (int i = 0; i < N; ++i)
 {
  Feature lf = leftVector.getFeature(i);
  for (int j = 0; j < M; ++j)
  {
   Feature rf = rightVector.getFeature(j);
   if (lf.equals(rf)) continue;
   __result.addFeature(lf.conjunction(rf, this));
  }
 }
 __result.sort();
 return __result;
}

代码示例来源:origin: edu.illinois.cs.cogcomp/illinois-md

public FeatureVector classify(Object __example)
{
 if (!(__example instanceof Relation))
 {
  String type = __example == null ? "null" : __example.getClass().getName();
  System.err.println("Classifier 'combinedFeatures$$0(Relation)' defined on line 237 of extent.lbj received '" + type + "' as input.");
  new Exception().printStackTrace();
  System.exit(1);
 }
 FeatureVector __result;
 __result = new FeatureVector();
 FeatureVector leftVector = left.classify(__example);
 int N = leftVector.featuresSize();
 FeatureVector rightVector = right.classify(__example);
 int M = rightVector.featuresSize();
 for (int i = 0; i < N; ++i)
 {
  Feature lf = leftVector.getFeature(i);
  for (int j = 0; j < M; ++j)
  {
   Feature rf = rightVector.getFeature(j);
   if (lf.equals(rf)) continue;
   __result.addFeature(lf.conjunction(rf, this));
  }
 }
 __result.sort();
 return __result;
}

代码示例来源:origin: edu.illinois.cs.cogcomp/illinois-mlner

public FeatureVector classify(Object __example)
{
 if (!(__example instanceof NEWord))
 {
  String type = __example == null ? "null" : __example.getClass().getName();
  System.err.println("Classifier 'FeaturesLevel1Only$$4(NEWord)' defined on line 370 of LbjTagger.lbj received '" + type + "' as input.");
  new Exception().printStackTrace();
  System.exit(1);
 }
 FeatureVector __result;
 __result = new FeatureVector();
 FeatureVector leftVector = left.classify(__example);
 int N = leftVector.featuresSize();
 FeatureVector rightVector = right.classify(__example);
 int M = rightVector.featuresSize();
 for (int i = 0; i < N; ++i)
 {
  Feature lf = leftVector.getFeature(i);
  for (int j = 0; j < M; ++j)
  {
   Feature rf = rightVector.getFeature(j);
   if (lf.equals(rf)) continue;
   __result.addFeature(lf.conjunction(rf, this));
  }
 }
 __result.sort();
 return __result;
}

代码示例来源:origin: edu.illinois.cs.cogcomp/md

public FeatureVector classify(Object __example)
{
 if (!(__example instanceof Relation))
 {
  String type = __example == null ? "null" : __example.getClass().getName();
  System.err.println("Classifier 'combinedFeatures$$0(Relation)' defined on line 237 of extent.lbj received '" + type + "' as input.");
  new Exception().printStackTrace();
  System.exit(1);
 }
 FeatureVector __result;
 __result = new FeatureVector();
 FeatureVector leftVector = left.classify(__example);
 int N = leftVector.featuresSize();
 FeatureVector rightVector = right.classify(__example);
 int M = rightVector.featuresSize();
 for (int i = 0; i < N; ++i)
 {
  Feature lf = leftVector.getFeature(i);
  for (int j = 0; j < M; ++j)
  {
   Feature rf = rightVector.getFeature(j);
   if (lf.equals(rf)) continue;
   __result.addFeature(lf.conjunction(rf, this));
  }
 }
 __result.sort();
 return __result;
}

代码示例来源:origin: edu.illinois.cs.cogcomp/LBJava

/**
 * Take the dot product of two feature vectors.
 *
 * @param vector The feature vector to take the dot product with.
 * @return The dot product of this feature vector and <code>vector</code>.
 **/
public double dot(FeatureVector vector) {
  if (features.size() == 0 || vector.features.size() == 0)
    return 0;
  FVector v1 = (FVector) features.clone();
  FVector v2 = (FVector) vector.features.clone();
  v1.sort();
  v2.sort();
  double res = 0;
  int i = 0, j = 0;
  Feature f1 = v1.get(0);
  Feature f2 = v2.get(0);
  while (f1 != null && f2 != null) {
    if (f1.equals(f2)) {
      res += f1.getStrength() * f2.getStrength();
      f1 = v1.get(++i);
      f2 = v2.get(++j);
    } else if (f1.compareTo(f2) < 0)
      f1 = v1.get(++i);
    else
      f2 = v2.get(++j);
  }
  return res;
}

相关文章