cc.mallet.types.Instance.getSource()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(10.7k)|赞(0)|评价(0)|浏览(110)

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

Instance.getSource介绍

暂无

代码示例

代码示例来源:origin: de.julielab/jcore-mallet-2.0.9

public void printRank (PrintWriter pw) throws FileNotFoundException
{
  // xxx Fix this.
  /*System.out.print (classifier.getClass().getName() + "(.");
  System.out.print (") = [");
  for (int i = 0; i < labeling.numLocations(); i++)
    System.out.print (labeling.labelAtLocation(i).toString()+"="+labeling.valueAtLocation(i)+" ");
  System.out.println ("]");*/		
  pw.print(classifier.getClass().getName());
  pw.print(" ");
  pw.print(instance.getSource() + " ");
  LabelVector lv = labeling.toLabelVector();
  lv.printByRank(pw);
  pw.println ();
}

代码示例来源:origin: com.github.steveash.mallet/mallet

public void printRank (PrintWriter pw) throws FileNotFoundException
{
  // xxx Fix this.
  /*System.out.print (classifier.getClass().getName() + "(.");
  System.out.print (") = [");
  for (int i = 0; i < labeling.numLocations(); i++)
    System.out.print (labeling.labelAtLocation(i).toString()+"="+labeling.valueAtLocation(i)+" ");
  System.out.println ("]");*/		
  pw.print(classifier.getClass().getName());
  pw.print(" ");
  pw.print(instance.getSource() + " ");
  LabelVector lv = labeling.toLabelVector();
  lv.printByRank(pw);
  pw.println ();
}

代码示例来源:origin: cc.mallet/mallet

public Instance pipe(Instance carrier) {
  StringBuffer sb = new StringBuffer();
  String source = (String) carrier.getSource();
  Sequence as = (Sequence) carrier.getTarget();
  // int startLabelIndex = as.getAlphabet().lookupIndex("start");
  for (int i = 0; i < source.length(); i++) {
    System.out.println("target[" + i + "]=" + as.get(i).toString());
    if (as.get(i).toString().equals("start") && i != 0)
      sb.append(' ');
    sb.append(source.charAt(i));
  }
  carrier.setSource(sb.toString());
  System.out.println("carrier.getSource() = " + carrier.getSource());
  return carrier;
}

代码示例来源:origin: cc.mallet/mallet

public void printRank (PrintWriter pw) throws FileNotFoundException
{
  // xxx Fix this.
  /*System.out.print (classifier.getClass().getName() + "(.");
  System.out.print (") = [");
  for (int i = 0; i < labeling.numLocations(); i++)
    System.out.print (labeling.labelAtLocation(i).toString()+"="+labeling.valueAtLocation(i)+" ");
  System.out.println ("]");*/		
  pw.print(classifier.getClass().getName());
  pw.print(" ");
  pw.print(instance.getSource() + " ");
  LabelVector lv = labeling.toLabelVector();
  lv.printByRank(pw);
  pw.println ();
}

代码示例来源:origin: com.github.steveash.mallet/mallet

public Instance pipe(Instance carrier) {
  StringBuffer sb = new StringBuffer();
  String source = (String) carrier.getSource();
  Sequence as = (Sequence) carrier.getTarget();
  // int startLabelIndex = as.getAlphabet().lookupIndex("start");
  for (int i = 0; i < source.length(); i++) {
    System.out.println("target[" + i + "]=" + as.get(i).toString());
    if (as.get(i).toString().equals("start") && i != 0)
      sb.append(' ');
    sb.append(source.charAt(i));
  }
  carrier.setSource(sb.toString());
  System.out.println("carrier.getSource() = " + carrier.getSource());
  return carrier;
}

代码示例来源:origin: com.github.steveash.mallet/mallet

public Instance pipe(Instance carrier)
{
 StringBuffer sb = new StringBuffer();
 String source = (String) carrier.getSource();
 Sequence as = (Sequence) carrier.getTarget();
 //int startLabelIndex = as.getAlphabet().lookupIndex("start");
 for (int i = 0; i < source.length(); i++) {
  System.out.println("target[" + i + "]=" + as.get(i).toString());
  if (as.get(i).toString().equals("start") && i != 0)
   sb.append(' ');
  sb.append(source.charAt(i));
 }
 carrier.setSource(sb.toString());
 System.out.println("carrier.getSource() = " + carrier.getSource());
 return carrier;
}

代码示例来源:origin: cc.mallet/mallet

public Instance pipe(Instance carrier)
{
 StringBuffer sb = new StringBuffer();
 String source = (String) carrier.getSource();
 Sequence as = (Sequence) carrier.getTarget();
 //int startLabelIndex = as.getAlphabet().lookupIndex("start");
 for (int i = 0; i < source.length(); i++) {
  System.out.println("target[" + i + "]=" + as.get(i).toString());
  if (as.get(i).toString().equals("start") && i != 0)
   sb.append(' ');
  sb.append(source.charAt(i));
 }
 carrier.setSource(sb.toString());
 System.out.println("carrier.getSource() = " + carrier.getSource());
 return carrier;
}

代码示例来源:origin: cc.mallet/mallet

public void print (PrintWriter pw) throws FileNotFoundException
{
  // xxx Fix this.
  /*System.out.print (classifier.getClass().getName() + "(.");
  System.out.print (") = [");
  for (int i = 0; i < labeling.numLocations(); i++)
    System.out.print (labeling.labelAtLocation(i).toString()+"="+labeling.valueAtLocation(i)+" ");
  System.out.println ("]");*/		
  pw.print(classifier.getClass().getName());
  pw.print(" ");
  pw.print(instance.getSource() + " ");
  for (int i = 0; i < labeling.numLocations(); i++)
    pw.print (labeling.labelAtLocation(i).toString()+"="+labeling.valueAtLocation(i)+" ");
  pw.println ();
}

代码示例来源:origin: de.julielab/jcore-mallet-2.0.9

public void print (PrintWriter pw) throws FileNotFoundException
{
  // xxx Fix this.
  /*System.out.print (classifier.getClass().getName() + "(.");
  System.out.print (") = [");
  for (int i = 0; i < labeling.numLocations(); i++)
    System.out.print (labeling.labelAtLocation(i).toString()+"="+labeling.valueAtLocation(i)+" ");
  System.out.println ("]");*/		
  pw.print(classifier.getClass().getName());
  pw.print(" ");
  pw.print(instance.getSource() + " ");
  for (int i = 0; i < labeling.numLocations(); i++)
    pw.print (labeling.labelAtLocation(i).toString()+"="+labeling.valueAtLocation(i)+" ");
  pw.println ();
}

代码示例来源:origin: com.github.steveash.mallet/mallet

public void print (PrintWriter pw) throws FileNotFoundException
{
  // xxx Fix this.
  /*System.out.print (classifier.getClass().getName() + "(.");
  System.out.print (") = [");
  for (int i = 0; i < labeling.numLocations(); i++)
    System.out.print (labeling.labelAtLocation(i).toString()+"="+labeling.valueAtLocation(i)+" ");
  System.out.println ("]");*/		
  pw.print(classifier.getClass().getName());
  pw.print(" ");
  pw.print(instance.getSource() + " ");
  for (int i = 0; i < labeling.numLocations(); i++)
    pw.print (labeling.labelAtLocation(i).toString()+"="+labeling.valueAtLocation(i)+" ");
  pw.println ();
}

代码示例来源:origin: cc.mallet/mallet

public Instance next () {
  if (!dataSubiterator.hasNext()) {
    assert (superIterator.hasNext());
    superInstance = superIterator.next();
    dataSubiterator = ((FeatureVectorSequence)superInstance.getData()).iterator();
    targetSubiterator = ((LabelSequence)superInstance.getTarget()).iterator();
  }
  // We are assuming sequences don't have zero length
  assert (dataSubiterator.hasNext());
  assert (targetSubiterator.hasNext());
  return new Instance (dataSubiterator.next(), targetSubiterator.next(), 
      superInstance.getSource()+" tokensequence:"+count++,	null);
}
public boolean hasNext () {

代码示例来源:origin: com.github.steveash.mallet/mallet

public Instance next () {
  if (!dataSubiterator.hasNext()) {
    assert (superIterator.hasNext());
    superInstance = superIterator.next();
    dataSubiterator = ((FeatureVectorSequence)superInstance.getData()).iterator();
    targetSubiterator = ((LabelSequence)superInstance.getTarget()).iterator();
  }
  // We are assuming sequences don't have zero length
  assert (dataSubiterator.hasNext());
  assert (targetSubiterator.hasNext());
  return new Instance (dataSubiterator.next(), targetSubiterator.next(), 
      superInstance.getSource()+" tokensequence:"+count++,	null);
}
public boolean hasNext () {

代码示例来源:origin: de.julielab/jcore-mallet-2.0.9

public Instance next () {
  if (!dataSubiterator.hasNext()) {
    assert (superIterator.hasNext());
    superInstance = superIterator.next();
    dataSubiterator = ((FeatureVectorSequence)superInstance.getData()).iterator();
    targetSubiterator = ((LabelSequence)superInstance.getTarget()).iterator();
  }
  // We are assuming sequences don't have zero length
  assert (dataSubiterator.hasNext());
  assert (targetSubiterator.hasNext());
  return new Instance (dataSubiterator.next(), targetSubiterator.next(), 
      superInstance.getSource()+" tokensequence:"+count++,	null);
}
public boolean hasNext () {

代码示例来源:origin: cc.mallet/mallet

public Instance next ()
{
 Instance inst = subIt.next ();
 inst = pipe.pipe (inst);
 return new Instance (inst.getData (), inst.getTarget (), inst.getName (), inst.getSource ());
}

代码示例来源:origin: de.julielab/jcore-mallet-2.0.9

public Instance next ()
{
 Instance inst = subIt.next ();
 inst = pipe.pipe (inst);
 return new Instance (inst.getData (), inst.getTarget (), inst.getName (), inst.getSource ());
}

代码示例来源:origin: com.github.steveash.mallet/mallet

public Instance next ()
{
 Instance inst = subIt.next ();
 inst = pipe.pipe (inst);
 return new Instance (inst.getData (), inst.getTarget (), inst.getName (), inst.getSource ());
}

代码示例来源:origin: cc.mallet/mallet

public Instance toInstance() {
    Instance ret;
    FeatureVector fv;
    double[] values = new double[labeling.numLocations()];
    int[] indices = new int[labeling.numLocations()];
    for(int i = 0; i < labeling.numLocations(); i++){
      indices[i] = labeling.indexAtLocation(i);
      values[i] = labeling.valueAtLocation(i);
    }
    fv = new FeatureVector(labeling.getAlphabet(), indices, values);
    ret = new Instance(fv,null,null,instance.getSource());
    return ret;
  }
}

代码示例来源:origin: de.julielab/jcore-mallet-2.0.9

public Instance toInstance() {
    Instance ret;
    FeatureVector fv;
    double[] values = new double[labeling.numLocations()];
    int[] indices = new int[labeling.numLocations()];
    for(int i = 0; i < labeling.numLocations(); i++){
      indices[i] = labeling.indexAtLocation(i);
      values[i] = labeling.valueAtLocation(i);
    }
    fv = new FeatureVector(labeling.getAlphabet(), indices, values);
    ret = new Instance(fv,null,null,instance.getSource());
    return ret;
  }
}

代码示例来源:origin: com.github.steveash.mallet/mallet

public Instance toInstance() {
    Instance ret;
    FeatureVector fv;
    double[] values = new double[labeling.numLocations()];
    int[] indices = new int[labeling.numLocations()];
    for(int i = 0; i < labeling.numLocations(); i++){
      indices[i] = labeling.indexAtLocation(i);
      values[i] = labeling.valueAtLocation(i);
    }
    fv = new FeatureVector(labeling.getAlphabet(), indices, values);
    ret = new Instance(fv,null,null,instance.getSource());
    return ret;
  }
}

代码示例来源:origin: cc.mallet/mallet

/** Assumes Instance.source contains the Tokenization object. */
public Extraction extract (InstanceList ilist) {
Extraction extraction = new Extraction (this, getTargetAlphabet ());
  for (int i = 0; i < ilist.size(); i++) {
    Instance inst = ilist.get(i);
    Tokenization tok = (Tokenization)inst.getSource();
 String name = inst.getName().toString();
 Sequence input = (Sequence)inst.getData ();
 Sequence target = (Sequence)inst.getTarget ();
 Sequence output = crf.transduce(input);
 DocumentExtraction docseq =
      new DocumentExtraction (name, getTargetAlphabet(), tok,
                              output, target, backgroundTag,
                              filter);
 extraction.addDocumentExtraction (docseq);            
  }
return extraction;
}

相关文章