@Test public void testDecodeStateSequence() { int[] hiddenSequence = {1, 2, 0, 3, 10}; int[] outputSequence = {1, 2, 10, 0}; List<String> hiddenSequenceDec = HmmUtils.decodeStateSequence( getModel(), hiddenSequence, false, "unknown"); List<String> outputSequenceDec = HmmUtils.decodeStateSequence( getModel(), outputSequence, true, "unknown"); String[] hiddenSequenceExp = {"H1", "H2", "H0", "H3", "unknown"}; String[] outputSequenceExp = {"O1", "O2", "unknown", "O0"}; for (int i = 0; i < hiddenSequenceExp.length; ++i) { assertEquals(hiddenSequenceExp[i], hiddenSequenceDec.get(i)); } for (int i = 0; i < outputSequenceExp.length; ++i) { assertEquals(outputSequenceExp[i], outputSequenceDec.get(i)); } }
public static List<String> decodeStateSequence(HmmModel model, int[] sequence, boolean observed, String defaultValue) { List<String> decoded = Lists.newArrayListWithCapacity(sequence.length); for (int position : sequence) { String nextState; if (observed) { nextState = model.getOutputStateName(position); } else { nextState = model.getHiddenStateName(position); } decoded.add(nextState == null ? defaultValue : nextState); } return decoded; }
HmmUtils { public static List<String> decodeStateSequence(HmmModel model, int[] sequence, boolean observed, String defaultValue) { List<String> decoded = Lists.newArrayListWithCapacity(sequence.length); for (int position : sequence) { String nextState; if (observed) { nextState = model.getOutputStateName(position); } else { nextState = model.getHiddenStateName(position); } decoded.add(nextState == null ? defaultValue : nextState); } return decoded; } }
HmmUtils { public static List<String> decodeStateSequence(HmmModel model, int[] sequence, boolean observed, String defaultValue) { List<String> decoded = Lists.newArrayListWithCapacity(sequence.length); for (int position : sequence) { String nextState; if (observed) { nextState = model.getOutputStateName(position); } else { nextState = model.getHiddenStateName(position); } decoded.add(nextState == null ? defaultValue : nextState); } return decoded; } private  HmmUtils(); }
HmmUtils { public static List<String> decodeStateSequence(HmmModel model, int[] sequence, boolean observed, String defaultValue) { List<String> decoded = Lists.newArrayListWithCapacity(sequence.length); for (int position : sequence) { String nextState; if (observed) { nextState = model.getOutputStateName(position); } else { nextState = model.getHiddenStateName(position); } decoded.add(nextState == null ? defaultValue : nextState); } return decoded; } private  HmmUtils(); static Matrix getCumulativeTransitionMatrix(HmmModel model); static Matrix getCumulativeOutputMatrix(HmmModel model); static Vector getCumulativeInitialProbabilities(HmmModel model); static void validate(HmmModel model); static int[] encodeStateSequence(HmmModel model,
                                          Collection<String> sequence, boolean observed, int defaultValue); static List<String> decodeStateSequence(HmmModel model,
                                                 int[] sequence,
                                                 boolean observed,
                                                 String defaultValue); static void normalizeModel(HmmModel model); static HmmModel truncateModel(HmmModel model, double threshold); }
HmmUtils { public static List<String> decodeStateSequence(HmmModel model, int[] sequence, boolean observed, String defaultValue) { List<String> decoded = Lists.newArrayListWithCapacity(sequence.length); for (int position : sequence) { String nextState; if (observed) { nextState = model.getOutputStateName(position); } else { nextState = model.getHiddenStateName(position); } decoded.add(nextState == null ? defaultValue : nextState); } return decoded; } private  HmmUtils(); static Matrix getCumulativeTransitionMatrix(HmmModel model); static Matrix getCumulativeOutputMatrix(HmmModel model); static Vector getCumulativeInitialProbabilities(HmmModel model); static void validate(HmmModel model); static int[] encodeStateSequence(HmmModel model,
                                          Collection<String> sequence, boolean observed, int defaultValue); static List<String> decodeStateSequence(HmmModel model,
                                                 int[] sequence,
                                                 boolean observed,
                                                 String defaultValue); static void normalizeModel(HmmModel model); static HmmModel truncateModel(HmmModel model, double threshold);  }