Return the longest possible first part and the last part of the
        hyphenated word. The first part has the hyphen already attached.
        Returns None, if there is no hyphenation point before width, or
        if the word could not be hyphenated.
6140
def wrap(self, word, width, hyphen='-'):
        
        width -= len(hyphen)
        for w1, w2 in self.iterate(word):
            if len(w1) <= width:
                return w1 + hyphen, w2
547069
def getPartialLength(self):
        
        indexes = self.GetChildrenIndexes()
        length = 0
        divider = 0
        total = 0
        result = ""
        for v in indexes:
            voice = self.GetChild(v)
            if voice.note_total > length:
                length = voice.note_total
                note_types = voice.GetAllNoteTypes()
                if len(note_types) == 1:
                    total = length
                    result = str(total)
                else:
                    note_types.sort()
                    total = note_types[0]
                    result = str(total)
                    previous = total
                    count = 0
                    for value in note_types[1:]:
                        if previous * 2 == value:
                            result += "."
                        if previous == value:
                            if total >= previous:
                                total -= previous
                            else:
                                total -= previous / 2
                            total += previous / 2
                            value = previous / 2
                        previous = value

                    first_digit = str(int(total))
                    result = first_digit + result[1:]

        return result
440373
private int firstVowel(String word, int last) {
        int i = 0;
        if ((i < last) && (!(vowel(word.charAt(i), 'a')))) {
            i++;
        }
        if (i != 0) {
            while ((i < last) && (!(vowel(word.charAt(i), word.charAt(i - 1))))) {
                i++;
            }
        }
        if (i < last) {
            return i;
        }
        return last;
    }
73414
def first(self):
        
        self.reset()
        value = next(self, None)
        if value is None:
            raise ConstraintViolation("{} did not find any results.".format(self.mode.capitalize()))
        return value
472512
private boolean previousSegment() {
        assert(state == State.ITER_CHECK_BWD);
        // The input text [(iter index)..limit[ passes the FCD check.
        pos = iter.getIndex();
        // Collect the characters being checked, in case they need to be normalized.
        if(s == null) {
            s = new StringBuilder();
        } else {
            s.setLength(0);
        }
        int nextCC = 0;
        for(;;) {
            // Fetch the previous character and its fcd16 value.
            int c = iter.previousCodePoint();
            if(c < 0) { break; }
            int fcd16 = nfcImpl.getFCD16(c);
            int trailCC = fcd16 & 0xff;
            if(trailCC == 0 && s.length() != 0) {
                // FCD boundary after this character.
                iter.nextCodePoint();
                break;
            }
            s.appendCodePoint(c);
            if(trailCC != 0 && ((nextCC != 0 && trailCC > nextCC) ||
                                CollationFCD.isFCD16OfTibetanCompositeVowel(fcd16))) {
                // Fails FCD check. Find the previous FCD boundary and normalize.
                while(fcd16 > 0xff) {
                    c = iter.previousCodePoint();
                    if(c < 0) { break; }
                    fcd16 = nfcImpl.getFCD16(c);
                    if(fcd16 == 0) {
                        iter.nextCodePoint();
                        break;
                    }
                    s.appendCodePoint(c);
                }
                s.reverse();
                normalize(s);
                limit = pos;
                start = pos - s.length();
                state = State.IN_NORM_ITER_AT_START;
                pos = normalized.length();
                return true;
            }
            nextCC = fcd16 >> 8;
            if(nextCC == 0) {
                // FCD boundary before the following character.
                break;
            }
        }
        start = pos - s.length();
        assert(pos != start);
        iter.moveIndex(s.length());
        state = State.ITER_IN_FCD_SEGMENT;
        return true;
    }
1048146
def word_ends(self):
        """"""
        if not self.is_tagged(WORDS):
            self.tokenize_words()
        return self.ends(WORDS)
1288306
@Nonnull
    public Word<I> longestCommonPrefix(Word<?> other) {
        int len = length(), otherLen = other.length();
        int maxIdx = (len < otherLen) ? len : otherLen;

        int i = 0;
        while (i < maxIdx) {
            I sym1 = getSymbol(i);
            Object sym2 = other.getSymbol(i);

            if (!Objects.equals(sym1, sym2)) {
                break;
            }
            i++;
        }

        return prefix(i);
    }
962557
def first_line_indent(self):
        
        ind = self.ind
        if ind is None:
            return None
        hanging = ind.hanging
        if hanging is not None:
            return Length(-hanging)
        firstLine = ind.firstLine
        if firstLine is None:
            return None
        return firstLine
150765
public function longestWord()
    {
        $words = str_word_count($this->returnValue, 1);

        $longestWordLength = 0;
        $longestWord       = "";

        foreach ($words as $word) {
            if (strlen($word) > $longestWordLength) {
                $longestWordLength = strlen($word);
                $longestWord       = $word;
            }
        }

        return self::create($longestWord);
    }
209902
def get_closest(word, possibilities, cutoff=0.6, fallback_to_first=True):
    """"""
    possibilities = list(possibilities)
    try:
        return difflib_get_close_matches(word, possibilities, 1, cutoff)[0]
    except IndexError:
        if fallback_to_first:
            return possibilities[0]
398285
function getLeftmost(start) {
        var p = start, leftmost = start;
        do {
            if (p.x < leftmost.x)
                leftmost = p;
            p = p.next;
        } while (p !== start);
        return leftmost;
    }
133356
def find_previous_word_beginning(self, count=1, WORD=False):
        
        if count < 0:
            return self.find_next_word_beginning(count=-count, WORD=WORD)

        regex = _FIND_BIG_WORD_RE if WORD else _FIND_WORD_RE
        iterator = regex.finditer(self.text_before_cursor[::-1])

        try:
            for i, match in enumerate(iterator):
                if i + 1 == count:
                    return - match.end(1)
        except StopIteration:
            pass
1318225
def get_fixed_long_line(target, previous_line, original,
                        indent_word='    ', max_line_length=79,
                        aggressive=False, experimental=False, verbose=False):
    
    indent = _get_indentation(target)
    source = target[len(indent):]
    assert source.lstrip() == source
    assert not target.lstrip().startswith('#')

    # Check for partial multiline.
    tokens = list(generate_tokens(source))

    candidates = shorten_line(
        tokens, source, indent,
        indent_word,
        max_line_length,
        aggressive=aggressive,
        experimental=experimental,
        previous_line=previous_line)

    # Also sort alphabetically as a tie breaker (for determinism).
    candidates = sorted(
        sorted(set(candidates).union([target, original])),
        key=lambda x: line_shortening_rank(
            x,
            indent_word,
            max_line_length,
            experimental=experimental))

    if verbose >= 4:
        print(('-' * 79 + '\n').join([''] + candidates + ['']),
              file=wrap_output(sys.stderr, 'utf-8'))

    if candidates:
        best_candidate = candidates[0]

        # Don't allow things to get longer.
        if longest_line_length(best_candidate) > longest_line_length(original):
            return None

        return best_candidate
697985
def find_next_word_ending(self, include_current_position=False, count=1, WORD=False):
        
        if count < 0:
            return self.find_previous_word_ending(count=-count, WORD=WORD)

        if include_current_position:
            text = self.text_after_cursor
        else:
            text = self.text_after_cursor[1:]

        regex = _FIND_BIG_WORD_RE if WORD else _FIND_WORD_RE
        iterable = regex.finditer(text)

        try:
            for i, match in enumerate(iterable):
                if i + 1 == count:
                    value = match.end(1)

                    if include_current_position:
                        return value
                    else:
                        return value + 1

        except StopIteration:
            pass
546824
def strseq(prefix: str, first: int, last: int, suffix: str = "") -> List[str]:
    
    return [strnum(prefix, n, suffix) for n in range(first, last + 1)]
871603
def endswith_partial(text, partial_str):
    ''''''
    # at the end of the content
    # we don't care about complete overlap, so start checking
    # for matches without the last character
    test_str = partial_str[:-1]
    # look for progressively smaller segments
    while test_str:
        if text.endswith(test_str):
            return len(test_str)
        test_str = test_str[:-1]
    return False
1137122
def get_longest_non_repeat_v2(string):
    
    if string is None:
        return 0, ''
    sub_string = ''
    start, max_len = 0, 0
    used_char = {}
    for index, char in enumerate(string):
        if char in used_char and start <= used_char[char]:
            start = used_char[char] + 1
        else:
            if index - start + 1 > max_len:
                max_len = index - start + 1
                sub_string = string[start: index + 1]
        used_char[char] = index
    return max_len, sub_string