本文整理汇总了Java中edu.stanford.nlp.sequences.FeatureFactory.getCliques方法的典型用法代码示例。如果您正苦于以下问题:Java FeatureFactory.getCliques方法的具体用法?Java FeatureFactory.getCliques怎么用?Java FeatureFactory.getCliques使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类edu.stanford.nlp.sequences.FeatureFactory
的用法示例。
在下文中一共展示了FeatureFactory.getCliques方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: makeDatum
import edu.stanford.nlp.sequences.FeatureFactory; //导入方法依赖的package包/类
@Override
public CRFDatum<List<String>, CRFLabel> makeDatum(List<IN> info, int loc, FeatureFactory<IN> featureFactory) {
pad.set(CoreAnnotations.AnswerAnnotation.class, flags.backgroundSymbol);
PaddedList<IN> pInfo = new PaddedList<IN>(info, pad);
List<List<String>> features = new ArrayList<List<String>>();
Collection<Clique> done = Generics.newHashSet();
for (int i = 0; i < windowSize; i++) {
List<String> featuresC = new ArrayList<String>();
List<Clique> windowCliques = featureFactory.getCliques(i, 0);
windowCliques.removeAll(done);
done.addAll(windowCliques);
for (Clique c : windowCliques) {
featuresC.addAll(featureFactory.getCliqueFeatures(pInfo, loc, c));
if(testTime && i==0)
// this feature is only present at test time and only appears
// in cliques of size 1 (i.e., cliques with window=0)
featuresC.add(BIAS);
}
features.add(featuresC);
}
int[] labels = new int[windowSize];
for (int i = 0; i < windowSize; i++) {
String answer = pInfo.get(loc + i - windowSize + 1).get(CoreAnnotations.AnswerAnnotation.class);
labels[i] = classIndex.indexOf(answer);
}
return new CRFDatum<List<String>, CRFLabel>(features, new CRFLabel(labels), null);
}