Package org.fnlp.ml.types

Examples of org.fnlp.ml.types.Instance


  public void statistic(InstanceSet instSet){ 
    int numSamples = instSet.size();
    for(int i=0;i<numSamples;i++){
      if(i%1000==0)
        System.out.println((i+0.0)/numSamples);
      Instance inst=instSet.get(i);
      oneStepStatistic(inst);
    }
  }
View Full Code Here


    HashSparseVector sv1 =(HashSparseVector) instance.getData();
    if(fs!=null)
      sv1=fs.select(sv1);
   
    for(int i = 0; i < prototypes.size(); i++){
      Instance curInst = prototypes.get(i);
      HashSparseVector sv2 =(HashSparseVector) curInst.getData();
      if(fs!=null)
        sv2=fs.select(sv2);
      float score;
      try {
        score = sim.calc(sv1, sv2);
      } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
        return null;
      }
      predK.add((Integer) curInst.getTarget(), score);
    }
    Predict<Integer> predN=predK.getNLabels(n);
    return predN;
 
View Full Code Here

public class ARInstanceGetter {

  private Instance instance;
  public ARInstanceGetter(FeatureGeter fBuilder){ 
    this.instance = new Instance(fBuilder.getFeatrue(),
        fBuilder.getInst().getTarget());
    this.instance.setSource(fBuilder.getInst().getData());
  }
View Full Code Here

  /**
   * 读取内容
   * @return
   */
  public Instance next(){
    return new Instance(content);
  }
View Full Code Here

      return src;
    String[] sents = Sentenizer.split(src);
    String tag = "";
    try {
      for (int i = 0; i < sents.length; i++) {
        Instance inst = new Instance(sents[i]);
        String[] preds = _tag(inst);
        String s = FormatCWS.toString(inst, preds,delim);
        tag += s;
        if (i < sents.length - 1)
          tag += delim;
View Full Code Here

  public ArrayList<String> tag2List(String src) {
    if(src==null||src.length()==0)
      return null;
    ArrayList<String> res =null;
    try {
      Instance inst = new Instance(src);
      String[] preds = _tag(inst);
      res  = FormatCWS.toList(inst, preds);
    } catch (Exception e) {
      e.printStackTrace();
    }
View Full Code Here

*/
public class BasicFormatter {
  public static String format(InstanceSet testSet, String[][] labelsSet) {
    StringBuilder sb = new StringBuilder();
    for (int i = 0; i < testSet.size(); i++) {
      Instance inst = testSet.getInstance(i);
      String[] labels = labelsSet[i];
      sb.append(format(inst, labels));
      sb.append("\n");
    }
    return sb.toString();
View Full Code Here

    testSet.loadThruPipes(new SequenceReader(testfile, false, "utf8"));
    System.out.println("测试样本个数: " + testSet.size()); //
    String[][] labelsSet = new String[testSet.size()][];
    for (int i = 0; i < testSet.size(); i++) {
      Instance carrier = testSet.get(i);
      int[] pred = (int[]) cl.classify(carrier).getLabel(0);
      labelsSet[i] = labels.lookupString(pred);
    }
   
    String s = SimpleFormatter.format(testSet, labelsSet);
View Full Code Here

public class Seq2ArrayWithTag {

  public static String format(InstanceSet testSet, String[][] labelsSet) {
    StringBuilder sb = new StringBuilder();
    for (int i = 0; i < testSet.size(); i++) {
      Instance inst = testSet.getInstance(i);
      String[] labels = labelsSet[i];
      sb.append(format(inst, labels));
    }
    return sb.toString();
  }
View Full Code Here

   * @return
   */
  public static String toString(InstanceSet instSet, String[][] labelsSet, String delim) {
    StringBuilder sb = new StringBuilder();
    for (int i = 0; i < instSet.size(); i++) {
      Instance inst = instSet.getInstance(i);
      String[] labels = labelsSet[i];
      sb.append(toString(inst, labels,delim));
      sb.append("\n");
    }
    return sb.toString();
View Full Code Here

TOP

Related Classes of org.fnlp.ml.types.Instance

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.