Package cc.mallet.types

Examples of cc.mallet.types.Alphabet


  }

  public void testMaxLattice() {
    int inputVocabSize = 1;
    int numStates = 2;
    Alphabet inputAlphabet = new Alphabet();
    for (int i = 0; i < inputVocabSize; i++)
      inputAlphabet.lookupIndex("feature" + i);
    Alphabet outputAlphabet = new Alphabet();

    CRF crf = new CRF(inputAlphabet, outputAlphabet);

    String[] stateNames = new String[numStates];
    for (int i = 0; i < numStates; i++)
View Full Code Here


    int inputVocabSize = 4;
    int numStates = 5;
    // Create a file to store the CRF
    File f = new File("TestObject.obj");
    File f2 = new File("TestObject2.obj");
    Alphabet inputAlphabet = new Alphabet();
    for (int i = 0; i < inputVocabSize; i++)
      inputAlphabet.lookupIndex("feature" + i);
    Alphabet outputAlphabet = new Alphabet();
    String[] stateNames = new String[numStates];
    for (int i = 0; i < numStates; i++) {
      stateNames[i] = "state" + i;
      outputAlphabet.lookupIndex(stateNames[i]);
    }

    CRF crf = new CRF(inputAlphabet, outputAlphabet);
    CRF saveCRF = crf;
    // inputAlphabet = (Feature.Alphabet) crf.getInputAlphabet();
View Full Code Here

    super (name);
  }
 
  public void testNewPutSizeFreeze ()
  {
    Alphabet dict = new Alphabet ();
    FeatureSequence fs = new FeatureSequence (dict, 10);
    fs.add (dict.lookupIndex ("apple"));
    fs.add (dict.lookupIndex ("bear"));
    fs.add (dict.lookupIndex ("car"));
    fs.add (dict.lookupIndex ("door"));
    assertTrue (fs.size() == 4);
    double[] weights = new double[4];
    fs.addFeatureWeightsTo (weights);
    assertTrue (weights[1] == 1.0);

    fs.add (dict.lookupIndex ("bear"));
    int[] feats = fs.toFeatureIndexSequence();
    assertTrue (feats[0] == 0);
    assertTrue (feats[1] == 1);
    assertTrue (feats[2] == 2);
    assertTrue (feats[3] == 3);
View Full Code Here

    this (dataDict, false, false);
  }
 
  public TokenSequence2FeatureVectorSequence (boolean binary, boolean augmentable)
  {
    super (new Alphabet(), null);
    this.augmentable = augmentable;
    this.binary = binary;
  }
View Full Code Here

  private static int[] indicesWithConjunctions (FeatureVector fv, Alphabet newVocab, int[] conjunctions)
  {
    assert (fv.values == null);          // Only works on binary feature vectors
    assert (! (fv instanceof AugmentableFeatureVector));
    Alphabet v = fv.getAlphabet();
    // newVocab should be an augmented copy of v
    assert (v.size() <= newVocab.size())
                        : "fv.vocab.size="+v.size()+" newVocab.size="+newVocab.size();
    int[] newIndices = new int[fv.indices.length * conjunctions.length];
    java.util.Arrays.sort (conjunctions);
    System.arraycopy (fv.indices, 0, newIndices, 0, fv.indices.length);
    int size = fv.indices.length;
    int ci = 0;
View Full Code Here

                                                FeatureSelection fsNarrow,
                                                FeatureSelection fsWide)
  {
    assert (fv.values == null);          // Only works on binary feature vectors
    ////assert (! (fv instanceof AugmentableFeatureVector));
    Alphabet v = fv.getAlphabet();
    // newVocab should be an augmented copy of v
    assert (v.size() <= newVocab.size())
                        : "fv.vocab.size="+v.size()+" newVocab.size="+newVocab.size();
    int length;
    if (fv instanceof AugmentableFeatureVector) {
      length = ((AugmentableFeatureVector)fv).size;
      ((AugmentableFeatureVector)fv).sortIndices();
    } else {
View Full Code Here

    return b.toString();
  }

  public static void main (String[] args) {
    Record r =
        new Record(new Alphabet(), new Alphabet(),
                    new String[][] { { "field1", "f1v1", "f1v2" },
                                    { "field2", "f2v1" },
                                    { "field3", "f3v1", "f3v2", "f3v3" } });
    System.out.println(r);
  }
View Full Code Here

    this.random = new Randoms(123456789);
    this.noise = 0.01;
  }
 
  public void run () {
    Alphabet alphabet = dictOfSize(20);
   
    // TRAIN
    Clustering training = sampleClustering(alphabet);   
    Pipe clusterPipe = new OverlappingFeaturePipe();
    System.err.println("Training with " + training);
View Full Code Here

    }
    return singletons;
  }

   private Alphabet dictOfSize (int size) {
    Alphabet ret = new Alphabet ();
    for (int i = 0; i < size; i++)
      ret.lookupIndex ("feature"+i);
     return ret;
  }
View Full Code Here

  private class OverlappingFeaturePipe extends Pipe {

    private static final long serialVersionUID = 1L;

    public OverlappingFeaturePipe () {
      super (new Alphabet(), new LabelAlphabet());     
    }
View Full Code Here

TOP

Related Classes of cc.mallet.types.Alphabet

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.