cc.mallet.types.Alphabet.size()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(6.9k)|赞(0)|评价(0)|浏览(92)

本文整理了Java中cc.mallet.types.Alphabet.size()方法的一些代码示例,展示了Alphabet.size()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Alphabet.size()方法的具体详情如下:
包路径:cc.mallet.types.Alphabet
类名称:Alphabet
方法名:size

Alphabet.size介绍

暂无

代码示例

代码示例来源:origin: cc.mallet/mallet

/** Current size of the Vocabulary */
  public int size() 
  {
    return dataAlphabet.size();
  }
}

代码示例来源:origin: cc.mallet/mallet

public boolean isDataAlphabetSet() 
{
  if (dataAlphabet != null && dataAlphabet.size() > 0)
    return true;
  return false;
}

代码示例来源:origin: com.github.steveash.mallet/mallet

public Logged (double[] probabilities, Alphabet dictionary,
               int size, boolean areLoggedAlready)
{
  super (probabilities, dictionary, size, true, !areLoggedAlready);
  assert (dictionary == null || dictionary.size() == size);
  if (!areLoggedAlready)
    for (int i = 0; i < size; i++)
      values[i] = Math.log (values[i]);
}

代码示例来源:origin: cc.mallet/mallet

public int increment (int featureIndex, int incr) {
  if (featureIndex < 0 || featureIndex > alphabet.size())
    throw new IllegalArgumentException ("featureIndex "+featureIndex+" out of range");
  return featureCounts.adjustOrPutValue(featureIndex, incr, incr);
}

代码示例来源:origin: cc.mallet/mallet

public HMM(Alphabet inputAlphabet, Alphabet outputAlphabet) {
  inputAlphabet.stopGrowth();
  logger.info("HMM input dictionary size = " + inputAlphabet.size());
  this.inputAlphabet = inputAlphabet;
  this.outputAlphabet = outputAlphabet;
}

代码示例来源:origin: de.julielab/jcore-mallet-2.0.9

public boolean structureMatches (Factors other) {
  if (weightAlphabet.size() != other.weightAlphabet.size()) return false;
  if (weights.length != other.weights.length) return false;
  // gsc: checking each SparseVector's size within weights.
  for (int i = 0; i < weights.length; i++)
    if (weights[i].numLocations() != other.weights[i].numLocations()) return false;
  // Note that we are not checking the indices of the SparseVectors in weights
  if (defaultWeights.length != other.defaultWeights.length) return false;
  assert (initialWeights.length == finalWeights.length);
  if (initialWeights.length != other.initialWeights.length) return false;
  return true;
}

代码示例来源:origin: de.julielab/jcore-mallet-2.0.9

public int put (int featureIndex, int value) {
  if (featureIndex < 0 || featureIndex > alphabet.size())
    throw new IllegalArgumentException ("featureIndex "+featureIndex+" out of range");
  return featureCounts.put (featureIndex, value);
}

代码示例来源:origin: de.julielab/jcore-mallet-2.0.9

public void addFullyConnectedStatesForLabels() {
  String[] labels = new String[outputAlphabet.size()];
  // This is assuming the the entries in the outputAlphabet are Strings!
  for (int i = 0; i < outputAlphabet.size(); i++) {
    labels[i] = (String) outputAlphabet.lookupObject(i);
  }
  addFullyConnectedStates(labels);
}

代码示例来源:origin: com.github.steveash.mallet/mallet

/** Constructor that takes an alphabet representing the
 *    meaning of each dimension
 */
public Dirichlet (double[] alphas, Alphabet dict)
{
  this(alphas);
  if (dict != null && alphas.length != dict.size())
    throw new IllegalArgumentException ("alphas and dict sizes do not match.");
  this.dict = dict;
  if (dict != null)
    dict.stopGrowth();
}

代码示例来源:origin: com.github.steveash.mallet/mallet

public int increment (int featureIndex) {
  if (featureIndex < 0 || featureIndex > alphabet.size())
    throw new IllegalArgumentException ("featureIndex "+featureIndex+" out of range");
  return featureCounts.adjustOrPutValue(featureIndex, 1, 1);
}

代码示例来源:origin: com.github.steveash.mallet/mallet

public int increment (int featureIndex, int incr) {
  if (featureIndex < 0 || featureIndex > alphabet.size())
    throw new IllegalArgumentException ("featureIndex "+featureIndex+" out of range");
  return featureCounts.adjustOrPutValue(featureIndex, incr, incr);
}

代码示例来源:origin: cc.mallet/mallet

public void addFullyConnectedStatesForLabels ()
{
  String[] labels = new String[outputAlphabet.size()];
  // This is assuming the the entries in the outputAlphabet are Strings!
  for (int i = 0; i < outputAlphabet.size(); i++) {
    logger.fine ("CRF: outputAlphabet.lookup class = "+
        outputAlphabet.lookupObject(i).getClass().getName());
    labels[i] = (String) outputAlphabet.lookupObject(i);
  }
  addFullyConnectedStates (labels);
}

代码示例来源:origin: de.julielab/jcore-mallet-2.0.9

public void addFullyConnectedStatesForLabels ()
{
  String[] labels = new String[outputAlphabet.size()];
  // This is assuming the the entries in the outputAlphabet are Strings!
  for (int i = 0; i < outputAlphabet.size(); i++) {
    logger.info ("CRF: outputAlphabet.lookup class = "+
        outputAlphabet.lookupObject(i).getClass().getName());
    labels[i] = (String) outputAlphabet.lookupObject(i);
  }
  addFullyConnectedStates (labels);
}

代码示例来源:origin: cc.mallet/mallet

public void printParameters(String filename) throws IOException {
  Alphabet alphabet = data.getDataAlphabet();
  PrintWriter out = new PrintWriter(filename);
  
  for (int feature = 0; feature < alphabet.size(); feature++) {
    out.printf("%s\t%.8f\n", alphabet.lookupObject(feature), coefficients[feature]);
  }
  out.close();
}

代码示例来源:origin: cc.mallet/mallet

public CRF (Alphabet inputAlphabet, Alphabet outputAlphabet)
{
  super (new Noop(inputAlphabet, outputAlphabet), null);
  inputAlphabet.stopGrowth();
  logger.info ("CRF input dictionary size = "+inputAlphabet.size());
  //xxx outputAlphabet.stopGrowth();
  this.inputAlphabet = inputAlphabet;
  this.outputAlphabet = outputAlphabet;
}

代码示例来源:origin: de.julielab/jcore-mallet-2.0.9

TestResults (Instance inst)
{
 alphabet = new Alphabet ();
 setupAlphabet (inst);
 numClasses = alphabet.size ();
 confusion = new int [numClasses][numClasses];
 precision = new double [numClasses];
 recall = new double [numClasses];
 f1 = new double [numClasses];
}

代码示例来源:origin: com.github.steveash.jg2p/jg2p-core

public static RankedFeatureVector gradientGainRatioFrom(InstanceList ilist, CRF crf) {
 int numFeatures = ilist.getDataAlphabet().size();
 double[] gradientgains = new double[numFeatures];
 double[] gradientlosses = new double[numFeatures];
 fillResults(ilist, crf, null, gradientgains, gradientlosses);
 return makeRatioVector(ilist, numFeatures, gradientgains, gradientlosses);
}

代码示例来源:origin: com.github.steveash.jg2p/jg2p-core

public static Pair<RankedFeatureVector, RankedFeatureVector> gradientsFrom(InstanceList ilist, CRF crf) {
 int numFeatures = ilist.getDataAlphabet().size();
 double[] gradientgains = new double[numFeatures];
 double[] pos = new double[numFeatures];
 double[] neg = new double[numFeatures];
 fillResults(ilist, crf, gradientgains, pos, neg);
 return Pair.of(new RankedFeatureVector(ilist.getDataAlphabet(), gradientgains),
         makeRatioVector(ilist, numFeatures, pos, neg));
}

代码示例来源:origin: com.github.steveash.mallet/mallet

public PerLabelInfoGain (InstanceList ilist)
{
  double[][] pcig = calcPerLabelInfoGains (ilist);
  Alphabet v = ilist.getDataAlphabet();
  int numClasses = ilist.getTargetAlphabet().size();
  ig = new InfoGain[numClasses];
  for (int i = 0; i < numClasses; i++)
    ig[i] = new InfoGain (v, pcig[i]);
}

代码示例来源:origin: cc.mallet/mallet

public void testConcatenatePipes ()
{
 Pipe p1 = new StupidPipe ();
 Pipe p2 = new SimpleTagger.SimpleTaggerSentence2FeatureVectorSequence ();
 // initialize p2's dict
 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 ());
}

相关文章