@Test public void testBestSequence() { String[] sequence = {"1", "2", "3", "2", "1"}; BeamSearchContextGenerator<String> cg = new IdentityFeatureGenerator(sequence); String[] outcomes = new String[] {"1", "2", "3"}; MaxentModel model = new IdentityModel(outcomes); BeamSearch<String> bs = new BeamSearch<>(2, model); Sequence seq = bs.bestSequence(sequence, null, cg, (int i, String[] inputSequence, String[] outcomesSequence, String outcome) -> true); Assert.assertNotNull(seq); Assert.assertEquals(sequence.length, seq.getOutcomes().size()); Assert.assertEquals("1", seq.getOutcomes().get(0)); Assert.assertEquals("2", seq.getOutcomes().get(1)); Assert.assertEquals("3", seq.getOutcomes().get(2)); Assert.assertEquals("2", seq.getOutcomes().get(3)); Assert.assertEquals("1", seq.getOutcomes().get(4)); }
public Sequence bestSequence(T[] sequence, Object[] additionalContext, BeamSearchContextGenerator<T> cg, SequenceValidator<T> validator) { Sequence[] sequences = bestSequences(1, sequence, additionalContext, cg, validator); if (sequences.length > 0) return sequences[0]; else return null; }
BeamSearch implements SequenceClassificationModel<T> { public Sequence bestSequence(T[] sequence, Object[] additionalContext, BeamSearchContextGenerator<T> cg, SequenceValidator<T> validator) { Sequence[] sequences = bestSequences(1, sequence, additionalContext, cg, validator); if (sequences.length > 0) return sequences[0]; else return null; } }
BeamSearch implements SequenceClassificationModel<T> { public Sequence bestSequence(T[] sequence, Object[] additionalContext, BeamSearchContextGenerator<T> cg, SequenceValidator<T> validator) { Sequence[] sequences = bestSequences(1, sequence, additionalContext, cg, validator); if (sequences.length > 0) return sequences[0]; else return null; } BeamSearch(int size, MaxentModel model);  BeamSearch(int size, MaxentModel model, int cacheSize); }
BeamSearch implements SequenceClassificationModel<T> { public Sequence bestSequence(T[] sequence, Object[] additionalContext, BeamSearchContextGenerator<T> cg, SequenceValidator<T> validator) { Sequence[] sequences = bestSequences(1, sequence, additionalContext, cg, validator); if (sequences.length > 0) return sequences[0]; else return null; } BeamSearch(int size, MaxentModel model);  BeamSearch(int size, MaxentModel model, int cacheSize); Sequence[] bestSequences(int numSequences, T[] sequence,
      Object[] additionalContext, double minSequenceScore,
      BeamSearchContextGenerator<T> cg, SequenceValidator<T> validator); Sequence[] bestSequences(int numSequences, T[] sequence,
      Object[] additionalContext, BeamSearchContextGenerator<T> cg, SequenceValidator<T> validator); Sequence bestSequence(T[] sequence, Object[] additionalContext,
      BeamSearchContextGenerator<T> cg, SequenceValidator<T> validator); @Override String[] getOutcomes(); }
BeamSearch implements SequenceClassificationModel<T> { public Sequence bestSequence(T[] sequence, Object[] additionalContext, BeamSearchContextGenerator<T> cg, SequenceValidator<T> validator) { Sequence[] sequences = bestSequences(1, sequence, additionalContext, cg, validator); if (sequences.length > 0) return sequences[0]; else return null; } BeamSearch(int size, MaxentModel model);  BeamSearch(int size, MaxentModel model, int cacheSize); Sequence[] bestSequences(int numSequences, T[] sequence,
      Object[] additionalContext, double minSequenceScore,
      BeamSearchContextGenerator<T> cg, SequenceValidator<T> validator); Sequence[] bestSequences(int numSequences, T[] sequence,
      Object[] additionalContext, BeamSearchContextGenerator<T> cg, SequenceValidator<T> validator); Sequence bestSequence(T[] sequence, Object[] additionalContext,
      BeamSearchContextGenerator<T> cg, SequenceValidator<T> validator); @Override String[] getOutcomes(); static final String BEAM_SIZE_PARAMETER; }