Package cc.mallet.types

Examples of cc.mallet.types.AugmentableFeatureVector


    this (false);
  }
 
  public Instance pipe (Instance carrier)
  {
    carrier.setData(new AugmentableFeatureVector ((FeatureSequence)carrier.getData(), binary));
    return carrier;
  }
View Full Code Here


    for (int i = 0; i < ilist.size(); i++) {
      Instance inst = ilist.get(i);
      Classification c = m_tokenClassifiers.classify(inst, ! m_inProduction);
      LabelVector lv = c.getLabelVector();
      AugmentableFeatureVector afv1 = (AugmentableFeatureVector) inst.getData();
      int[] indices = afv1.getIndices();
      AugmentableFeatureVector afv2 = new AugmentableFeatureVector(m_dataAlphabet,
          indices, afv1.getValues(), indices.length + m_predRanks2add.length);

      for (int j = 0; j < m_predRanks2add.length; j++) {
        Label label = lv.getLabelAtRank(m_predRanks2add[j]);
        int idx = m_dataAlphabet.lookupIndex("TOK_PRED=" + label.toString() + "_@_RANK_" + m_predRanks2add[j]);

        assert(idx >= 0);
        afv2.add(idx, 1);
      }
      fva[i] = afv2;
    }

    carrier.setData(new FeatureVectorSequence(fva));
View Full Code Here

    Object instName = (inst.getName() == null ? "NONAME" : inst.getName());
   
    for (int j = 0; j < fvs.size(); j++) {
      FeatureVector fv = fvs.getFeatureVector(j);
      int[] indices = fv.getIndices();
      FeatureVector data = new AugmentableFeatureVector (alphabetsPipe.getDataAlphabet(),
          indices, fv.getValues(), indices.length);
      Labeling target = ls.getLabelAtPosition(j);
      String name = instName.toString() + "_@_POS_" + (j + 1);
      Object source = inst.getSource();
      Instance toAdd = alphabetsPipe.pipe(new Instance(data, target, name, source));
View Full Code Here

  }

  public Record (Alphabet fieldAlph, Alphabet valueAlph, String[][] vals) {
    this(fieldAlph, valueAlph);
    for (int i = 0; i < vals.length; i++) {
      AugmentableFeatureVector afv = new AugmentableFeatureVector(valueAlph, false);
      for (int j = 1; j < vals[i].length; j++)
        afv.add(valueAlph.lookupIndex(vals[i][j]), 1.0);
      field2values.put(fieldAlph.lookupIndex(vals[i][0]), afv.toFeatureVector());
    }
  }
View Full Code Here

  }

  public void testDotProductBinaryToSV ()
  {
    SparseVector v = makeSparseVectorToN (5);
    AugmentableFeatureVector afv = makeAfv (new int[] { 1, 3 }, true);
    double dp = afv.dotProduct (v);
    assertEquals (4.0, dp, 1e-5);
    new AugmentableFeatureVector (new Alphabet(), true);
  }
View Full Code Here

  }

  public void testDotProductSparseASVToSV ()
  {
    SparseVector v = makeSparseVectorToN (7);
    AugmentableFeatureVector afv = makeAfv (new int[] { 1, 3 }, false);
    double dp = afv.dotProduct (v);
    assertEquals (4.0, dp, 1e-5);

    afv = makeAfv (new int[] { 2, 5 }, false);
    dp = afv.dotProduct (v);
    assertEquals (7.0, dp, 1e-5);
  }
View Full Code Here

    assertEquals (7.0, dp, 1e-5);
  }

  private AugmentableFeatureVector makeAfv (int[] ints, boolean binary)
  {
    AugmentableFeatureVector afv = new AugmentableFeatureVector (new Alphabet(), binary);
    for (int i = 0; i < ints.length; i++) {
      int idx = ints[i];
      afv.add (idx, 1.0);
    }
    return afv;
  }
View Full Code Here

    dict.lookupIndex ("TWO");
    dict.lookupIndex ("THREE");

    FeatureVector fv = new FeatureVector (dict, new int[] { 1,3 });

    AugmentableFeatureVector afv = new AugmentableFeatureVector (new Alphabet (), true);
    afv.add (fv, "O:");

    assertEquals (4, dict.size());
    assertEquals (2, afv.getAlphabet ().size());
    assertEquals ("O:ONE\nO:THREE\n", afv.toString ());
  }
View Full Code Here

    super ((Alphabet)null, null);
  }

  public Instance pipe (Instance carrier)
  {
    AugmentableFeatureVector afv = (AugmentableFeatureVector)carrier.getData();
    double v;
    for (int i = afv.numLocations() - 1; i >= 0; i--) {
      v = afv.valueAtLocation (i);
      if (v >= 1)
        afv.setValueAtLocation (i, Math.log(v)+1);
    }
    return carrier;
  }
View Full Code Here

        }
        int[] featureIndicesArr = new int[featureIndices.size()];
        for (int index = 0; index < featureIndices.size(); index++) {
          featureIndicesArr[index] = featureIndices.get(index);
        }
        fvs[l] = featureInductionOption.value ? new AugmentableFeatureVector(features, featureIndicesArr, null, featureIndicesArr.length) :
          new FeatureVector(features, featureIndicesArr);
      }
      carrier.setData(new FeatureVectorSequence(fvs));
      if (isTargetProcessing()) {
        carrier.setTarget(target);
View Full Code Here

TOP

Related Classes of cc.mallet.types.AugmentableFeatureVector

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.