Methods
BreakIntoWords
#Break a phrase into word fragments. This method will split the phrase at all spaces, and attempt to break up words which exceed the maximum width into hyphenated chunks.
BreakWordsIntoLines
#Break a phrase into lines whose length doesn't exceed the maximum width. An attempt will be made to hyphenate words which exceed the limit.
ComposeSequence<T>
#public static string ComposeSequence<T>(IList<T> list, Func<T, string> formatter, SequenceTrimming trimming, SequenceSymbols symbols = null, int limit = 2147483647)
Compose a symbol-separated list of values whose entire length does not exceed some character count.
Parameters:
| list (IList<T>) | |
| formatter (Func<T, string>) | |
| trimming (Prose.SequenceTrimming) | |
| symbols (Prose.SequenceSymbols = null) | |
| limit (int = 2147483647) |
ConvertWildcardToRegex
#Convert a wildcard pattern string into an equivalent regex notation.
- = any sequence.
? = any single character.
# = any numeric sequence.
ConvertWildcardToRegexWithGroups
#Convert a wildcard pattern string into an equivalent regex notation with wildcard group capture.
- = any sequence.
? = any single character.
# = any numeric sequence.
DefaultArticle
#Determines the default indefinite article (i.e. a/an) to use with this string. It may result in ungrammatical English as there exist irregular cases.
Parameters:
| text (string) | Text to examine. |
Returns: The most likely indefinite article to use.
Distance
#public static int Distance(string text, string other, StringComparison comparison, StringMetric metric)
Measure the distance between two strings.
Parameters:
| text (string) | String to compare. |
| other (string) | String to compare to. |
| comparison (StringComparison) | Comparison to use. |
| metric (Prose.StringMetric) | Distance metric algorithm. |
Returns: 'Edit' distance between the two strings.
Interpolate
#Interpolate between two strings.
Test to see whether a string is a valid variable name.
LabelSequence
#Create an endless labeling sequence of strings: A, B, C, ..., AA, AB, AC, ..., XUP, XUQ, ...
LabelSequence
#public static IEnumerable<string> LabelSequence(string template = "{0}", string pool = "ABCDEFGHIJKLMNOPQRSTUVWXYZ")
Create an endless labeling sequence of strings: A, B, C, ..., AA, AB, AC, ..., XUP, XUQ, ...
Measure the largest width and height amongst a collection of strings. Width and height are measured independently and may belong to different strings.
Parameters:
| strings (IEnumerable<string>) | Strings to measure. |
| font (Font) | Font to use. |
Returns: Size containing all individual sizes..
Mask various ranges in a string representing C# style code.
Parameters:
| code (string) | Code to mask. |
| lineComments (bool) | If true, line comments will be masked. |
| blockComments (bool) | If true, block comments will be masked. |
| charLiterals (bool) | If true, char literals will be masked. |
| stringLiterals (bool) | If true, string literals (including style prefix symbols) will be masked. |
Returns: Mask.
Mask all comment and text literal ranges in a string representing C# style code.
Parameters:
| code (string) | Code to mask. |
Returns: Mask.
Apply a set of masking patterns to a string.
Parameters:
| text (string) | String to mask. |
| patterns (params Prose.MaskPattern[]) | Patterns. |
Returns: String mask.
MatchPenalty
#public static int MatchPenalty(string[] keys, string pattern, StringComparison comparison = StringComparison.OrdinalIgnoreCase, StringMetric metric = StringMetric.Damerau)
Compute the matching penalty for a string and a set of search keys. This function can be used to find the best match from a collection of strings using fuzzy matching.
Parameters:
| keys (string[]) | Search keys. |
| pattern (string) | String to match against. |
| comparison (StringComparison = StringComparison.OrdinalIgnoreCase) | Comparison type. |
| metric (Prose.StringMetric = StringMetric.Damerau) | String distance metric. |
Returns: Match penalty. An exact match yields zero, any deviation yields a negative value. The lower the return value, the worse the match.
Mode
#public static string Mode(IEnumerable<string> strings, StringComparison comparison, Func<string[], string> resolution)
Finds the most common value in a collection of strings. Null strings are not included in the search, but empty ones are.
Parameters:
| strings (IEnumerable<string>) | String collection to inspect. |
| comparison (StringComparison) | String comparison. |
| resolution (Func<string[], string>) | Resolution method for when various strings are all tied. |
Returns: Most common string in collection or null if collection is empty.
Mode
#Finds the most common value in a collection of strings. Null strings are not included in the search, but empty ones are.
Parameters:
| strings (IEnumerable<string>) | String collection to inspect. |
| comparison (StringComparison) | String comparison. |
Returns: Most common string in collection or null if collection is empty.
Mode
#Finds the most common value in a collection of strings. Null strings are not included in the search, but empty ones are.
Parameters:
| strings (IEnumerable<string>) | String collection to inspect. |
Returns: Most common string in collection or null if collection is empty.
ModifyCasing
#Change the casing of a string based on a boolean pattern.
Parameters:
| text (string) | String to case. |
| casing (IEnumerable<bool>) | Boolean pattern (true=uppercase, false=lowercase). |
Returns: Cased string.
ModifyCasing
#Change the casing of a string based on an integer pattern.
Parameters:
| text (string) | String to case. |
| casing (IEnumerable<int>) | Integer pattern (negative = lowercase, 0 = originalcase, positive = uppercase). |
Returns: Cased string.
Overlap
#public static string Overlap(IEnumerable<string> strings, string variesSymbol, bool ignoreTrailingCharacters = true)
Create a string which has a varies symbol for each char location that differs between a collection of strings.
Parameters:
| strings (IEnumerable<string>) | Strings to test. |
| variesSymbol (string) | Varies symbol to insert. |
| ignoreTrailingCharacters (bool = true) | If true, non-matching trailing characters won't get masked. |
Returns: Overlayed string.
ParseKeyValueLine
#public static int ParseKeyValueLine(string line, out string leadup, out KeyValueFragment[] fragments)
Parse a line of colon separated key value pairs.
Parameters:
| line (string) | |
| leadup (out string) | |
| fragments (out Prose.KeyValueFragment[]) |
PluralPhrasing
#Create a formatted phrase based on a count integer.
ReadFromJson
#Read a value from a json string.
Replace all C# style comments in a piece of code with whitespace.
Parameters:
| code (string) | String to clean. |
Returns: String with no comments.
RemoveFormators
#Remove those parts of a text which are not helpful during searches. These include commas and other punctuation symbols as well as formator words such as 'the', 'or', 'as', 'is' etc.
SortAlphaNumeric
#Sort a bunch of strings using alphanumeric comparisons.
Parameters:
| strings (string[]) | Strings to sort. |
| comparison (StringComparison) | Comparison to use for the non-numeric portions of the strings. |
Returns: An index map for the sorted strings.
SortAlphaNumericMap
#Sort a bunch of strings using alphanumeric comparisons.
Parameters:
| strings (string[]) | Strings to sort. |
| comparison (StringComparison) | Comparison to use for the non-numeric portions of the strings. |
Returns: An index map for the sorted strings.
Syllabify
#Break a text into syllables.
Parameters:
| text (string) | Text to break. |
Returns: Array of syllables.
ToSentenceCase
#Upper case first non-whitespace character after every sentence terminator.
Parameters:
| text (string) | String to case. |
| culture (CultureInfo) | Culture to use for cse changes. |
Returns: Sentence cased string.
ToSentenceCase
#Upper case first non-whitespace character after every sentence terminator.
Parameters:
| text (string) | String to case. |
Returns: Sentence cased string.
Convert a string to subscript notation. This only works for digits (0-9), the plus and minus symbols and parenthesis. Do note that not all fonts support these subscript characters.
Parameters:
| text (string) | Text to modify. |
Returns: Modified text.
Convert a string to superscript notation. This only works for digits (0-9), the plus and minus symbols and parenthesis. Do note that not all fonts support these superscript characters.
Parameters:
| text (string) | Text to modify. |
Returns: Modified text.
Turn a string into a valid variable name. This method applies VB/C# conventions, only alphanumeric chars and the underscore, provided the name doesn't begin with a digit. This method may return an empty string if all the characters are considered invalid, empty strings are not valid names and need to be handled separately.
Parameters:
| text (string) | String to convert. |
Returns: Variable name.
ToWordCase
#Upper case the first character of every word.
Parameters:
| text (string) | String to case. |
| culture (CultureInfo) | Culture to use for case modification. |
Returns: Word cased string.
ToWordCase
#Upper case the first character of every word.
Parameters:
| text (string) | String to case. |
Returns: Word cased string.
TryParseInteger
#Figure out whether a string contains an integer at a specific location.
Parameters:
| text (string) | String to parse. |
| allowSign (bool) | If true, the first symbol is allowed to be a plus or minus sign. |
| startIndex (int) | Index to start from. |
| nextIndex (out int) | Index of first non-numeric character following the integer, or 'startIndex+1' if no number could be found. |
| integer (out BigInteger) | Integer at location. |
Returns: True if an integer starts at the given location.
TryParseIntegerSubscript
#Figure out whether a string contains a subscript integer at a specific location.
Parameters:
| text (string) | String to parse. |
| allowSign (bool) | If true, the first symbol is allowed to be a plus or minus sign. |
| startIndex (int) | Index to start from. |
| nextIndex (out int) | Index of first non-numeric character following the integer, or 'startIndex+1' if no number could be found. |
| integer (out BigInteger) | Integer found at location. |
Returns: True if an integer starts at the given location.
TryParseIntegerSuperscript
#Figure out whether a string contains a subscript integer at a specific location.
Parameters:
| text (string) | String to parse. |
| allowSign (bool) | If true, the first symbol is allowed to be a plus or minus sign. |
| startIndex (int) | Index to start from. |
| nextIndex (out int) | Index of first non-numeric character following the integer, or 'startIndex+1' if no number could be found. |
| integer (out BigInteger) | Integer found at location. |
Returns: True if an integer starts at the given location.
TryParseNumber
#Try and parse a number which occurs in a text.
Parameters:
| text (string) | Text containing possible number. |
| startIndex (int) | Index of first character to consider. |
| endIndex (out int) | Index of first character after the numeric substring, or just the next character if no number was found. |
| number (out double) | Number at the given index. |
Returns: True if a number starts at the given index.
TryParseNumber
#Try and parse a number which occurs in a text.
Parameters:
| text (string) | Text containing possible number. |
| startIndex (int) | Index of first character to consider. |
| endIndex (out int) | Index of first character after the numeric substring, or just the next character if no number was found. |
| number (out object) | Number at the given index. Could be a double, an int or a BigInteger. |
Returns: True if a number starts at the given index.
TryParsePoint
#Try and parse a set of coordinates from a text. Leading whitespace is ignored, and if the coordinates are surrounded by braces that will be taken into account.
Parameters:
| text (string) | Text to parse. |
| startIndex (int) | Index at which to start looking for point coordinates. |
| endIndex (out int) | Index *after* the final character part of the coordinates, if found. At least 'startIndex+1'."/> |
| point (out Point3d) | Point coordinate, if found. |
Returns: True if a point was found at the given string index.
Convert all subscript characters into regular ones.
Parameters:
| text (string) |
Convert all superscript characters into regular ones.
Parameters:
| text (string) |