Package cc.mallet.types

Examples of cc.mallet.types.Alphabet.lookupObject()


    RankedFeatureVector rfv;
    double[] weights = new double[numFeatures-1]; // do not deal with the default feature
    for (int li = 0; li < numLabels; li++) {
      out.print ("FEATURES FOR CLASS "+labelDict.lookupObject (li) + " ");
      for (int i = 0; i < defaultFeatureIndex; i++) {
        Object name = dict.lookupObject (i);
        double weight = parameters [li*numFeatures + i];
        weights[i] = weight;
      }
      rfv = new RankedFeatureVector(dict,weights);
      rfv.printTopK(out,num);
View Full Code Here


        }
        double prop = (double)count/totalWord;
        out.append(String.format("prop:%2.4f, ", prop));
     
        for (int i=0; i<numWords; i++) {
          out.append(alphabet.lookupObject(sortedTypes[i].getID()) + " ");
        }
        System.out.println(out);
      }
      else{
        if(k < kactive.size() )
View Full Code Here

          out.append("word:"+ nk.get(k) + ", ");
          double prop = (double)nk.get(k)/totalWord;
          out.append(String.format("prop:%2.4f, ", prop));
       
          for (int i=0; i<numWords; i++) {
            out.append(alphabet.lookupObject(sortedTypes[i].getID()) + " ");
          }
          System.out.println(out);
        }
        else{
          if(k < kactive.size() )
View Full Code Here

    if (p.isTargetProcessing())
    {
      Alphabet targets = p.getTargetAlphabet();
      StringBuffer buf = new StringBuffer("Labels:");
      for (int i = 0; i < targets.size(); i++)
        buf.append(" ").append(targets.lookupObject(i).toString());
      logger.info(buf.toString());
    }
    if (trainOption.value)
    {
      crf = train(trainingData, testData, eval,
View Full Code Here

    // Include the feature weights according to each label
    for (int li = 0; li < numLabels; li++) {
      out.println ("FEATURES FOR CLASS "+labelDict.lookupObject (li));
      out.println (" <default> "+parameters [li*numFeatures + defaultFeatureIndex]);
      for (int i = 0; i < defaultFeatureIndex; i++) {
        Object name = dict.lookupObject (i);
        double weight = parameters [li*numFeatures + i];
        out.println (" "+name+" "+weight);
      }
    }
  }
View Full Code Here

    RankedFeatureVector rfv;
    double[] weights = new double[numFeatures-1]; // do not deal with the default feature
    for (int li = 0; li < numLabels; li++) {
      out.print ("FEATURES FOR CLASS "+labelDict.lookupObject (li) + " ");
      for (int i = 0; i < defaultFeatureIndex; i++) {
        Object name = dict.lookupObject (i);
        double weight = parameters [li*numFeatures + i];
        weights[i] = weight;
      }
      rfv = new RankedFeatureVector(dict,weights);
      rfv.printTopK(out,num);
View Full Code Here

    if (p.isTargetProcessing())
    {
      Alphabet targets = p.getTargetAlphabet();
      StringBuffer buf = new StringBuffer("Labels:");
      for (int i = 0; i < targets.size(); i++)
        buf.append(" ").append(targets.lookupObject(i).toString());
      logger.info(buf.toString());
    }
    if (trainOption.value)
    {
      crf = train(trainingData, testData, eval,
View Full Code Here

    if (p.isTargetProcessing())
    {
      Alphabet targets = p.getTargetAlphabet();
      StringBuffer buf = new StringBuffer("Labels:");
      for (int i = 0; i < targets.size(); i++)
        buf.append(" ").append(targets.lookupObject(i).toString());
      logger.info(buf.toString());
    }
    if (trainOption.value)
    {
      crf = train(trainingData, testData, eval,
View Full Code Here

      assert(!Double.isNaN(instanceWeight)) : "instanceWeight is NaN";

      boolean hasNaN = false;
      for (int i = 0; i < fv.numLocations(); i++) {
        if (Double.isNaN(fv.valueAtLocation(i))) {
          logger.info("NaN for feature " + fdict.lookupObject(fv.indexAtLocation(i)).toString());
          hasNaN = true;
        }
      }
      if (hasNaN)
        logger.info("NaN in instance: " + inst.getName());
View Full Code Here

    // Include the feature weights according to each label
    for (int li = 0; li < numLabels; li++) {
      out.println ("FEATURES FOR CLASS "+labelDict.lookupObject (li));
      out.println (" <default> "+parameters [li*numFeatures + defaultFeatureIndex]);
      for (int i = 0; i < defaultFeatureIndex; i++) {
        Object name = dict.lookupObject (i);
        double weight = parameters [li*numFeatures + i];
        out.println (" "+name+" "+weight);
      }
    }
  }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.