本文整理了Java中cc.mallet.types.Alphabet.clone()
方法的一些代码示例,展示了Alphabet.clone()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Alphabet.clone()
方法的具体详情如下:
包路径:cc.mallet.types.Alphabet
类名称:Alphabet
方法名:clone
暂无
代码示例来源:origin: cc.mallet/mallet
private void copyStatesAndWeightsFrom (CRF initialCRF)
{
this.parameters = new Factors (initialCRF.parameters, true); // This will copy all the transition weights
this.parameters.weightAlphabet = (Alphabet) initialCRF.parameters.weightAlphabet.clone();
//weightAlphabet = (Alphabet) initialCRF.weightAlphabet.clone ();
//weights = new SparseVector [initialCRF.weights.length];
states.clear ();
// Clear these, because they will be filled by this.addState()
this.parameters.initialWeights = new double[0];
this.parameters.finalWeights = new double[0];
for (int i = 0; i < initialCRF.states.size(); i++) {
State s = (State) initialCRF.getState (i);
String[][] weightNames = new String[s.weightsIndices.length][];
for (int j = 0; j < weightNames.length; j++) {
int[] thisW = s.weightsIndices[j];
weightNames[j] = (String[]) initialCRF.parameters.weightAlphabet.lookupObjects(thisW, new String [s.weightsIndices[j].length]);
}
addState (s.name, initialCRF.parameters.initialWeights[i], initialCRF.parameters.finalWeights[i],
s.destinationNames, s.labels, weightNames);
}
featureSelections = initialCRF.featureSelections.clone ();
// yyy weightsFrozen = (boolean[]) initialCRF.weightsFrozen.clone();
}
代码示例来源:origin: com.github.steveash.mallet/mallet
/** Construct new Factors by copying the other one. */
public Factors (Factors other, boolean cloneAlphabet) {
weightAlphabet = cloneAlphabet ? (Alphabet) other.weightAlphabet.clone() : other.weightAlphabet;
weights = new SparseVector[other.weights.length];
for (int i = 0; i < weights.length; i++)
weights[i] = (SparseVector) other.weights[i].cloneMatrix();
defaultWeights = other.defaultWeights.clone();
weightsFrozen = other.weightsFrozen;
initialWeights = other.initialWeights.clone();
finalWeights = other.finalWeights.clone();
}
代码示例来源:origin: cc.mallet/mallet
/** Construct new Factors by copying the other one. */
public Factors (Factors other, boolean cloneAlphabet) {
weightAlphabet = cloneAlphabet ? (Alphabet) other.weightAlphabet.clone() : other.weightAlphabet;
weights = new SparseVector[other.weights.length];
for (int i = 0; i < weights.length; i++)
weights[i] = (SparseVector) other.weights[i].cloneMatrix();
defaultWeights = other.defaultWeights.clone();
weightsFrozen = other.weightsFrozen;
initialWeights = other.initialWeights.clone();
finalWeights = other.finalWeights.clone();
}
代码示例来源:origin: de.julielab/jcore-mallet-2.0.9
/** Construct new Factors by copying the other one. */
public Factors (Factors other, boolean cloneAlphabet) {
weightAlphabet = cloneAlphabet ? (Alphabet) other.weightAlphabet.clone() : other.weightAlphabet;
weights = new SparseVector[other.weights.length];
for (int i = 0; i < weights.length; i++)
weights[i] = (SparseVector) other.weights[i].cloneMatrix();
defaultWeights = other.defaultWeights.clone();
weightsFrozen = other.weightsFrozen;
initialWeights = other.initialWeights.clone();
finalWeights = other.finalWeights.clone();
}
代码示例来源:origin: de.julielab/jcore-mallet-2.0.9
private void copyStatesAndWeightsFrom (CRF initialCRF)
{
this.parameters = new Factors (initialCRF.parameters, true); // This will copy all the transition weights
this.parameters.weightAlphabet = (Alphabet) initialCRF.parameters.weightAlphabet.clone();
//weightAlphabet = (Alphabet) initialCRF.weightAlphabet.clone ();
//weights = new SparseVector [initialCRF.weights.length];
states.clear ();
// Clear these, because they will be filled by this.addState()
this.parameters.initialWeights = new double[0];
this.parameters.finalWeights = new double[0];
for (int i = 0; i < initialCRF.states.size(); i++) {
State s = (State) initialCRF.getState (i);
String[][] weightNames = new String[s.weightsIndices.length][];
for (int j = 0; j < weightNames.length; j++) {
int[] thisW = s.weightsIndices[j];
weightNames[j] = (String[]) initialCRF.parameters.weightAlphabet.lookupObjects(thisW, new String [s.weightsIndices[j].length]);
}
addState (s.name, initialCRF.parameters.initialWeights[i], initialCRF.parameters.finalWeights[i],
s.destinationNames, s.labels, weightNames);
}
featureSelections = initialCRF.featureSelections.clone ();
// yyy weightsFrozen = (boolean[]) initialCRF.weightsFrozen.clone();
}
代码示例来源:origin: com.github.steveash.mallet/mallet
private void copyStatesAndWeightsFrom (CRF initialCRF)
{
this.parameters = new Factors (initialCRF.parameters, true); // This will copy all the transition weights
this.parameters.weightAlphabet = (Alphabet) initialCRF.parameters.weightAlphabet.clone();
//weightAlphabet = (Alphabet) initialCRF.weightAlphabet.clone ();
//weights = new SparseVector [initialCRF.weights.length];
states.clear ();
// Clear these, because they will be filled by this.addState()
this.parameters.initialWeights = new double[0];
this.parameters.finalWeights = new double[0];
for (int i = 0; i < initialCRF.states.size(); i++) {
State s = (State) initialCRF.getState (i);
String[][] weightNames = new String[s.weightsIndices.length][];
for (int j = 0; j < weightNames.length; j++) {
int[] thisW = s.weightsIndices[j];
weightNames[j] = (String[]) initialCRF.parameters.weightAlphabet.lookupObjects(thisW, new String [s.weightsIndices[j].length]);
}
addState (s.name, initialCRF.parameters.initialWeights[i], initialCRF.parameters.finalWeights[i],
s.destinationNames, s.labels, weightNames);
}
featureSelections = initialCRF.featureSelections.clone ();
// yyy weightsFrozen = (boolean[]) initialCRF.weightsFrozen.clone();
}
代码示例来源:origin: cc.mallet/mallet
public AddClassifierTokenPredictions(TokenClassifiers tokenClassifiers, int[] predRanks2add,
boolean binary, InstanceList testList)
{
m_predRanks2add = predRanks2add;
m_binary = binary;
m_tokenClassifiers = tokenClassifiers;
m_inProduction = false;
m_dataAlphabet = (Alphabet) tokenClassifiers.getAlphabet().clone();
Alphabet labelAlphabet = tokenClassifiers.getLabelAlphabet();
// add the token prediction features to the alphabet
for (int i = 0; i < m_predRanks2add.length; i++) {
for (int j = 0; j < labelAlphabet.size(); j++) {
String featName = "TOK_PRED=" + labelAlphabet.lookupObject(j).toString() + "_@_RANK_" + m_predRanks2add[i];
m_dataAlphabet.lookupIndex(featName, true);
}
}
// evaluate token classifier
if (testList != null) {
Trial trial = new Trial(m_tokenClassifiers, testList);
logger.info("Token classifier accuracy on test set = " + trial.getAccuracy());
}
}
代码示例来源:origin: de.julielab/jcore-mallet-2.0.9
public AddClassifierTokenPredictions(TokenClassifiers tokenClassifiers, int[] predRanks2add,
boolean binary, InstanceList testList)
{
m_predRanks2add = predRanks2add;
m_binary = binary;
m_tokenClassifiers = tokenClassifiers;
m_inProduction = false;
m_dataAlphabet = (Alphabet) tokenClassifiers.getAlphabet().clone();
Alphabet labelAlphabet = tokenClassifiers.getLabelAlphabet();
// add the token prediction features to the alphabet
for (int i = 0; i < m_predRanks2add.length; i++) {
for (int j = 0; j < labelAlphabet.size(); j++) {
String featName = "TOK_PRED=" + labelAlphabet.lookupObject(j).toString() + "_@_RANK_" + m_predRanks2add[i];
m_dataAlphabet.lookupIndex(featName, true);
}
}
// evaluate token classifier
if (testList != null) {
Trial trial = new Trial(m_tokenClassifiers, testList);
logger.info("Token classifier accuracy on test set = " + trial.getAccuracy());
}
}
代码示例来源:origin: com.github.steveash.mallet/mallet
public AddClassifierTokenPredictions(TokenClassifiers tokenClassifiers, int[] predRanks2add,
boolean binary, InstanceList testList)
{
m_predRanks2add = predRanks2add;
m_binary = binary;
m_tokenClassifiers = tokenClassifiers;
m_inProduction = false;
m_dataAlphabet = (Alphabet) tokenClassifiers.getAlphabet().clone();
Alphabet labelAlphabet = tokenClassifiers.getLabelAlphabet();
// add the token prediction features to the alphabet
for (int i = 0; i < m_predRanks2add.length; i++) {
for (int j = 0; j < labelAlphabet.size(); j++) {
String featName = "TOK_PRED=" + labelAlphabet.lookupObject(j).toString() + "_@_RANK_" + m_predRanks2add[i];
m_dataAlphabet.lookupIndex(featName, true);
}
}
// evaluate token classifier
if (testList != null) {
Trial trial = new Trial(m_tokenClassifiers, testList);
logger.info("Token classifier accuracy on test set = " + trial.getAccuracy());
}
}
代码示例来源:origin: cc.mallet/mallet
return;
Alphabet tmpDV = (Alphabet) ilist.getDataAlphabet().clone();
FeatureSelection featuresSelected = ilist.getFeatureSelection();
InstanceList tmpilist = new InstanceList (tmpDV, ilist.getTargetAlphabet());
代码示例来源:origin: de.julielab/jcore-mallet-2.0.9
return;
Alphabet tmpDV = (Alphabet) ilist.getDataAlphabet().clone();
FeatureSelection featuresSelected = ilist.getFeatureSelection();
InstanceList tmpilist = new InstanceList (tmpDV, ilist.getTargetAlphabet());
代码示例来源:origin: com.github.steveash.mallet/mallet
return;
Alphabet tmpDV = (Alphabet) ilist.getDataAlphabet().clone();
FeatureSelection featuresSelected = ilist.getFeatureSelection();
InstanceList tmpilist = new InstanceList (tmpDV, ilist.getTargetAlphabet());
内容来源于网络,如有侵权,请联系作者删除!