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

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

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

Alphabet.clone介绍

暂无

代码示例

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

  1. private void copyStatesAndWeightsFrom (CRF initialCRF)
  2. {
  3. this.parameters = new Factors (initialCRF.parameters, true); // This will copy all the transition weights
  4. this.parameters.weightAlphabet = (Alphabet) initialCRF.parameters.weightAlphabet.clone();
  5. //weightAlphabet = (Alphabet) initialCRF.weightAlphabet.clone ();
  6. //weights = new SparseVector [initialCRF.weights.length];
  7. states.clear ();
  8. // Clear these, because they will be filled by this.addState()
  9. this.parameters.initialWeights = new double[0];
  10. this.parameters.finalWeights = new double[0];
  11. for (int i = 0; i < initialCRF.states.size(); i++) {
  12. State s = (State) initialCRF.getState (i);
  13. String[][] weightNames = new String[s.weightsIndices.length][];
  14. for (int j = 0; j < weightNames.length; j++) {
  15. int[] thisW = s.weightsIndices[j];
  16. weightNames[j] = (String[]) initialCRF.parameters.weightAlphabet.lookupObjects(thisW, new String [s.weightsIndices[j].length]);
  17. }
  18. addState (s.name, initialCRF.parameters.initialWeights[i], initialCRF.parameters.finalWeights[i],
  19. s.destinationNames, s.labels, weightNames);
  20. }
  21. featureSelections = initialCRF.featureSelections.clone ();
  22. // yyy weightsFrozen = (boolean[]) initialCRF.weightsFrozen.clone();
  23. }

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

  1. /** Construct new Factors by copying the other one. */
  2. public Factors (Factors other, boolean cloneAlphabet) {
  3. weightAlphabet = cloneAlphabet ? (Alphabet) other.weightAlphabet.clone() : other.weightAlphabet;
  4. weights = new SparseVector[other.weights.length];
  5. for (int i = 0; i < weights.length; i++)
  6. weights[i] = (SparseVector) other.weights[i].cloneMatrix();
  7. defaultWeights = other.defaultWeights.clone();
  8. weightsFrozen = other.weightsFrozen;
  9. initialWeights = other.initialWeights.clone();
  10. finalWeights = other.finalWeights.clone();
  11. }

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

  1. /** Construct new Factors by copying the other one. */
  2. public Factors (Factors other, boolean cloneAlphabet) {
  3. weightAlphabet = cloneAlphabet ? (Alphabet) other.weightAlphabet.clone() : other.weightAlphabet;
  4. weights = new SparseVector[other.weights.length];
  5. for (int i = 0; i < weights.length; i++)
  6. weights[i] = (SparseVector) other.weights[i].cloneMatrix();
  7. defaultWeights = other.defaultWeights.clone();
  8. weightsFrozen = other.weightsFrozen;
  9. initialWeights = other.initialWeights.clone();
  10. finalWeights = other.finalWeights.clone();
  11. }

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

  1. /** Construct new Factors by copying the other one. */
  2. public Factors (Factors other, boolean cloneAlphabet) {
  3. weightAlphabet = cloneAlphabet ? (Alphabet) other.weightAlphabet.clone() : other.weightAlphabet;
  4. weights = new SparseVector[other.weights.length];
  5. for (int i = 0; i < weights.length; i++)
  6. weights[i] = (SparseVector) other.weights[i].cloneMatrix();
  7. defaultWeights = other.defaultWeights.clone();
  8. weightsFrozen = other.weightsFrozen;
  9. initialWeights = other.initialWeights.clone();
  10. finalWeights = other.finalWeights.clone();
  11. }

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

  1. private void copyStatesAndWeightsFrom (CRF initialCRF)
  2. {
  3. this.parameters = new Factors (initialCRF.parameters, true); // This will copy all the transition weights
  4. this.parameters.weightAlphabet = (Alphabet) initialCRF.parameters.weightAlphabet.clone();
  5. //weightAlphabet = (Alphabet) initialCRF.weightAlphabet.clone ();
  6. //weights = new SparseVector [initialCRF.weights.length];
  7. states.clear ();
  8. // Clear these, because they will be filled by this.addState()
  9. this.parameters.initialWeights = new double[0];
  10. this.parameters.finalWeights = new double[0];
  11. for (int i = 0; i < initialCRF.states.size(); i++) {
  12. State s = (State) initialCRF.getState (i);
  13. String[][] weightNames = new String[s.weightsIndices.length][];
  14. for (int j = 0; j < weightNames.length; j++) {
  15. int[] thisW = s.weightsIndices[j];
  16. weightNames[j] = (String[]) initialCRF.parameters.weightAlphabet.lookupObjects(thisW, new String [s.weightsIndices[j].length]);
  17. }
  18. addState (s.name, initialCRF.parameters.initialWeights[i], initialCRF.parameters.finalWeights[i],
  19. s.destinationNames, s.labels, weightNames);
  20. }
  21. featureSelections = initialCRF.featureSelections.clone ();
  22. // yyy weightsFrozen = (boolean[]) initialCRF.weightsFrozen.clone();
  23. }

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

  1. private void copyStatesAndWeightsFrom (CRF initialCRF)
  2. {
  3. this.parameters = new Factors (initialCRF.parameters, true); // This will copy all the transition weights
  4. this.parameters.weightAlphabet = (Alphabet) initialCRF.parameters.weightAlphabet.clone();
  5. //weightAlphabet = (Alphabet) initialCRF.weightAlphabet.clone ();
  6. //weights = new SparseVector [initialCRF.weights.length];
  7. states.clear ();
  8. // Clear these, because they will be filled by this.addState()
  9. this.parameters.initialWeights = new double[0];
  10. this.parameters.finalWeights = new double[0];
  11. for (int i = 0; i < initialCRF.states.size(); i++) {
  12. State s = (State) initialCRF.getState (i);
  13. String[][] weightNames = new String[s.weightsIndices.length][];
  14. for (int j = 0; j < weightNames.length; j++) {
  15. int[] thisW = s.weightsIndices[j];
  16. weightNames[j] = (String[]) initialCRF.parameters.weightAlphabet.lookupObjects(thisW, new String [s.weightsIndices[j].length]);
  17. }
  18. addState (s.name, initialCRF.parameters.initialWeights[i], initialCRF.parameters.finalWeights[i],
  19. s.destinationNames, s.labels, weightNames);
  20. }
  21. featureSelections = initialCRF.featureSelections.clone ();
  22. // yyy weightsFrozen = (boolean[]) initialCRF.weightsFrozen.clone();
  23. }

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

  1. public AddClassifierTokenPredictions(TokenClassifiers tokenClassifiers, int[] predRanks2add,
  2. boolean binary, InstanceList testList)
  3. {
  4. m_predRanks2add = predRanks2add;
  5. m_binary = binary;
  6. m_tokenClassifiers = tokenClassifiers;
  7. m_inProduction = false;
  8. m_dataAlphabet = (Alphabet) tokenClassifiers.getAlphabet().clone();
  9. Alphabet labelAlphabet = tokenClassifiers.getLabelAlphabet();
  10. // add the token prediction features to the alphabet
  11. for (int i = 0; i < m_predRanks2add.length; i++) {
  12. for (int j = 0; j < labelAlphabet.size(); j++) {
  13. String featName = "TOK_PRED=" + labelAlphabet.lookupObject(j).toString() + "_@_RANK_" + m_predRanks2add[i];
  14. m_dataAlphabet.lookupIndex(featName, true);
  15. }
  16. }
  17. // evaluate token classifier
  18. if (testList != null) {
  19. Trial trial = new Trial(m_tokenClassifiers, testList);
  20. logger.info("Token classifier accuracy on test set = " + trial.getAccuracy());
  21. }
  22. }

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

  1. public AddClassifierTokenPredictions(TokenClassifiers tokenClassifiers, int[] predRanks2add,
  2. boolean binary, InstanceList testList)
  3. {
  4. m_predRanks2add = predRanks2add;
  5. m_binary = binary;
  6. m_tokenClassifiers = tokenClassifiers;
  7. m_inProduction = false;
  8. m_dataAlphabet = (Alphabet) tokenClassifiers.getAlphabet().clone();
  9. Alphabet labelAlphabet = tokenClassifiers.getLabelAlphabet();
  10. // add the token prediction features to the alphabet
  11. for (int i = 0; i < m_predRanks2add.length; i++) {
  12. for (int j = 0; j < labelAlphabet.size(); j++) {
  13. String featName = "TOK_PRED=" + labelAlphabet.lookupObject(j).toString() + "_@_RANK_" + m_predRanks2add[i];
  14. m_dataAlphabet.lookupIndex(featName, true);
  15. }
  16. }
  17. // evaluate token classifier
  18. if (testList != null) {
  19. Trial trial = new Trial(m_tokenClassifiers, testList);
  20. logger.info("Token classifier accuracy on test set = " + trial.getAccuracy());
  21. }
  22. }

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

  1. public AddClassifierTokenPredictions(TokenClassifiers tokenClassifiers, int[] predRanks2add,
  2. boolean binary, InstanceList testList)
  3. {
  4. m_predRanks2add = predRanks2add;
  5. m_binary = binary;
  6. m_tokenClassifiers = tokenClassifiers;
  7. m_inProduction = false;
  8. m_dataAlphabet = (Alphabet) tokenClassifiers.getAlphabet().clone();
  9. Alphabet labelAlphabet = tokenClassifiers.getLabelAlphabet();
  10. // add the token prediction features to the alphabet
  11. for (int i = 0; i < m_predRanks2add.length; i++) {
  12. for (int j = 0; j < labelAlphabet.size(); j++) {
  13. String featName = "TOK_PRED=" + labelAlphabet.lookupObject(j).toString() + "_@_RANK_" + m_predRanks2add[i];
  14. m_dataAlphabet.lookupIndex(featName, true);
  15. }
  16. }
  17. // evaluate token classifier
  18. if (testList != null) {
  19. Trial trial = new Trial(m_tokenClassifiers, testList);
  20. logger.info("Token classifier accuracy on test set = " + trial.getAccuracy());
  21. }
  22. }

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

  1. return;
  2. Alphabet tmpDV = (Alphabet) ilist.getDataAlphabet().clone();
  3. FeatureSelection featuresSelected = ilist.getFeatureSelection();
  4. InstanceList tmpilist = new InstanceList (tmpDV, ilist.getTargetAlphabet());

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

  1. return;
  2. Alphabet tmpDV = (Alphabet) ilist.getDataAlphabet().clone();
  3. FeatureSelection featuresSelected = ilist.getFeatureSelection();
  4. InstanceList tmpilist = new InstanceList (tmpDV, ilist.getTargetAlphabet());

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

  1. return;
  2. Alphabet tmpDV = (Alphabet) ilist.getDataAlphabet().clone();
  3. FeatureSelection featuresSelected = ilist.getFeatureSelection();
  4. InstanceList tmpilist = new InstanceList (tmpDV, ilist.getTargetAlphabet());

相关文章