public void CopyAutomaton() { StringAutomaton automaton = StringAutomaton.ConstantOn(1.0, "prefix1", "prefix2"); automaton.AppendInPlace(StringAutomaton.Constant(1.0, DiscreteChar.Lower())); automaton.AppendInPlace(StringAutomaton.Constant(1.0, DiscreteChar.Upper())); automaton.AppendInPlace("!"); StringTransducer copy = StringTransducer.Copy(automaton); StringInferenceTestUtilities.TestTransducerValue(copy, "prefix1!", "prefix1!", 1.0); StringInferenceTestUtilities.TestTransducerValue(copy, "prefix2!", "prefix2!", 1.0); StringInferenceTestUtilities.TestTransducerValue(copy, "prefix1lower!", "prefix1lower!", 1.0); StringInferenceTestUtilities.TestTransducerValue(copy, "prefix2UPPER!", "prefix2UPPER!", 1.0); StringInferenceTestUtilities.TestTransducerValue(copy, "prefix1lowerUPPER!", "prefix1lowerUPPER!", 1.0); StringInferenceTestUtilities.TestIfTransducerRejects(copy, "prefix1lower", "prefix2UPPER", "!", "prefix1lowerUPPER"); StringInferenceTestUtilities.TestTransducerProjection(copy, automaton, "prefix1!", 1.0); StringInferenceTestUtilities.TestTransducerProjection(copy, automaton, "prefix2!", 1.0); StringInferenceTestUtilities.TestTransducerProjection(copy, automaton, "prefix1lower!", 1.0); StringInferenceTestUtilities.TestTransducerProjection(copy, automaton, "prefix2UPPER!", 1.0); StringInferenceTestUtilities.TestTransducerProjection(copy, automaton, "prefix1lowerUPPER!", 1.0); StringAutomaton subsetAutomaton = StringAutomaton.ConstantOn(2.0, "prefix1"); subsetAutomaton.AppendInPlace(StringAutomaton.ConstantOn(3.0, "lll", "mmm")); subsetAutomaton.AppendInPlace(StringAutomaton.ConstantOn(1.5, "!", "U!")); StringInferenceTestUtilities.TestTransducerProjection(copy, subsetAutomaton, "prefix1lll!", 9.0); StringInferenceTestUtilities.TestTransducerProjection(copy, subsetAutomaton, "prefix1mmmU!", 9.0); StringInferenceTestUtilities.TestTransducerProjection(copy, subsetAutomaton, "prefix1!", 0.0); StringInferenceTestUtilities.TestTransducerProjection(copy, subsetAutomaton, "prefix2lower!", 0.0); StringInferenceTestUtilities.TestTransducerProjection(copy, subsetAutomaton, "prefix2U!", 0.0); StringAutomaton supersetAutomaton = StringAutomaton.ConstantOn(1.5, "pr"); supersetAutomaton.AppendInPlace(StringAutomaton.Constant(2.0)); StringInferenceTestUtilities.TestTransducerProjection(copy, supersetAutomaton, "prefix1!", 3.0); StringInferenceTestUtilities.TestTransducerProjection(copy, supersetAutomaton, "prefix2!", 3.0); StringInferenceTestUtilities.TestTransducerProjection(copy, supersetAutomaton, "prefix1lower!", 3.0); StringInferenceTestUtilities.TestTransducerProjection(copy, supersetAutomaton, "prefix2UPPER!", 3.0); StringInferenceTestUtilities.TestTransducerProjection(copy, supersetAutomaton, "prefix1lowerUPPER!", 3.0); StringInferenceTestUtilities.TestTransducerProjection(copy, supersetAutomaton, "prefix11!", 0.0); StringInferenceTestUtilities.TestTransducerProjection(copy, supersetAutomaton, "prefix1lowerUPPERlower!", 0.0); StringInferenceTestUtilities.TestTransducerProjection(copy, supersetAutomaton, "prrrrr!", 0.0); }
public void CopySequence1() { StringTransducer copySequence = StringTransducer.Copy("important"); StringInferenceTestUtilities.TestTransducerValue(copySequence, "important", "important", 1.0); StringInferenceTestUtilities.TestTransducerValue(copySequence, "important", "imp", 0.0); StringInferenceTestUtilities.TestTransducerValue(copySequence, "important", "ortant", 0.0); StringInferenceTestUtilities.TestTransducerValue(copySequence, "important", string.Empty, 0.0); StringInferenceTestUtilities.TestTransducerProjection(copySequence, StringAutomaton.ConstantOn(3.0, "important"), "important", 3.0); StringInferenceTestUtilities.TestTransducerProjection(copySequence, StringAutomaton.ConstantOn(1.5, "important", "not important"), "important", 1.5); StringInferenceTestUtilities.TestTransducerProjection(copySequence, StringAutomaton.Constant(2.0), "important", 2.0); StringInferenceTestUtilities.TestTransducerProjection( copySequence, StringAutomaton.Constant(2.0).Append(StringAutomaton.ConstantOn(3.0, "nt")), "important", 6.0); StringInferenceTestUtilities.TestIfTransducerRejects(copySequence, string.Empty, "nothing is important", "importance", "imp", "ortant", "a"); }