public void Sum() { StringTransducer replace = StringTransducer.Sum( StringTransducer.Replace(ImmutableDiscreteChar.Lower(), ImmutableDiscreteChar.Digit()), StringTransducer.Replace(ImmutableDiscreteChar.Lower(), ImmutableDiscreteChar.LetterOrDigit())); StringInferenceTestUtilities.TestTransducerValue(replace, "hello", "123", 2.0); StringInferenceTestUtilities.TestTransducerValue(replace, "w", "1337", 2.0); StringInferenceTestUtilities.TestTransducerValue(replace, "w", string.Empty, 2.0); StringInferenceTestUtilities.TestTransducerValue(replace, string.Empty, "17", 2.0); StringInferenceTestUtilities.TestTransducerValue(replace, string.Empty, string.Empty, 2.0); StringInferenceTestUtilities.TestTransducerValue(replace, "hello", "worlds", 1.0); StringInferenceTestUtilities.TestTransducerValue(replace, "hello", "WORLDS111", 1.0); StringInferenceTestUtilities.TestTransducerValue(replace, "123", "worlds", 0.0); StringInferenceTestUtilities.TestTransducerValue(replace, "123", "123", 0.0); StringInferenceTestUtilities.TestTransducerValue(replace, "1", string.Empty, 0.0); }
public void ReplaceAutomaton() { StringAutomaton automaton1 = StringAutomaton.Constant(2.0, ImmutableDiscreteChar.Lower()); automaton1 = automaton1.Sum(StringAutomaton.ConstantOnElement(3.0, 'a')); StringAutomaton automaton2 = StringAutomaton.Constant(0.5, ImmutableDiscreteChar.Digit()); automaton2 = automaton2.Sum(StringAutomaton.Constant(2.5, ImmutableDiscreteChar.LetterOrDigit())); StringTransducer replace = StringTransducer.Replace(automaton1, automaton2); StringInferenceTestUtilities.TestTransducerValue(replace, string.Empty, "123", 6.0); StringInferenceTestUtilities.TestTransducerValue(replace, "a", "123", 15.0); StringInferenceTestUtilities.TestTransducerValue(replace, "ax", "AbC", 5.0); StringInferenceTestUtilities.TestTransducerValue(replace, "a", "a", 12.5); StringInferenceTestUtilities.TestTransducerValue(replace, string.Empty, string.Empty, 6.0); StringInferenceTestUtilities.TestTransducerValue(replace, "123", string.Empty, 0.0); StringInferenceTestUtilities.TestTransducerValue(replace, "AbC", "ax", 0.0); StringInferenceTestUtilities.TestTransducerValue(replace, "1", "1", 0.0); }
public void ReplaceElements() { StringTransducer replace = StringTransducer.Replace(ImmutableDiscreteChar.Lower(), ImmutableDiscreteChar.Digit()); StringInferenceTestUtilities.TestTransducerValue(replace, "hello", "123", 1.0); StringInferenceTestUtilities.TestTransducerValue(replace, "w", "1337", 1.0); StringInferenceTestUtilities.TestTransducerValue(replace, "w", string.Empty, 1.0); StringInferenceTestUtilities.TestTransducerValue(replace, string.Empty, "17", 1.0); StringInferenceTestUtilities.TestTransducerValue(replace, string.Empty, string.Empty, 1.0); StringInferenceTestUtilities.TestTransducerValue(replace, "123", "worlds", 0.0); StringInferenceTestUtilities.TestTransducerValue(replace, "123", "123", 0.0); StringInferenceTestUtilities.TestTransducerValue(replace, "1", string.Empty, 0.0); }