本文整理汇总了Java中cc.mallet.types.Instance.getDataAlphabet方法的典型用法代码示例。如果您正苦于以下问题:Java Instance.getDataAlphabet方法的具体用法?Java Instance.getDataAlphabet怎么用?Java Instance.getDataAlphabet使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cc.mallet.types.Instance
的用法示例。
在下文中一共展示了Instance.getDataAlphabet方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: makeList
import cc.mallet.types.Instance; //导入方法依赖的package包/类
/**
*
* @param i
* @param j
* @return A new {@link InstanceList} containing the two argument {@link Instance}s.
*/
public static InstanceList makeList (Instance i, Instance j) {
InstanceList list = new InstanceList(new Noop(i.getDataAlphabet(), i.getTargetAlphabet()));
list.add(i);
list.add(j);
return list;
}
示例2: setup
import cc.mallet.types.Instance; //导入方法依赖的package包/类
private void setup (InstanceList instances, Instance instance) {
assert (instances != null || instance != null);
if (instance == null && instances != null)
instance = instances.get(0);
// Initialize the alphabets
if (dataAlphabet == null) {
this.dataAlphabet = instance.getDataAlphabet();
this.targetAlphabet = instance.getTargetAlphabet();
} else if (!Alphabet.alphabetsMatch(instance, this))
// Make sure the alphabets match
throw new IllegalArgumentException ("Training set alphabets do not match those of NaiveBayesTrainer.");
// Initialize or check the instancePipe
if (instances != null) {
if (instancePipe == null)
instancePipe = instances.getPipe();
else if (instancePipe != instances.getPipe())
// Make sure that this pipes match. Is this really necessary??
// I don't think so, but it could be confusing to have each returned classifier have a different pipe? -akm 1/08
throw new IllegalArgumentException ("Training set pipe does not match that of NaiveBayesTrainer.");
}
if (me == null) {
int numLabels = targetAlphabet.size();
me = new Multinomial.Estimator[numLabels];
for (int i = 0; i < numLabels; i++) {
me[i] = (Multinomial.Estimator) featureEstimator.clone();
me[i].setAlphabet(dataAlphabet);
}
pe = (Multinomial.Estimator) priorEstimator.clone();
}
if (targetAlphabet.size() > me.length) {
// target alphabet grew. increase size of our multinomial array
int targetAlphabetSize = targetAlphabet.size();
// copy over old values
Multinomial.Estimator[] newMe = new Multinomial.Estimator[targetAlphabetSize];
System.arraycopy (me, 0, newMe, 0, me.length);
// initialize new expanded space
for (int i= me.length; i<targetAlphabetSize; i++){
Multinomial.Estimator mest = (Multinomial.Estimator)featureEstimator.clone ();
mest.setAlphabet (dataAlphabet);
newMe[i] = mest;
}
me = newMe;
}
}