Syllabify the given word, whether simplex or complex.
184216
def syllabify(word, compound=None):
    ''''''
    if compound is None:
        compound = bool(re.search(r'(-| |=)', word))

    syllabify = _syllabify_compound if compound else _syllabify
    syll, rules = syllabify(word)

    yield syll, rules

    n = 7

    if 'T4' in rules:
        yield syllabify(word, T4=False)
        n -= 1

    if 'e' in rules:
        yield syllabify(word, T1E=False)
        n -= 1

    if 'e' in rules and 'T4' in rules:
        yield syllabify(word, T4=False, T1E=False)
        n -= 1

    # yield empty syllabifications and rules
    for i in range(n):
        yield '', ''
1078066
def stress(syllabified_simplex_word):
    ''''''
    syllables = syllabified_simplex_word.split('.')
    stressed = '\'' + syllables[0]  # primary stress

    try:
        n = 0
        medial = syllables[1:-1]

        for i, syll in enumerate(medial):

            if (i + n) % 2 == 0:
                stressed += '.' + syll

            else:
                try:
                    if is_light(syll) and is_heavy(medial[i + 1]):
                        stressed += '.' + syll
                        n += 1
                        continue

                except IndexError:
                    pass

                # secondary stress
                stressed += '.`' + syll

    except IndexError:
        pass

    if len(syllables) > 1:
        stressed += '.' + syllables[-1]

    return stressed
825886
def apply_T7(word):
    ''''''
    T7 = ''
    WORD = word.split('.')

    for i, v in enumerate(WORD):

        if contains_VVV(v):

            for I, V in enumerate(v[::-1]):

                if is_vowel(V):
                    WORD[i] = v[:I] + '.' + v[I:]
                    T7 = ' T7'

    word = '.'.join(WORD)

    return word, T7
1198787
def build_valid_keywords_grammar(keywords=None):
    """"""
    from invenio_query_parser.parser import KeywordQuery, KeywordRule, \
        NotKeywordValue, SimpleQuery, ValueQuery

    if keywords:
        KeywordRule.grammar = attr('value', re.compile(
            r"(\d\d\d\w{{0,3}}|{0})\b".format("|".join(keywords), re.I)))

        NotKeywordValue.grammar = attr('value', re.compile(
            r'\b(?!\d\d\d\w{{0,3}}|{0}:)\S+\b:'.format(
                ":|".join(keywords))))

        SimpleQuery.grammar = attr(
            'op', [NotKeywordValue, KeywordQuery, ValueQuery])
    else:
        KeywordRule.grammar = attr('value', re.compile(r"[\w\d]+(\.[\w\d]+)*"))
        SimpleQuery.grammar = attr('op', [KeywordQuery, ValueQuery])
475498
def convert_consonantal_i(self, word) -> str:
        """"""
        match = list(self.consonantal_i_matcher.finditer(word))
        if match:
            if word[0].isupper():
                return "J" + word[1:]
            return "j" + word[1:]
        return word
193946
def _do_word(self, word, lemma=None, type=None):
        
        # Improve 3rd person singular "'s" lemma to "be", e.g., as in "he's fine".
        if lemma == "'s" and type in ("VB", "VBZ"):
            lemma = "be"
        self.words.append(Word(self, word, lemma, type, index=len(self.words)))
1091877
def _term(g):
    """"""
    all_t = {x for rule in g.rules for x in rule.rhs if isinstance(x, T)}
    t_rules = {t: Rule(NT('__T_%s' % str(t)), [t], weight=0, alias='Term') for t in all_t}
    new_rules = []
    for rule in g.rules:
        if len(rule.rhs) > 1 and any(isinstance(x, T) for x in rule.rhs):
            new_rhs = [t_rules[x].lhs if isinstance(x, T) else x for x in rule.rhs]
            new_rules.append(Rule(rule.lhs, new_rhs, weight=rule.weight, alias=rule.alias))
            new_rules.extend(v for k, v in t_rules.items() if k in rule.rhs)
        else:
            new_rules.append(rule)
    return Grammar(new_rules)
345554
def bysize(words):
    
    ret = {}
    for w in words:
        if len(w) not in ret:
            ret[len(w)] = set()
        ret[len(w)].add(w)
    return ret
1105368
public WordBuilder<I> append(Word<? extends I> word) {
        int wLen = word.length();
        ensureAdditionalCapacity(wLen);
        word.writeToArray(0, array, length, wLen);
        length += wLen;
        return this;
    }
47720
def iterate(self, word):
        
        for p in reversed(self.positions(word)):
            if p.data:
                # get the nonstandard hyphenation data
                change, index, cut = p.data
                if word.isupper():
                    change = change.upper()
                c1, c2 = change.split('=')
                yield word[:p+index] + c1, c2 + word[p+index+cut:]
            else:
                yield word[:p], word[p:]
388862
def apply_T5(word):
    ''''''
    WORD = _split_consonants_and_vowels(word)

    for k, v in WORD.iteritems():

        if len(v) >= 3 and is_vowel(v[0]):
            vv = [v.find(i) for i in i_DIPHTHONGS if v.find(i) > 0]

            if any(vv):
                vv = vv[0]

                if vv == v[0]:
                    WORD[k] = v[:2] + '.' + v[2:]

                else:
                    WORD[k] = v[:vv] + '.' + v[vv:]

    word = _compile_dict_into_word(WORD)

    return word
372209
@SafeVarargs
    @Nonnull
    public static <I> Word<I> fromSymbols(I... symbols) {
        if (symbols.length == 0) {
            return epsilon();
        }
        if (symbols.length == 1) {
            return fromLetter(symbols[0]);
        }
        return new SharedWord<>(symbols.clone());
    }
384802
def _in(self, *lst):
        """"""
        self.terms.append('in (%s)' % ', '.join(['"%s"' % x for x in lst]))
        return self
1124242
def compile(self):
        """"""
        cs = ""
        for term in self.terms:
            if cs:
                cs += " "
            cs += term
        self.compiled_str = urllib.parse.quote(cs)
        return self
306280
def word(ctx, text, number, by_spaces=False):
    
    return word_slice(ctx, text, number, conversions.to_integer(number, ctx) + 1, by_spaces)
199810
def stem(self, text):
        """"""

        stemmed_text = ''

        for word in text.split(' '):
            if word not in self.stops:

                # remove '-que' suffix
                word, in_que_pass_list = self._checkremove_que(word)
                if not in_que_pass_list:

                    # remove the simple endings from the target word
                    word, was_stemmed = self._matchremove_simple_endings(word)

                    # if word didn't match the simple endings, try verb endings
                    if not was_stemmed:
                        word = self._matchremove_verb_endings(word)

            # add the stemmed word to the text
            stemmed_text += word + ' '


        return stemmed_text
632162
def apply_T6(word):
    ''''''
    WORD = _split_consonants_and_vowels(word)

    for k, v in WORD.iteritems():

        if len(v) == 3 and is_vowel(v[0]):
            vv = [v.find(i) for i in LONG_VOWELS if v.find(i) > 0]

            if any(vv):
                vv = vv[0]

                if vv == v[0]:
                    WORD[k] = v[:2] + '.' + v[2:]

                else:
                    WORD[k] = v[:vv] + '.' + v[vv:]

    word = _compile_dict_into_word(WORD)

    return word