/// <summary> /// Creates a distribution over strings of length 1 induced by a given distribution over characters. /// This method is an alias for <see cref="SequenceDistribution{TSequence, TElement, TElementDistribution, TSequenceManipulator, TAutomaton, TWeightFunction, TWeightFunctionFactory, TThis}.SingleElement(TElementDistribution)"/>. /// </summary> /// <param name="characterDist">The distribution over characters.</param> /// <returns>The created distribution.</returns> /// <remarks> /// The distribution created by this method can differ from the result of /// <see cref="SequenceDistribution{TSequence, TElement, TElementDistribution, TSequenceManipulator, TAutomaton, TWeightFunction, TWeightFunctionFactory, TThis}.Repeat(TThis, int, int?)"/> /// with both min and max length set to 1 since the latter always creates a partial uniform distribution. /// </remarks> public static StringDistribution Char(ImmutableDiscreteChar characterDist) { return(StringDistribution.SingleElement(characterDist)); }
/// <summary> /// Creates a distribution over strings of length 1 induced by a given distribution over characters. /// This method is an alias for <see cref="SequenceDistribution{TSequence, TElement, TElementDistribution, TSequenceManipulator, TAutomaton, TWeightFunction, TWeightFunctionFactory, TThis}.SingleElement(TElementDistribution)"/>. /// </summary> /// <param name="characterDist">The distribution over characters.</param> /// <returns>The created distribution.</returns> /// <remarks> /// The distribution created by this method can differ from the result of /// <see cref="SequenceDistribution{TSequence, TElement, TElementDistribution, TSequenceManipulator, TAutomaton, TWeightFunction, TWeightFunctionFactory, TThis}.Repeat(TThis, int, int?)"/> /// with both min and max length set to 1 since the latter always creates a partial uniform distribution. /// </remarks> public static StringDistribution Char(DiscreteChar characterDist) { return(StringDistribution.SingleElement(characterDist.WrappedDistribution)); }
/// <summary> /// Creates a distribution which puts all mass on a string containing only a given character. /// This method is an alias for <see cref="SequenceDistribution{TSequence, TElement, TElementDistribution, TSequenceManipulator, TAutomaton, TWeightFunction, TWeightFunctionFactory, TThis}.SingleElement(TElement)"/>. /// </summary> /// <param name="ch">The character.</param> /// <returns>The created distribution.</returns> public static StringDistribution Char(char ch) { return(StringDistribution.SingleElement(ch)); }
/// <summary> /// Creates a point mass distribution. /// This method is an alias for <see cref="SequenceDistribution{TSequence, TElement, TElementDistribution, TSequenceManipulator, TAutomaton, TWeightFunction, TWeightFunctionFactory, TThis}.PointMass"/>. /// </summary> /// <param name="str">The point.</param> /// <returns>The created point mass distribution.</returns> public static StringDistribution String(string str) { return(StringDistribution.PointMass(str)); }
/// <summary> /// Creates a uniform distribution over strings of whitespace characters (see <see cref="DiscreteChar.Whitespace"/>), /// with length within the given bounds. /// If <paramref name="maxLength"/> is set to <see langword="null"/>, /// there will be no upper bound on the length, and the resulting distribution will thus be improper. /// </summary> /// <param name="minLength">The minimum possible string length. Defaults to 1.</param> /// <param name="maxLength"> /// The maximum possible sequence length, or <see langword="null"/> for no upper bound on length. /// Defaults to <see langword="null"/>. /// </param> /// <returns>The created distribution.</returns> public static StringDistribution Whitespace(int minLength = 1, int?maxLength = null) { return(StringDistribution.Repeat(ImmutableDiscreteChar.Whitespace(), minLength, maxLength)); }
/// <summary> /// Creates a uniform distribution over strings of digits, lowercase and uppercase letters, with length within the given bounds. /// If <paramref name="maxLength"/> is set to <see langword="null"/>, /// there will be no upper bound on the length, and the resulting distribution will thus be improper. /// </summary> /// <param name="minLength">The minimum possible string length. Defaults to 1.</param> /// <param name="maxLength"> /// The maximum possible sequence length, or <see langword="null"/> for no upper bound on length. /// Defaults to <see langword="null"/>. /// </param> /// <returns>The created distribution.</returns> public static StringDistribution LettersOrDigits(int minLength = 1, int?maxLength = null) { return(StringDistribution.Repeat(ImmutableDiscreteChar.LetterOrDigit(), minLength, maxLength)); }
/// <summary> /// Creates a uniform distribution over strings of digits, with length within the given bounds. /// If <paramref name="maxLength"/> is set to <see langword="null"/>, /// there will be no upper bound on the length, and the resulting distribution will thus be improper. /// </summary> /// <param name="minLength">The minimum possible string length. Defaults to 1.</param> /// <param name="maxLength"> /// The maximum possible sequence length, or <see langword="null"/> for no upper bound on length. /// Defaults to <see langword="null"/>. /// </param> /// <param name="uniformity">The type of uniformity. Defaults to <see cref="DistributionKind.UniformOverValue"/></param> /// <returns>The created distribution.</returns> public static StringDistribution Digits(int minLength = 1, int?maxLength = null, DistributionKind uniformity = DistributionKind.UniformOverValue) { return(StringDistribution.Repeat(ImmutableDiscreteChar.Digit(), minLength, maxLength, uniformity)); }