Example #1
0
 internal OrthographyCounter(Orthography orthography)
 {
     Glyphs = new Dictionary <Glyph, Int32>(orthography.Count);
     foreach (Glyph glyph in orthography)
     {
         if (!Glyphs.ContainsKey(glyph.ToUpper()))
         {
             Glyphs.Add(glyph.ToUpper(), 0);
         }
     }
 }
Example #2
0
        /// <summary>
        /// Is the <paramref name="string"/> a pangram?
        /// </summary>
        /// <param name="string">The <see cref="String"/> to check.</param>
        /// <param name="orthography">The orthography to use.</param>
        /// <returns>
        /// <para>Pangrams are text in which each glyph in the orthography is present.</para>
        /// </returns>
        public static Boolean IsPangram(this String @string, Orthography orthography)
        {
            OrthographyCounter counter = orthography.GetCounter();

            counter.Add(@string);
            foreach (Int32 count in counter.Values)
            {
                if (count == 0)
                {
                    return(false);
                }
            }
            return(true);
        }
Example #3
0
        /// <summary>
        /// Is the <paramref name="string"/> an isogram?
        /// </summary>
        /// <param name="string">The <see cref="String"/> to check.</param>
        /// <param name="orthography">The orthography to use.</param>
        /// <param name="order">The order of the isogram.</param>
        /// <returns><see langword="true"/> if isogram; otherwise, <see langword="false"/>.</returns>
        /// <remarks>
        /// <para>Isograms are text in which each glyph that is present, is present the same number of times.</para>
        /// </remarks>
        public static Boolean IsIsogram(this String @string, Orthography orthography, out Int32 order)
        {
            OrthographyCounter counter = orthography.GetCounter();

            counter.Add(@string);
            order = 0;
            foreach (Int32 count in counter.Values)
            {
                if (order == 0 && count != 0)
                {
                    order = count;
                }
                if (count != order && count != 0)
                {
                    return(false);
                }
            }
            return(true);
        }
Example #4
0
 /// <summary>
 /// Is the <paramref name="string"/> an isogram?
 /// </summary>
 /// <param name="string">The <see cref="String"/> to check.</param>
 /// <param name="orthography">The orthography to use.</param>
 /// <returns><see langword="true"/> if isogram; otherwise, <see langword="false"/>.</returns>
 /// <remarks>
 /// <para>Isograms are text in which each glyph that is present, is present the same number of times.</para>
 /// </remarks>
 public static Boolean IsIsogram(this String @string, Orthography orthography) => @string.IsIsogram(orthography, out _);
Example #5
0
 /// <summary>
 /// Gets an orthographic counter for this <see cref="Orthography"/>.
 /// </summary>
 /// <returns>A <see cref="OrthographyCounter"/> instance.</returns>
 internal static OrthographyCounter GetCounter(this Orthography orthography) => new OrthographyCounter(orthography);