using System.Text; namespace AIStudio.Tools.DocumentSegments; /// /// Tells whether words hold letters, i.e., whether a model has anything to work on. /// /// /// Letters count by Unicode scalar values rather than by chars: a letter beyond the Basic Multilingual Plane, e.g., /// of Adlam or a rare CJK character, takes two chars, neither of which is a letter on its own. /// internal static class TextLetterExtensions { /// The words. extension(string text) { /// /// Whether the words hold any letter. /// public bool HasLetters => text.EnumerateRunes().Any(Rune.IsLetter); /// /// How many letters the words hold. /// public int LetterCount => text.EnumerateRunes().Count(Rune.IsLetter); } }