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


Java PaddedList类代码示例

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


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

示例1: getCliqueFeatures

import edu.stanford.nlp.util.PaddedList; //导入依赖的package包/类
/**
 * Extracts all the features from the input data at a certain index.
 *
 * @param cInfo The complete data set as a List of WordInfo
 * @param loc  The index at which to extract features.
 */
public Collection<String> getCliqueFeatures(PaddedList<IN> cInfo, int loc, Clique clique) {
  Collection<String> features = new HashSet<>();

  if (clique == cliqueC) {
    addAllInterningAndSuffixing(features, featuresC(cInfo, loc), "C");
  } else if (clique == cliqueCpC) {
    addAllInterningAndSuffixing(features, featuresCpC(cInfo, loc), "CpC");
  } 
  //    else if (clique == cliqueCp2C) {
  //      addAllInterningAndSuffixing(features, featuresCp2C(cInfo, loc), "Cp2C");
  //    } else if (clique == cliqueCp3C) {
  //      addAllInterningAndSuffixing(features, featuresCp3C(cInfo, loc), "Cp3C");
  //    }

  return features;
}
 
开发者ID:stanfordnlp,项目名称:phrasal,代码行数:23,代码来源:CRFPostprocessorFeatureFactory.java

示例2: featuresCpC

import edu.stanford.nlp.util.PaddedList; //导入依赖的package包/类
private Collection<String> featuresCpC(PaddedList<IN> cInfo, int loc) {
  Collection<String> features = new ArrayList<>();

  // Caused overfitting.
  //    CoreLabel c = cInfo.get(loc);
  //    CoreLabel p = cInfo.get(loc - 1);
  //    CoreLabel n = cInfo.get(loc + 1);
  //    
  //    String charc = c.get(CoreAnnotations.CharAnnotation.class);
  //    String charp = p.get(CoreAnnotations.CharAnnotation.class);
  //    String charn = n.get(CoreAnnotations.CharAnnotation.class);
  //
  //    addCharacterClassFeatures(features, charp, "-p");
  //    addCharacterClassFeatures(features, charn, "-n");
  //    addCharacterClassFeatures(features, charc, "-c");

  // Indicator transition feature
  features.add("cliqueCpC");

  return features;
}
 
开发者ID:stanfordnlp,项目名称:phrasal,代码行数:22,代码来源:CRFPostprocessorFeatureFactory.java

示例3: distSimAnnotate

import edu.stanford.nlp.util.PaddedList; //导入依赖的package包/类
private void distSimAnnotate(PaddedList<IN> info) {
  for (CoreLabel fl : info) {
    if (fl.has(CoreAnnotations.DistSimAnnotation.class)) { return; }
    String word = getWord(fl);
    if ( ! flags.casedDistSim) {
      word = word.toLowerCase();
    }
    if (flags.numberEquivalenceDistSim) {
      word = WordShapeClassifier.wordShape(word, WordShapeClassifier.WORDSHAPEDIGITS);
    }
    String distSim = lexicon.get(word);
    if (distSim == null) {
      distSim = flags.unknownWordDistSimClass;
    }
    fl.set(CoreAnnotations.DistSimAnnotation.class, distSim);
  }
}
 
开发者ID:paulirwin,项目名称:Stanford.NER.Net,代码行数:18,代码来源:NERFeatureFactory.java

示例4: makeDatum

import edu.stanford.nlp.util.PaddedList; //导入依赖的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);
}
 
开发者ID:paulirwin,项目名称:Stanford.NER.Net,代码行数:32,代码来源:CRFBiasedClassifier.java

示例5: occurrencePatterns

import edu.stanford.nlp.util.PaddedList; //导入依赖的package包/类
private Collection<String> occurrencePatterns(PaddedList<IN> cInfo, int loc) {
  // features on last Cap
  String word = getWord(cInfo.get(loc));
  String nWord = getWord(cInfo.get(loc + reverse(1)));
  CoreLabel p = cInfo.get(loc - reverse(1));
  String pWord = getWord(p);
  // System.err.println(word+" "+nWord);
  if (!(isNameCase(word) && noUpperCase(nWord) && hasLetter(nWord) && hasLetter(pWord) && p != cInfo.getPad())) {
    return Collections.singletonList("NO-OCCURRENCE-PATTERN");
  }
  // System.err.println("LOOKING");
  Set<String> l = Generics.newHashSet();
  if (cInfo.get(loc - reverse(1)).getString(CoreAnnotations.PartOfSpeechAnnotation.class) != null && isNameCase(pWord) && cInfo.get(loc - reverse(1)).getString(CoreAnnotations.PartOfSpeechAnnotation.class).equals("NNP")) {
    for (int jump = 3; jump < 150; jump++) {
      if (getWord(cInfo.get(loc + reverse(jump))).equals(word)) {
        if (getWord(cInfo.get(loc + reverse(jump - 1))).equals(pWord)) {
          l.add("XY-NEXT-OCCURRENCE-XY");
        } else {
          l.add("XY-NEXT-OCCURRENCE-Y");
        }
      }
    }
    for (int jump = -3; jump > -150; jump--) {
      if (getWord(cInfo.get(loc + reverse(jump))).equals(word)) {
        if (getWord(cInfo.get(loc + reverse(jump - 1))).equals(pWord)) {
          l.add("XY-PREV-OCCURRENCE-XY");
        } else {
          l.add("XY-PREV-OCCURRENCE-Y");
        }
      }
    }
  } else {
    for (int jump = 3; jump < 150; jump++) {
      if (getWord(cInfo.get(loc + reverse(jump))).equals(word)) {
        if (isNameCase(getWord(cInfo.get(loc + reverse(jump - 1)))) && (cInfo.get(loc + reverse(jump - 1))).getString(CoreAnnotations.PartOfSpeechAnnotation.class).equals("NNP")) {
          l.add("X-NEXT-OCCURRENCE-YX");
          // System.err.println(getWord(cInfo.get(loc+reverse(jump-1))));
        } else if (isNameCase(getWord(cInfo.get(loc + reverse(jump + 1)))) && (cInfo.get(loc + reverse(jump + 1))).getString(CoreAnnotations.PartOfSpeechAnnotation.class).equals("NNP")) {
          // System.err.println(getWord(cInfo.get(loc+reverse(jump+1))));
          l.add("X-NEXT-OCCURRENCE-XY");
        } else {
          l.add("X-NEXT-OCCURRENCE-X");
        }
      }
    }
    for (int jump = -3; jump > -150; jump--) {
      if (getWord(cInfo.get(loc + jump)) != null && getWord(cInfo.get(loc + jump)).equals(word)) {
        if (isNameCase(getWord(cInfo.get(loc + reverse(jump + 1)))) && (cInfo.get(loc + reverse(jump + 1))).getString(CoreAnnotations.PartOfSpeechAnnotation.class).equals("NNP")) {
          l.add("X-PREV-OCCURRENCE-YX");
          // System.err.println(getWord(cInfo.get(loc+reverse(jump+1))));
        } else if (isNameCase(getWord(cInfo.get(loc + reverse(jump - 1)))) && cInfo.get(loc + reverse(jump - 1)).getString(CoreAnnotations.PartOfSpeechAnnotation.class).equals("NNP")) {
          l.add("X-PREV-OCCURRENCE-XY");
          // System.err.println(getWord(cInfo.get(loc+reverse(jump-1))));
        } else {
          l.add("X-PREV-OCCURRENCE-X");
        }
      }
    }
  }
  /*
  if (!l.isEmpty()) {
    System.err.println(pWord+" "+word+" "+nWord+" "+l);
  }
  */
  return l;
}
 
开发者ID:paulirwin,项目名称:Stanford.NER.Net,代码行数:67,代码来源:NERFeatureFactory.java

示例6: getCliqueFeatures

import edu.stanford.nlp.util.PaddedList; //导入依赖的package包/类
/**
 * This method returns a {@link Collection} of the features
 * calculated for the word at the specified position in info (the list of
 * words) for the specified {@link Clique}.
 * It should return the actual features, <b>NOT</b> wrapped in a
 * {@link Features} object, as the wrapping
 * will be done automatically.
 * Because it takes a {@link PaddedList} you don't
 * need to worry about indices which are outside of the list.
 *
 * @param info A PaddedList of the feature-value pairs
 * @param position The current position to extract features at
 * @param clique The particular clique for which to extract features. It
 *     should be a member of the knownCliques list.
 * @return A {@link Collection} of the features
 *     calculated for the word at the specified position in info.
 */
public abstract Collection<String> getCliqueFeatures(PaddedList<IN> info, int position, Clique clique);
 
开发者ID:paulirwin,项目名称:Stanford.NER.Net,代码行数:19,代码来源:FeatureFactory.java


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