Exemple #1
0
/*
GetMaxCharSequence return character which have maximum sequence in `text`.

Example, given a text of string "aaa abcdee ffgf" it will return 'a' and 3.
*/
func GetMaxCharSequence(text string) (char rune, count int) {
	chars, counts := CountCharSequence(text)

	if len(chars) == 0 {
		return 0, 0
	}

	_, idx, _ := numerus.IntsFindMax(counts)

	return chars[idx], counts[idx]
}
Exemple #2
0
/*
WordsMaxCountOf return the string that has highest frequency.

Example, given input

	words:  [A A B A B C C]
	tokens: [A B]

it will return A as the majority tokens in words.
If tokens has equal frequency, then the first tokens in order will returned.
*/
func WordsMaxCountOf(words []string, tokens []string, sensitive bool) string {
	if len(words) <= 0 {
		return ""
	}

	tokensCount := WordsCountTokens(words, tokens, sensitive)
	_, maxIdx, ok := numerus.IntsFindMax(tokensCount)

	if !ok {
		return ""
	}

	return tokens[maxIdx]
}