public void testBestSequenceZeroLengthInput() { var sequence = new string[0]; IBeamSearchContextGenerator <string> cg = new IdentityFeatureGenerator(sequence); var outcomes = new[] { "1", "2", "3" }; var model = new IdentityModel(outcomes); var bs = new BeamSearch <string>(3, cg, model); var seq = bs.BestSequence(sequence, null); Assert.NotNull(seq); Assert.AreEqual(sequence.Length, seq.Outcomes.Count); }
public void TestBestSequenceOneElementInput() { var sequence = new[] { "1" }; var cg = new IdentityFeatureGenerator(sequence); var outcomes = new[] { "1", "2", "3" }; var model = new IdentityModel(outcomes); var bs = new BeamSearch <string>(3, cg, model); var seq = bs.BestSequence(sequence, null); Assert.NotNull(seq); Assert.AreEqual(sequence.Length, seq.Outcomes.Count); Assert.AreEqual("1", seq.Outcomes[0]); }
public void testBestSequenceWithValidator() { var sequence = new[] { "1", "2", "3", "2", "1" }; var cg = new IdentityFeatureGenerator(sequence); var outcomes = new[] { "1", "2", "3" }; var model = new IdentityModel(outcomes); var bs = new BeamSearch <string>(2, cg, model, new SequenceValidator(), 0); var seq = bs.BestSequence(sequence, null); Assert.NotNull(seq); Assert.AreEqual(sequence.Length, seq.Outcomes.Count); Assert.AreEqual("1", seq.Outcomes[0]); Assert.AreNotSame("2", seq.Outcomes[1]); Assert.AreEqual("3", seq.Outcomes[2]); Assert.AreNotSame("2", seq.Outcomes[3]); Assert.AreEqual("1", seq.Outcomes[4]); }