// Syllables returns the number of syllables in the string word.
//
// NOTE: This function expects a word (not raw text) as input.
494284
func Syllables(word string) int {
	// See if we can leave early ...
	length := utf8.RuneCountInString(word)
	if length < 1 {
		return 0
	} else if length < 3 {
		return 1
	}

	// See if this is a known cornercase ...
	word = strings.ToLower(word)
	if syllables, ok := cornercases[word]; ok {
		return syllables
	}
	text, count := clean(word)

	// Count multiple vowels
	count += len(vowels.FindAllString(text, -1))

	count -= len(monosyllabicOne.FindAllString(text, -1))
	count -= len(monosyllabicTwo.FindAllString(text, -1))

	count += len(doubleSyllabicOne.FindAllString(text, -1))
	count += len(doubleSyllabicTwo.FindAllString(text, -1))
	count += len(doubleSyllabicThree.FindAllString(text, -1))
	count += len(doubleSyllabicFour.FindAllString(text, -1))

	if count < 1 {
		return 1
	}
	return count
}
267263
func (e *Encoding) pad(s string, minlen int) string {
	if len(s) >= minlen {
		return s
	}

	format := fmt.Sprint(`%0`, strconv.Itoa(minlen), "s")
	return fmt.Sprintf(format, s)
}
1209447
func (g *LineString) Length() float64 {
	return length1(g.flatCoords, 0, len(g.flatCoords), g.stride)
}
47277
func (t *Trainer) Stem(a string) (string, error) {
	if t.s == nil {
		return "", componentUnavailable("Stemmer")
	}
	return t.s.Stem(a)
}
308638
func (r *Response) Text(text string) error {
	return r.Raw([]byte(text))
}
629139
func (e *Event) String() string {
	if e.Type == Error {
		return "{ws.Event Error " + e.Error.Error() + "}"
	}
	return "{ws.Event " + e.Type.String() + "}"
}
619686
func (c *Corpus) Add(word string) int {
	if id, ok := c.ids[word]; ok {
		c.frequencies[id]++
		c.totalFreq++
		return id
	}

	id := atomic.AddInt64(&c.maxid, 1)
	c.ids[word] = int(id - 1)
	c.words = append(c.words, word)
	c.frequencies = append(c.frequencies, 1)
	c.totalFreq++

	runeCount := utf8.RuneCountInString(word)
	if runeCount > c.maxWordLength {
		c.maxWordLength = runeCount
	}

	return int(id - 1)
}
501182
func Words(prefix, suffix string, words ...string) string {
	for i, word := range words {
		words[i] = regexp.QuoteMeta(word)
	}
	return prefix + `(` + strings.Join(words, `|`) + `)` + suffix
}
70202
func rndString(count int, chars []rune) (string, error) {
	s := make([]rune, count)
	for i := range s {
		s[i] = chars[Rnd.Intn(len(chars))]
	}
	return string(s), nil
}
967191
func (a Measurements) String() string {
	var str []string
	for _, m := range a {
		str = append(str, m.String())
	}
	return strings.Join(str, ", ")
}
1195962
func (c *Corpus) str(s string) string {
	if s == "" {
		return ""
	}
	if s, ok := c.strs[s]; ok {
		return s
	}
	if c.strs == nil {
		c.strs = make(map[string]string)
	}
	c.strs[s] = s
	return s
}
982200
func (as AnnotatedSentence) Stems() []string {
	stems := make([]string, len(as))
	for i, a := range as {
		stems[i] = a.Stem
	}
	return stems
}
1324169
func (e Errors) Error() string {
	messages := []string{}
	for _, err := range e {
		messages = append(messages, err.Message())
	}
	return strings.Join(messages, "\n")
}
847903
func (v Vocabulary) Word(w string) (Word, error) {
  if w == "" {
    return Word{}, Error("word must be non-empty string")
  }

  if v.c.BigHugeLabsApiKey == "" {
    return Word{}, Error("BigHugeLabsApiKey required.")
  }
  if v.c.WordnikApiKey == "" {
    return Word{}, Error("WordnikApiKey required.")
  }

  meanings, err := v.Meanings(w)
  if err != nil {
    return Word{}, err
  }

  synonyms, err := v.Synonyms(w)
  if err != nil {
    return Word{}, err
  }

  antonyms, err := v.Antonyms(w)
  if err != nil {
    return Word{}, err
  }

  pos, err := v.PartOfSpeech(w)
  if err != nil {
    return Word{}, err
  }

  ue, err := v.UsageExample(w)
  if err != nil {
    return Word{}, err
  }

  return Word{
    Word:         w,
    Meanings:     meanings,
    Synonyms:     synonyms,
    Antonyms:     antonyms,
    PartOfSpeech: pos,
    UsageExample: ue,
  }, nil
}
1337322
func (l Lorem) Word(v reflect.Value) (interface{}, error) {
	return l.word(), nil
}
412069
func (stm englishStemmer) Stem(word string) string {
	word = strings.ToLower(word)
	// Is it exception?
	if rep, ex := exceptions1[word]; ex {
		return rep
	}
	s := []rune(word)
	if len(s) <= 2 {
		return word
	}
	if s[0] == '\'' {
		s = s[1:]
	}
	if s[0] == 'y' {
		s[0] = 'Y'
	}
	for i := 1; i < len(s); i++ {
		if isVowel(s[i-1]) && s[i] == 'y' {
			s[i] = 'Y'
		}
	}
	r1, r2 := getR1R2(s)

	// Step 0
	s = removeSuffix(s, []rune("'s'"))
	s = removeSuffix(s, []rune("'s"))
	s = removeSuffix(s, []rune("'"))

	// Step 1a
	if i := suffixPos(s, []rune("sses")); i != -1 {
		// sses
		// replace by ss
		s = append(s[:i], []rune("ss")...)
		goto step1b
	}
	{
		i := suffixPos(s, []rune("ied"))
		if i == -1 {
			i = suffixPos(s, []rune("ies"))
		}
		if i != -1 {
			// ied+   ies*
			// replace by i if preceded by more than one letter,
			// otherwise by ie (so ties -> tie, cries -> cri)
			s = s[:i]
			if len(s) > 1 {
				s = append(s, rune('i'))
			} else {
				s = append(s, []rune("ie")...)
			}
			goto step1b
		}
	}
	if suffixPos(s, []rune("us")) != -1 || suffixPos(s, []rune("ss")) != -1 {
		// do nothing
		goto step1b
	}

	if i := suffixPos(s, []rune("s")); i != -1 {
		if len(s) >= 3 && hasVowelBeforePos(s, len(s)-3) {
			s = s[:i]
		}
		goto step1b
	}

step1b:
	if _, ex := exceptions2[string(s)]; ex {
		return string(s)
	}
	// Step 1b
	for _, suf := range [][]rune{[]rune("eed"), []rune("eedly")} {
		if i := suffixPos(s, suf); i != -1 {
			if i >= r1 {
				s = append(s[:i], []rune("ee")...)
			}
			goto step1c
		}
	}

	for _, suf := range step1bWords {
		if suffixPos(s, suf) != -1 {
			if len(s) > len(suf) && hasVowelBeforePos(s, len(s)-len(suf)-1) {
				s = s[:len(s)-len(suf)]
			} else {
				goto step1c
			}
			if suffixPos(s, []rune("at")) != -1 || suffixPos(s, []rune("bl")) != -1 ||
				suffixPos(s, []rune("iz")) != -1 {
				s = append(s, rune('e'))
				goto step1c
			}
			if endsWithDouble(s) {
				s = s[:len(s)-1]
				goto step1c
			}
			if isShortWord(s) {
				s = append(s, rune('e'))
			}
			goto step1c
		}
	}
step1c:
	// replace suffix y or Y by i if preceded by a non-vowel which is
	// not the first letter of the word (so cry -> cri, by -> by, say -> say)
	if len(s) > 2 {
		switch s[len(s)-1] {
		case 'y', 'Y':
			if !isVowel(s[len(s)-2]) {
				s[len(s)-1] = 'i'
			}
		}
	}
	//step2:
	r1, r2 = getR1R2(s)
	// Search for the longest among the following suffixes, and,
	// if found and in R1, perform the action indicated
	for j, suf := range step2Words {
		if i := suffixPos(s, suf); i != -1 {
			if i >= r1 {
				s = append(s[:i], step2Reps[j]...)
			}
			goto step3
		}
	}
	if i := suffixPos(s, []rune("ogi")); i != -1 && i >= r1 {
		if s[i-1] == 'l' {
			s = append(s[:i], []rune("og")...)
		}
		goto step3
	}
	if i := suffixPos(s, []rune("li")); i != -1 && i >= r1 {
		// valid li-ending: c   d   e   g   h   k   m   n   r   t
		switch s[i-1] {
		case 'c', 'd', 'e', 'g', 'h', 'k', 'm', 'n', 'r', 't':
			s = s[:i]
		}
	}
step3:
	r1, r2 = getR1R2(s)
	for j, suf := range step3Words {
		if i := suffixPos(s, suf); i != -1 {
			if i >= r1 {
				s = append(s[:i], step3Reps[j]...)
			}
			goto step4
		}
	}
	if i := suffixPos(s, []rune("ative")); i != -1 && i >= r2 {
		s = s[:i]
		goto step4
	}

step4:
	r1, r2 = getR1R2(s)
	for _, suf := range step4Words {
		if i := suffixPos(s, suf); i != -1 {
			if i >= r2 {
				s = s[:i]
			}
			goto step5
		}
	}
	if i := suffixPos(s, []rune("ion")); i != -1 && i >= r2 {
		switch s[i-1] {
		case 's', 't':
			s = s[:i]
		}
	}

step5:
	r1, r2 = getR1R2(s)
	i := len(s) - 1
	if i > 0 && s[i] == 'e' {
		if i >= r2 {
			s = s[:i]
			goto final
		}
		if i >= r1 {
			// if not preceded by a short syllable
			if i < 3 {
				goto final
			}
			// N + v + N
			last := s[i-1]
			if !isVowel(s[i-3]) && isVowel(s[i-2]) && !isVowel(last) &&
				last != 'w' && last != 'x' && last != 'Y' {
				goto final
			}
			s = s[:i]
		}
		goto final
	}
	if i > 1 && i >= r2 && s[i] == 'l' && s[i-1] == 'l' {
		s = s[:i]
	}

final:
	for i, v := range s {
		if v == 'Y' {
			s[i] = 'y'
		}
	}
	return string(s)
}
1263365
func Si(n uint64) string {
	suff := siRaw
	x := float64(n)
	for ; x >= 1024; x = x / 1024 {
		suff++
	}

	return fmt.Sprintf("%.2f%s", x, suff.String())
}