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


Java LabelsSequence类代码示例

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


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

示例1: toLabelsSequence

import cc.mallet.types.LabelsSequence; //导入依赖的package包/类
public LabelsSequence toLabelsSequence (Assignment assn)
{
  int numFactors = numSlices ();
  int maxTime = maxTime ();
  Labels[] lbls = new Labels [maxTime];
  for (int t = 0; t < maxTime; t++) {
    Label[] theseLabels = new Label [numFactors];
    for (int i = 0; i < numFactors; i++) {
      Variable var = varOfIndex (t, i);
      int maxidx;

      if (var != null) {
        maxidx = assn.get (var);
      } else {
        maxidx = 0;
      }

      LabelAlphabet dict = labelOfVar (var).getLabelAlphabet ();
      theseLabels[i] = dict.lookupLabel (maxidx);
    }

    lbls[t] = new Labels (theseLabels);
  }

  return new LabelsSequence (lbls);
}
 
开发者ID:mimno,项目名称:GRMM,代码行数:27,代码来源:LabelsAssignment.java

示例2: testSerializable

import cc.mallet.types.LabelsSequence; //导入依赖的package包/类
public void testSerializable () throws IOException, ClassNotFoundException
{
  LabelAlphabet dict = new LabelAlphabet ();
  Labels lbls1 = new Labels (new Label[] {
    dict.lookupLabel ("A"),
    dict.lookupLabel ("B"),
  });
  Labels lbls2 = new Labels (new Label[] {
    dict.lookupLabel ("C"),
    dict.lookupLabel ("A"),
  });
  LabelsSequence lblseq  = new LabelsSequence (new Labels[] { lbls1, lbls2 });
  LabelsSequence lblseq2 = (LabelsSequence) TestSerializable.cloneViaSerialization (lblseq);
  assertEquals (lblseq.size(), lblseq2.size());
  assertEquals (lblseq.getLabels(0).toString(), lblseq2.getLabels(0).toString ());
  assertEquals (lblseq.getLabels(1).toString(), lblseq2.getLabels(1).toString ());
}
 
开发者ID:kostagiolasn,项目名称:NucleosomePatternClassifier,代码行数:18,代码来源:TestLabelsSequence.java

示例3: pipe

import cc.mallet.types.LabelsSequence; //导入依赖的package包/类
@Override
public Instance pipe(Instance inst) {
  List<String> source = (List<String>) inst.getData();
  List<String[]> target = (List<String[]>) inst.getTarget();

  inst.setData(makeTokenSeq(source));
  if (target != null) {
    Preconditions.checkState(target.size() == source.size(), "target %s source %s", target, source);
    Labels[] labels = new Labels[target.size()];
    for (int i = 0; i < target.size(); i++) {
      String[] labelStrings = target.get(i);
      labels[i] = new Labels(new Label[] {
          alignDict.lookupLabel(labelStrings[0]),
          phoneDict.lookupLabel(labelStrings[1])
      });
    }
    inst.setTarget(new LabelsAssignment(new LabelsSequence(labels)));
  }
  return inst;
}
 
开发者ID:steveash,项目名称:jg2p,代码行数:21,代码来源:JointInputToTokenSequence.java

示例4: LabelsAssignment

import cc.mallet.types.LabelsSequence; //导入依赖的package包/类
public LabelsAssignment (LabelsSequence lbls)
{
  super ();
  this.lblseq = lbls;
  setupLabel2Var ();
  addRow (toVariableArray (), toValueArray ());
}
 
开发者ID:mimno,项目名称:GRMM,代码行数:8,代码来源:LabelsAssignment.java

示例5: classify

import cc.mallet.types.LabelsSequence; //导入依赖的package包/类
/**
 * This method classifies several instances at once
 * 
 * @param features
 *          a list of lists of features - each list in the list represents one instance to be
 *          classified. The list should correspond to some logical sequence of instances to be
 *          classified (e.g. tokens in a sentence or lines in a document) that corresponds to the
 *          model that has been built for this classifier.
 */
public List<String[]> classify(final List<List<Feature>> features)
    throws CleartkProcessingException {
  // generate format that is appropriate for the acrf input pipe:
  String data = "";
  {
    StringWriter out = new StringWriter();
    PrintWriter printWriter = new PrintWriter(out);
    for (List<Feature> f : features) {
      List<NameNumber> nameNumbers = this.featuresEncoder.encodeAll(f);
      GrmmDataWriter.writeEncoded(nameNumbers, this.outcomeExample.split(" "), printWriter);
    }
    data = out.toString();
  }
  // classify:
  Pipe pipe = acrf.getInputPipe();
  Instance unprocessedInstance = new Instance(data, null, "", null);
  Instance instance = pipe.newIteratorFrom(Arrays.asList(unprocessedInstance).iterator()).next();
  LabelsSequence bestLabels = acrf.getBestLabels(instance);
  List<String[]> returnValues = new ArrayList<String[]>(features.size());
  for (int i = 0; i < bestLabels.size(); i++) {
    Labels labels = bestLabels.getLabels(i);
    String[] outcomes = new String[labels.size()];
    for (int j = 0; j < labels.size(); j++) {
      outcomes[j] = labels.get(j).getBestLabel().toString();
    }
    returnValues.add(outcomes);
  }
  return returnValues;
}
 
开发者ID:ClearTK,项目名称:cleartk,代码行数:39,代码来源:GrmmClassifier.java

示例6: pipe

import cc.mallet.types.LabelsSequence; //导入依赖的package包/类
@Override
public Instance pipe(Instance inst) {
  LabelSequence seq = (LabelSequence) inst.getTarget();
  LabelsSequence sseq = new LabelsSequence(seq);
  LabelsAssignment labels = new LabelsAssignment(sseq);
  inst.setTarget(labels);
  return inst;
}
 
开发者ID:steveash,项目名称:jg2p,代码行数:9,代码来源:LabelSequenceToLabelsAssignment.java

示例7: pipe

import cc.mallet.types.LabelsSequence; //导入依赖的package包/类
public Instance pipe (Instance carrier)
{
  LabelsSequence lbls = (LabelsSequence) carrier.getTarget ();
  carrier.setTarget (new LabelsAssignment (lbls));
  return carrier;
}
 
开发者ID:mimno,项目名称:GRMM,代码行数:7,代码来源:LabelsSequence2Assignment.java

示例8: getLabelsSequence

import cc.mallet.types.LabelsSequence; //导入依赖的package包/类
public LabelsSequence getLabelsSequence ()
{
  return lblseq;
}
 
开发者ID:mimno,项目名称:GRMM,代码行数:5,代码来源:LabelsAssignment.java


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