Package com.clearnlp.classification.instance

Examples of com.clearnlp.classification.instance.StringInstance


    DEPLabel label = null;
   
    if (isTrain())
    {
      label = state.getGoldLabel();
      insts.add(new StringInstance(label.toString(), vector));
    }
    else if (isDevelopOrDecode())
    {
      label = getAutoLabel(vector, state);
    }
    else if (isBootstrap())
    {
      label = getAutoLabel(vector, state);
      insts.add(new StringInstance(state.getGoldLabel().toString(), vector));
    }
   
    return label;
  }
View Full Code Here


// ================================ BUILD ================================

  public void build(int labelCutoff, int featureCutoff, int randomSeed, boolean initialize)
  {
    SparseFeatureVector vector;
    StringInstance instance;
    int label;
   
    if (initialize) init();
    buildLabels(labelCutoff);
    buildFeatures(featureCutoff);
   
    l_instances = Lists.newArrayList();
    r_shuffle = new Random(randomSeed);
    l_indices = new IntArrayList();
   
    while ((instance = i_collector.pollInstance()) != null)
    {
      if ((label = getLabelIndex(instance.getLabel())) < 0)
        continue;
     
      vector = toSparseFeatureVector(instance.getFeatureVector());
     
      if (!vector.isEmpty())
      {
        l_instances.add(new IntInstance(label, vector));
        l_indices.add(l_indices.size());
View Full Code Here

 
  private void addInstance(TagState state, List<StringInstance> insts, String goldLabel, StringFeatureVector vector)
  {
    if (!vector.isEmpty())
    {
      StringInstance instance = new StringInstance(goldLabel, vector);
      insts.add(instance);
    }
  }
View Full Code Here

    String label = null;
   
    if (isTrain())
    {
      label = state.getGoldLabel();
      if (vector.size() > 0) insts.add(new StringInstance(label, vector));
    }
    else if (isDevelopOrDecode())
    {
      label = getAutoLabel(vector, state);
    }
    else if (isBootstrap())
    {
      label = getAutoLabel(vector, state);
      if (vector.size() > 0) insts.add(new StringInstance(state.getGoldLabel(), vector));
    }
   
    return label;
  }
View Full Code Here

    DEPLabel label = null;
   
    if (isTrain())
    {
      label = state.getGoldLabel();
      insts.add(new StringInstance(label.toString(), vector));
    }
    else if (isDevelopOrDecode())
    {
      label = getAutoLabel(vector, state);
    }
    else if (isBootstrap())
    {
      label = getAutoLabel(vector, state);
      insts.add(new StringInstance(state.getGoldLabel().toString(), vector));
    }
   
    return label;
  }
View Full Code Here

 
  public void printInstances(PrintStream fout)
  {
    int i, size = s_instances.size();
    String[] instances = new String[size];
    StringInstance p;
   
    for (i=0; i<size; i++)
    {
      p = s_instances.get(i);
      instances[i] = p.getLabel() + DELIM_COL + p.getFeatureVector().toString()
    }
   
    Arrays.sort(instances);
   
    for (String instance : instances)
View Full Code Here

  public void build(boolean clearInstances)
  {
    LOG.info("Building:\n");
    initModelMaps();
   
    StringInstance instance;
    int y, i, size = s_instances.size();
    SparseFeatureVector x;
   
    for (i=0; i<size; i++)
    {
      instance = s_instances.get(i);
     
      if ((y = s_model.getLabelIndex(instance.getLabel())) < 0)
        continue;
     
      x = s_model.toSparseFeatureVector(instance.getFeatureVector());
     
      a_ys.add(y);
      a_xs.add(x.getIndices());
      if (b_weighta_vs.add(x.getWeights());
    }
View Full Code Here

    int i, size = tmp.length;
   
    for (i=1; i<size; i++)
      vector.addFeature(tmp[i]);
   
    return new StringInstance(label, vector);
  }
View Full Code Here

 
  /** Called by {@link #process(DEPTree)}. */
  private void processTrain(TagState state, List<StringInstance> insts)
  {
    StringFeatureVector vector = getFeatureVector(f_xml, state);
    if (!vector.isEmpty()) insts.add(new StringInstance(state.getGoldLabel(), vector));
  }
View Full Code Here

 
  /** Called by {@link #process(DEPTree)}. */
  private void processBootstrap(TagState state, List<StringInstance> insts)
  {
    StringFeatureVector vector = getFeatureVector(f_xml, state);
    if (!vector.isEmpty()) insts.add(new StringInstance(state.getGoldLabel(), vector));
    setAutoLabels(vector, state);
  }
View Full Code Here

TOP

Related Classes of com.clearnlp.classification.instance.StringInstance

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.