Package cc.mallet.types

Examples of cc.mallet.types.Alphabet


public class SvmLight2FeatureVectorAndLabel extends Pipe {

  private static final long serialVersionUID = 1L;
 
  public SvmLight2FeatureVectorAndLabel () {
    super (new Alphabet(), new LabelAlphabet());
  }
View Full Code Here


    super (name);
  }

  public void testNotFound ()
  {
    Alphabet dict = new Alphabet ();
    dict.lookupIndex ("TEST1");
    dict.lookupIndex ("TEST2");
    dict.lookupIndex ("TEST3");
    assertEquals (-1, dict.lookupIndex ("TEST4", false));
    assertEquals (3, dict.size());
    assertEquals (3, dict.lookupIndex ("TEST4", true));
  }
View Full Code Here

  }

  // tests a bug where
  public void testReadResolve () throws IOException, ClassNotFoundException
  {
    Alphabet dict = new Alphabet ();
    dict.lookupIndex ("TEST1");
    dict.lookupIndex ("TEST2");
    dict.lookupIndex ("TEST3");
    Alphabet dict2 = (Alphabet) TestSerializable.cloneViaSerialization (dict);
    assertTrue (dict == dict2);
  }
View Full Code Here

    p2.instanceFrom(new Instance (data, null, null, null));

    assertEquals (3, p2.getDataAlphabet ().size());

    Pipe serial = PipeUtils.concatenatePipes (p1, p2);
    Alphabet dict = serial.getDataAlphabet ();

    assertEquals (3, dict.size ());
    assertTrue (dict == p2.getDataAlphabet ());
  }
View Full Code Here

  public void testConcatenateBadPipes ()
  {
    Pipe p1 = new SimpleTaggerSentence2TokenSequence ();
    // force resolving data alphabet
    Alphabet dict1 = p1.getDataAlphabet ();

    Pipe p2 = new SimpleTaggerSentence2TokenSequence ();
    // force resolving data alphabet
    Alphabet dict2 = p2.getDataAlphabet ();

    assertTrue (dict1 != dict2);

    try {
      PipeUtils.concatenatePipes (p1, p2);
View Full Code Here

    Randoms random = new Randoms(123);
    Clusterer clusterer = null;
    if (!loadClusterer.value.exists()) {
      Clusterings training = readClusterings(trainingFile.value);

      Alphabet fieldAlphabet = ((Record) training.get(0).getInstances()
          .get(0).getData()).fieldAlphabet();

      Pipe pipe = new ClusteringPipe(string2ints(exactMatchFields.value, fieldAlphabet),
                                 string2ints(approxMatchFields.value, fieldAlphabet),
                                 string2ints(substringMatchFields.value, fieldAlphabet));
View Full Code Here

    double approxMatchThreshold;

    public ClusteringPipe(int[] exactMatchFields, int[] approxMatchFields,
        int[] substringMatchFields) {
      super(new Alphabet(), new LabelAlphabet());
      this.exactMatchFields = exactMatchFields;
      this.approxMatchFields = approxMatchFields;
      this.substringMatchFields = substringMatchFields;
    }
View Full Code Here

      int[] cluster1 = neighbor.getOldClusters()[0];
      int[] cluster2 = neighbor.getOldClusters()[1];
      InstanceList list = original.getInstances();
      int[] mergedIndices = neighbor.getNewCluster();
      Record[] records = array2Records(mergedIndices, list);
      Alphabet fieldAlph = records[0].fieldAlphabet();
      Alphabet valueAlph = records[0].valueAlphabet();

      PropertyList features = null;
      features = addExactMatch(records, fieldAlph, valueAlph, features);
      features = addApproxMatch(records, fieldAlph, valueAlph, features);
      features = addSubstringMatch(records, fieldAlph, valueAlph, features);
View Full Code Here

    if (selectedFeatures != null)
      // xxx Attend to FeatureSelection!!!
      throw new UnsupportedOperationException ("FeatureSelection not yet implemented.");

    double epsilon = m_epsilon;
    Alphabet dict = (Alphabet) trainingList.getDataAlphabet ();
    int numLabels = trainingList.getTargetAlphabet().size();
    int numFeats = dict.size();
    m_weights = new double [numLabels][numFeats+1];

    // init weights to 1
    for(int i = 0; i < numLabels; i++)
      Arrays.fill(m_weights[i], 1.0);
View Full Code Here

    print(System.out);
  }

  @Override
  public void print(PrintWriter out) {
    final Alphabet dict = getAlphabet();
    final LabelAlphabet labelDict = getLabelAlphabet();

    int numFeatures = dict.size() + 1;
    int numLabels = labelDict.size();

    // 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

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.