Documentation ¶
Index ¶
- Constants
- func AutomatedReadabilityIndex(in string) float64
- func AverageSyllablesPerWord(in string) float64
- func AverageWordsPerSentence(in string) float64
- func BrotliCompressText(data string) []byte
- func BrotliDecompressText(in []byte) (string, error)
- func ColemanLiauIndex(in string) float64
- func Concat(strings ...string) string
- func ExtractEmails(in string, max int) []string
- func ExtractHTMLTags(in string, max int) []string
- func ExtractUrls(in string, max int) []string
- func FlateCompressText(in string) ([]byte, error)
- func FlateDecompressText(in []byte) (string, error)
- func FleschKincaidGradeLevel(in string) float64
- func FleschKincaidReadingEase(in string) float64
- func FrequencyOfRune(char rune, in string) int
- func FrequencyOfString(str string, in string) int
- func GZIPCompressText(in string) ([]byte, error)
- func GZIPDecompressText(in []byte) (string, error)
- func GetAllWords(in string) []string
- func IsEmail(in string) bool
- func IsUrl(in string) bool
- func LetterCount(in string) int
- func NonConcurrentConcat(strings ...string) string
- func PercentFrequencyOfRune(char rune, in string) float64
- func PercentFrequencyOfString(str string, in string) float64
- func RemoveExtraWhitespace(in string) string
- func ReplaceCommonHTMLCharacters(in string) string
- func ReplaceEmails(in string, replacer string, max int) string
- func ReplaceHTMLTags(in string, replacer string, max int) string
- func ReplaceProprietaryMicrosoftCharacters(in string) string
- func ReplaceUrls(in string, replacer string, max int) string
- func SanitizeAll(in string) string
- func SentenceCount(in string) int
- func StringLongestCommonSubsequence(a, b string) string
- func SyllableCount(word string) (count int)
- func TotalSyllableCount(in string) int
- func WordCount(in string) int
Constants ¶
const EmailRegex = `\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}\b`
const UrlRegex = `https?://[^\s]+`
Variables ¶
This section is empty.
Functions ¶
func AutomatedReadabilityIndex ¶
AutomatedReadabilityIndex calculates the Automated Readability Index (ARI) for a given text. It estimates the U.S. grade level required to understand the text.
Parameters:
- in: The input text for which to calculate the ARI.
Returns:
- The Automated Readability Index (ARI) as a float64.
func AverageSyllablesPerWord ¶
AverageSyllablesPerWord calculates the average number of syllables per word in the given string (in).
Parameters:
- in: The input string for which to calculate the average syllables per word.
Returns:
- The average number of syllables per word as a float64.
func AverageWordsPerSentence ¶
AverageWordsPerSentence calculates the average number of words per sentence in the given string (in). If the number of sentences in the given string is 0, it returns the number of words as a float64.
Parameters:
- in: The input string for which to calculate the average words per sentence.
Returns:
- The average words per sentence as a float64.
func BrotliCompressText ¶
BrotliCompressText compresses a given text using the Brotli compression algorithm.
Parameters:
- data: The input text to be compressed.
Returns:
- The compressed data as a byte slice.
func BrotliDecompressText ¶
BrotliDecompressText decompresses Brotli compressed data into a string.
Parameters:
- in: The Brotli compressed data as a byte slice.
Returns:
- The decompressed text as a string.
- An error if decompression fails.
func ColemanLiauIndex ¶
ColemanLiauIndex calculates the Coleman-Liau Index for a given text. It estimates the U.S. grade level required to understand the text.
Parameters:
- in: The input text for which to calculate the Coleman-Liau Index.
Returns:
- The Coleman-Liau Index as a float64.
func Concat ¶
Concat concatenates multiple strings together using goroutines and a mutex for synchronization. It is more efficient for large concatenations compared to NonConcurrentConcat.
Parameters:
- strings: A variadic list of strings to concatenate.
Returns:
- The concatenated string.
func ExtractEmails ¶
ExtractEmails uses regular expressions to extract a given amount of emails (max) from a given string (in). Use a max value of -1 or less to return all emails found in the input string.
Parameters:
- in: The input string from which to extract emails.
- max: The maximum number of emails to extract. Use -1 to extract all emails.
Returns:
- A slice of strings containing the extracted emails.
func ExtractHTMLTags ¶
ExtractHTMLTags extracts a given number of HTML tags from the given string (in) using the lexer. It returns a list of HTML tags with a maximum length of (max). Use a max value of -1 or less to return every tag found in the input string.
Parameters:
- in: The input string from which to extract HTML tags.
- max: The maximum number of HTML tags to extract. Use -1 to extract all HTML tags.
Returns:
- A slice of strings containing the extracted HTML tags.
func ExtractUrls ¶
ExtractUrls extracts a given number of URLs from the given string (in) using regular expressions. It returns a list of URLs with a maximum length of (max). Use a max value of -1 or less to return every URL found in the input string.
Parameters:
- in: The input string from which to extract URLs.
- max: The maximum number of URLs to extract. Use -1 to extract all URLs.
Returns:
- A slice of strings containing the extracted URLs.
func FlateCompressText ¶
FlateCompressText compresses a given text using the Flate (DEFLATE) compression algorithm.
Parameters:
- in: The input text to be compressed.
Returns:
- The compressed data as a byte slice.
- An error if compression fails.
func FlateDecompressText ¶
FlateDecompressText decompresses Flate (DEFLATE) compressed data into a string.
Parameters:
- in: The Flate compressed data as a byte slice.
Returns:
- The decompressed text as a string.
- An error if decompression fails.
func FleschKincaidGradeLevel ¶
FleschKincaidGradeLevel calculates the Flesch-Kincaid Grade Level for a given text. It estimates the number of years of education required to understand the text.
Parameters:
- in: The input text for which to calculate the Grade Level.
Returns:
- The Flesch-Kincaid Grade Level as a float64.
func FleschKincaidReadingEase ¶
FleschKincaidReadingEase calculates the Flesch-Kincaid Reading Ease score for a given text. The higher the score, the easier the text is to read.
Parameters:
- in: The input text for which to calculate the Reading Ease score.
Returns:
- The Flesch-Kincaid Reading Ease score as a float64.
func FrequencyOfRune ¶
FrequencyOfRune returns the number of times a given rune (char) appears in another given string (text). Parameters:
- char: The rune to count in the input string.
- in: The input string in which to count the rune.
Returns:
- The frequency of the rune in the input string.
func FrequencyOfString ¶
FrequencyOfString returns the number of times a given string (str) appears in another given string (in). Parameters:
- str: The string to count in the input string.
- in: The input string in which to count the string.
Returns:
- The frequency of the string in the input string.
func GZIPCompressText ¶
GZIPCompressText compresses a given text using the GZIP compression algorithm.
Parameters:
- in: The input text to be compressed.
Returns:
- The compressed data as a byte slice.
- An error if compression fails.
func GZIPDecompressText ¶
GZIPDecompressText decompresses GZIP compressed data into a string.
Parameters:
- in: The GZIP compressed data as a byte slice.
Returns:
- The decompressed text as a string.
- An error if decompression fails.
func GetAllWords ¶
GetAllWords returns a list of all words in the given string.
Parameters:
- in: The input string from which to extract words.
Returns:
- A slice of strings containing all the words in the input string.
func LetterCount ¶
LetterCount counts the number of letters (alphabetic characters) in a given input string.
Parameters:
- in: The input string for which you want to count the letters.
Returns:
- The count of letters in the input string.
func NonConcurrentConcat ¶
NonConcurrentConcat concatenates multiple strings together without concurrency. This function is usually less efficient for small concatenations but works well for large concatenations.
Parameters:
- strings: A variadic list of strings to concatenate.
Returns:
- The concatenated string.
func PercentFrequencyOfRune ¶
PercentFrequencyOfRune calculates the percentage frequency of a specific rune (char) within a string (in). Parameters:
- char: The rune to calculate the percentage frequency of in the input string.
- in: The input string in which to calculate the percentage frequency of the rune.
Returns:
- The percentage frequency of the rune in the input string as a float64.
func PercentFrequencyOfString ¶
PercentFrequencyOfString calculates the percentage frequency of a specific string (str) within another string (in). Parameters:
- str: The string to calculate the percentage frequency of in the input string.
- in: The input string in which to calculate the percentage frequency of the string.
Returns:
- The percentage frequency of the string in the input string as a float64.
func RemoveExtraWhitespace ¶
RemoveExtraWhitespace removes extra whitespace between words in the given string (in) using the lexer.
Parameters:
- in: The input string from which to remove extra whitespace.
Returns:
- The input string with extra whitespace removed.
func ReplaceCommonHTMLCharacters ¶
ReplaceCommonHTMLCharacters replaces commonly used HTML entities with their corresponding characters.
Parameters:
- in: The input string to perform replacements on.
Returns:
- The input string with common HTML characters replaced.
func ReplaceEmails ¶
ReplaceEmails replaces a given amount of emails (max) from a given string (in) with a given string (replacer). This function first calls ExtractEmails(in, max) to extract the emails and then replaces them inside the input string with the provided replacer.
Parameters:
- in: The input string in which to replace emails.
- replacer: The string to replace emails with.
- max: The maximum number of emails to replace. Use -1 to replace all emails.
Returns:
- The input string with the specified emails replaced by the replacer string.
func ReplaceHTMLTags ¶
ReplaceHTMLTags replaces a given number of HTML tags (max) from the given string (in) with a given string (replacer). This function first calls ExtractHTMLTags(in, max) to extract the HTML tags and then replaces them inside the input string with the provided replacer.
Parameters:
- in: The input string in which to replace HTML tags.
- replacer: The string to replace HTML tags with.
- max: The maximum number of HTML tags to replace. Use -1 to replace all HTML tags.
Returns:
- The input string with the specified HTML tags replaced by the replacer string.
func ReplaceProprietaryMicrosoftCharacters ¶
ReplaceProprietaryMicrosoftCharacters replaces commonly used (bad) Microsoft and Google ASCII characters with normal characters.
Parameters:
- in: The input string to perform replacements on.
Returns:
- The input string with proprietary Microsoft characters replaced.
func ReplaceUrls ¶
ReplaceUrls replaces a given number of URLs (max) from the given string (in) with a given string (replacer). This function first calls ExtractUrls(in, max) to extract the URLs and then replaces them inside the input string with the provided replacer.
Parameters:
- in: The input string in which to replace URLs.
- replacer: The string to replace URLs with.
- max: The maximum number of URLs to replace. Use -1 to replace all URLs.
Returns:
- The input string with the specified URLs replaced by the replacer string.
func SanitizeAll ¶
SanitizeAll runs all sanitization functions on a given string (in). It performs multiple text sanitization operations to clean and normalize the input string.
Parameters:
- in: The input string to sanitize.
Returns:
- The sanitized string.
func SentenceCount ¶
SentenceCount returns the number of sentences in the given string (in). Note that this function may count unknown characters and abbreviations as sentences, which may not be accurate.
Parameters:
- in: The input string for which to count sentences.
Returns:
- The number of sentences in the input string.
func StringLongestCommonSubsequence ¶
Returns the longest common subsequence between two given strings (a and b)
func SyllableCount ¶
SyllableCount returns the number of syllables in the given word.
Parameters:
- word: The word for which to count syllables.
Returns:
- The number of syllables in the word.
func TotalSyllableCount ¶
TotalSyllableCount iterates over every word in the given string (in) and returns the total number of syllables in all words combined.
Parameters:
- in: The input string for which to calculate the total syllable count.
Returns:
- The total number of syllables in the input string.
Types ¶
This section is empty.