@Override public State getState(int index) { return baseModel.getState(index); }
@Override public State getState(int index) { return baseModel.getState(index); }
@Override public State getState(int index) { return baseModel.getState(index); }
public double getParameter (int sourceStateIndex, int destStateIndex, int featureIndex, int weightIndex) { State source = (State)getState(sourceStateIndex); State dest = (State) getState(destStateIndex); int rowIndex; for (rowIndex = 0; rowIndex < source.destinationNames.length; rowIndex++) if (source.destinationNames[rowIndex].equals (dest.name)) break; if (rowIndex == source.destinationNames.length) throw new IllegalArgumentException ("No transtition from state "+sourceStateIndex+" to state "+destStateIndex+"."); int weightsIndex = source.weightsIndices[rowIndex][weightIndex]; if (featureIndex < 0) return parameters.defaultWeights[weightsIndex]; return parameters.weights[weightsIndex].value (featureIndex); }
public double getParameter (int sourceStateIndex, int destStateIndex, int featureIndex, int weightIndex) { State source = (State)getState(sourceStateIndex); State dest = (State) getState(destStateIndex); int rowIndex; for (rowIndex = 0; rowIndex < source.destinationNames.length; rowIndex++) if (source.destinationNames[rowIndex].equals (dest.name)) break; if (rowIndex == source.destinationNames.length) throw new IllegalArgumentException ("No transtition from state "+sourceStateIndex+" to state "+destStateIndex+"."); int weightsIndex = source.weightsIndices[rowIndex][weightIndex]; if (featureIndex < 0) return parameters.defaultWeights[weightsIndex]; return parameters.weights[weightsIndex].value (featureIndex); }
public double getParameter (int sourceStateIndex, int destStateIndex, int featureIndex, int weightIndex) { State source = (State)getState(sourceStateIndex); State dest = (State) getState(destStateIndex); int rowIndex; for (rowIndex = 0; rowIndex < source.destinationNames.length; rowIndex++) if (source.destinationNames[rowIndex].equals (dest.name)) break; if (rowIndex == source.destinationNames.length) throw new IllegalArgumentException ("No transtition from state "+sourceStateIndex+" to state "+destStateIndex+"."); int weightsIndex = source.weightsIndices[rowIndex][weightIndex]; if (featureIndex < 0) return parameters.defaultWeights[weightsIndex]; return parameters.weights[weightsIndex].value(featureIndex); }
public void setParameter (int sourceStateIndex, int destStateIndex, int featureIndex, int weightIndex, double value) { weightsValueChanged(); State source = (State)getState(sourceStateIndex); State dest = (State) getState(destStateIndex); int rowIndex; for (rowIndex = 0; rowIndex < source.destinationNames.length; rowIndex++) if (source.destinationNames[rowIndex].equals (dest.name)) break; if (rowIndex == source.destinationNames.length) throw new IllegalArgumentException ("No transtition from state "+sourceStateIndex+" to state "+destStateIndex+"."); int weightsIndex = source.weightsIndices[rowIndex][weightIndex]; if (featureIndex < 0) parameters.defaultWeights[weightsIndex] = value; else { parameters.weights[weightsIndex].setValue (featureIndex, value); } }
public void setParameter (int sourceStateIndex, int destStateIndex, int featureIndex, int weightIndex, double value) { weightsValueChanged(); State source = (State)getState(sourceStateIndex); State dest = (State) getState(destStateIndex); int rowIndex; for (rowIndex = 0; rowIndex < source.destinationNames.length; rowIndex++) if (source.destinationNames[rowIndex].equals (dest.name)) break; if (rowIndex == source.destinationNames.length) throw new IllegalArgumentException ("No transtition from state "+sourceStateIndex+" to state "+destStateIndex+"."); int weightsIndex = source.weightsIndices[rowIndex][weightIndex]; if (featureIndex < 0) parameters.defaultWeights[weightsIndex] = value; else { parameters.weights[weightsIndex].setValue (featureIndex, value); } }
public void setParameter (int sourceStateIndex, int destStateIndex, int featureIndex, int weightIndex, double value) { weightsValueChanged(); State source = (State)getState(sourceStateIndex); State dest = (State) getState(destStateIndex); int rowIndex; for (rowIndex = 0; rowIndex < source.destinationNames.length; rowIndex++) if (source.destinationNames[rowIndex].equals (dest.name)) break; if (rowIndex == source.destinationNames.length) throw new IllegalArgumentException ("No transtition from state "+sourceStateIndex+" to state "+destStateIndex+"."); int weightsIndex = source.weightsIndices[rowIndex][weightIndex]; if (featureIndex < 0) parameters.defaultWeights[weightsIndex] = value; else { parameters.weights[weightsIndex].setValue (featureIndex, value); } }
private static void configure(CRF _crf, InstanceList trainingSet) { // crf.addStatesForLabelsConnectedAsIn(trainingSet); // CRFTrainerByLabelLikelihood trainer = new // CRFTrainerByLabelLikelihood( // crf); // trainer.setGaussianPriorVariance(1d); int[] orders = new int[] { 1 }; Pattern forbiddenPat = Pattern.compile("\\s"); Pattern allowedPat = Pattern.compile(".*"); String outside = Jcas2TokenSequence.TARGET_O; String startName = _crf.addOrderNStates(trainingSet, orders, null, outside, forbiddenPat, allowedPat, true); // String startName = crf.addOrderNStates(trainingSet, orders, null, // null, null, null, true); for (int i = 0; i < _crf.numStates(); i++) _crf.getState(i).setInitialWeight(Transducer.IMPOSSIBLE_WEIGHT); _crf.getState(startName).setInitialWeight(0.0); }
public static CRF getCRF(InstanceList training, int[] orders, String defaultLabel, String forbidden, String allowed, boolean connected) { Pattern forbiddenPat = Pattern.compile(forbidden); Pattern allowedPat = Pattern.compile(allowed); CRF crf = new CRF(training.getPipe(), (Pipe)null); String startName = crf.addOrderNStates(training, orders, null, defaultLabel, forbiddenPat, allowedPat, connected); for (int i = 0; i < crf.numStates(); i++) crf.getState(i).setInitialWeight (Transducer.IMPOSSIBLE_WEIGHT); crf.getState(startName).setInitialWeight(0.0); crf.setWeightsDimensionDensely(); return crf; }
public static CRF getCRF(InstanceList training, int[] orders, String defaultLabel, String forbidden, String allowed, boolean connected) { Pattern forbiddenPat = Pattern.compile(forbidden); Pattern allowedPat = Pattern.compile(allowed); CRF crf = new CRF(training.getPipe(), (Pipe)null); String startName = crf.addOrderNStates(training, orders, null, defaultLabel, forbiddenPat, allowedPat, connected); for (int i = 0; i < crf.numStates(); i++) crf.getState(i).setInitialWeight (Transducer.IMPOSSIBLE_WEIGHT); crf.getState(startName).setInitialWeight(0.0); crf.setWeightsDimensionDensely(); return crf; }
public static CRF getCRF(InstanceList training, int[] orders, String defaultLabel, String forbidden, String allowed, boolean connected) { Pattern forbiddenPat = Pattern.compile(forbidden); Pattern allowedPat = Pattern.compile(allowed); CRF crf = new CRF(training.getPipe(), (Pipe)null); String startName = crf.addOrderNStates(training, orders, null, defaultLabel, forbiddenPat, allowedPat, connected); for (int i = 0; i < crf.numStates(); i++) crf.getState(i).setInitialWeight (Transducer.IMPOSSIBLE_WEIGHT); crf.getState(startName).setInitialWeight(0.0); crf.setWeightsDimensionDensely(); return crf; }
public void addStartState (String name) { for (int i = 0; i < numStates (); i++) parameters.initialWeights[i] = IMPOSSIBLE_WEIGHT; String[] dests = new String [numStates()]; for (int i = 0; i < dests.length; i++) dests[i] = getState(i).getName(); addState (name, 0, 0.0, dests, dests); // initialWeight of 0.0 }
public void setAsStartState (State state) { for (int i = 0; i < numStates(); i++) { Transducer.State other = getState (i); if (other == state) { other.setInitialWeight (0); } else { other.setInitialWeight (IMPOSSIBLE_WEIGHT); } } weightsValueChanged(); }
public void addStartState (String name) { for (int i = 0; i < numStates (); i++) parameters.initialWeights[i] = IMPOSSIBLE_WEIGHT; String[] dests = new String [numStates()]; for (int i = 0; i < dests.length; i++) dests[i] = getState(i).getName(); addState (name, 0, 0.0, dests, dests); // initialWeight of 0.0 }
public void setAsStartState (State state) { for (int i = 0; i < numStates(); i++) { Transducer.State other = getState (i); if (other == state) { other.setInitialWeight (0); } else { other.setInitialWeight (IMPOSSIBLE_WEIGHT); } } weightsValueChanged(); }
public void addStartState (String name) { for (int i = 0; i < numStates (); i++) parameters.initialWeights[i] = IMPOSSIBLE_WEIGHT; String[] dests = new String [numStates()]; for (int i = 0; i < dests.length; i++) dests[i] = getState(i).getName(); addState (name, 0, 0.0, dests, dests); // initialWeight of 0.0 }
public void setAsStartState (State state) { for (int i = 0; i < numStates(); i++) { Transducer.State other = getState (i); if (other == state) { other.setInitialWeight (0); } else { other.setInitialWeight (IMPOSSIBLE_WEIGHT); } } weightsValueChanged(); }
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(); }