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

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

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

Alphabet.lookupObject介绍

[英]Returns an array of the objects corresponding to
[中]返回对应于的对象的数组

代码示例

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

public String[] getWeightNames (int index) {
  int[] indices = this.weightsIndices[index];
  String[] ret = new String[indices.length];
  for (int i=0; i < ret.length; i++)
    ret[i] = crf.parameters.weightAlphabet.lookupObject(indices[i]).toString();
  return ret;
}

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

public void print () {
  System.out.println ("Dirichlet:");
  for (int j = 0; j < partition.length; j++)
    System.out.println (dict!= null ? dict.lookupObject(j).toString() : j + "=" + magnitude * partition[j]);
}

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

public void print () {
  System.out.println ("Dirichlet:");
  for (int j = 0; j < partition.length; j++)
    System.out.println (dict!= null ? dict.lookupObject(j).toString() : j + "=" + magnitude * partition[j]);
}

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

public void print () {
  System.out.println ("Dirichlet:");
  for (int j = 0; j < partition.length; j++)
    System.out.println (dict!= null ? dict.lookupObject(j).toString() : j + "=" + magnitude * partition[j]);
}

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

public void write(PrintWriter out) {
  for (int word = 0; word < numWords; word++) {
    Formatter buffer = new Formatter();
    buffer.format("%s", vocabulary.lookupObject(word));
    for (int col = 0; col < numColumns; col++) {
      buffer.format(" %.6f", weights[word * stride + col]);
    }
    out.println(buffer);
  }
}

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

public void write(PrintWriter out) {
  for (int word = 0; word < numWords; word++) {
    Formatter buffer = new Formatter(Locale.US);
    buffer.format("%s", vocabulary.lookupObject(word));
    for (int col = 0; col < numColumns; col++) {
      buffer.format(" %.6f", weights[word * stride + col]);
    }
    out.println(buffer);
  }
}

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

public String[] getVocabulary() {
  String[] vocab = new String[ alphabet.size() ];
  for (int type = 0; type < numTypes; type++) {
    vocab[type] = (String) alphabet.lookupObject(type);
  }
  return vocab;
}

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

public Object randomObject (Randoms r)
{
  if (dictionary == null)
    throw new IllegalStateException ("This Multinomial has no dictionary.");
  return dictionary.lookupObject (randomIndex (r));
}

代码示例来源: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: com.github.steveash.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: de.julielab/jcore-mallet-2.0.9

public String toString (boolean oneLine) {
  StringBuffer b = new StringBuffer();
  int[] keys = field2values.keys();
  for (int i = 0; i < keys.length; i++) {
    b.append(fieldAlph.lookupObject(keys[i]) + "=");
    FeatureVector v = (FeatureVector) field2values.get(keys[i]);
    for (int j = 0; j < v.numLocations(); j++)
      b.append(valueAlph.lookupObject(v.indexAtLocation(j)) + ",");
    if (!oneLine) b.append("\n");
  }
  return b.toString();
}

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

public String toString (boolean oneLine) {
  StringBuffer b = new StringBuffer();
  int[] keys = field2values.keys();
  for (int i = 0; i < keys.length; i++) {
    b.append(fieldAlph.lookupObject(keys[i]) + "=");
    FeatureVector v = (FeatureVector) field2values.get(keys[i]);
    for (int j = 0; j < v.numLocations(); j++)
      b.append(valueAlph.lookupObject(v.indexAtLocation(j)) + ",");
    if (!oneLine) b.append("\n");
  }
  return b.toString();
}

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

public Object getObjectAtRank (final int rank)
{
  setRankOrder (rank);
  return dictionary.lookupObject (getIndexAtRank(rank)); // was return dictionary.lookupObject (rankOrder[rank]);
}

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

public Alphabet getPrunedAlphabet(int minDocs, int maxDocs, int minCount, int maxCount) {
  Alphabet inputAlphabet = instances.getDataAlphabet();
  Alphabet outputAlphabet = new Alphabet();
  for (int inputType = 0; inputType < numFeatures; inputType++) {
    if (featureCounts[inputType] >= minCount && featureCounts[inputType] <= maxCount && documentFrequencies[inputType] >= minDocs && documentFrequencies[inputType] <= maxDocs) {
      outputAlphabet.lookupIndex(inputAlphabet.lookupObject(inputType));
    }
  }
  
  return outputAlphabet;
}

代码示例来源: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

public Alphabet getPrunedAlphabet(int minDocs, int maxDocs, int minCount, int maxCount) {
  Alphabet inputAlphabet = instances.getDataAlphabet();
  Alphabet outputAlphabet = new Alphabet();
  for (int inputType = 0; inputType < numFeatures; inputType++) {
    if (featureCounts[inputType] >= minCount && featureCounts[inputType] <= maxCount && documentFrequencies[inputType] >= minDocs && documentFrequencies[inputType] <= maxDocs) {
      outputAlphabet.lookupIndex(inputAlphabet.lookupObject(inputType));
    }
  }
  
  return outputAlphabet;
}

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

public void addSelfTransitioningStateForAllLabels(String name) {
  String[] labels = new String[outputAlphabet.size()];
  String[] destinationNames = new String[outputAlphabet.size()];
  for (int i = 0; i < outputAlphabet.size(); i++) {
    labels[i] = outputAlphabet.lookupObject(i).toString();
    destinationNames[i] = name;
  }
  addState(name, 0.0, 0.0, destinationNames, labels);
}

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

/** 
 *  Add all pruned words to the internal stoplist of a SimpleTokenizer.
 */
public void addPrunedWordsToStoplist(SimpleTokenizer tokenizer, int minimumCount) {
  Alphabet currentAlphabet = getDataAlphabet();
  for (int feature = 0; feature < currentAlphabet.size(); feature++) {
    if (counter.get(feature) < minimumCount) {
      tokenizer.stop((String) currentAlphabet.lookupObject(feature));
    }
  }
}

相关文章