src/Sentence.php
private function punctuationMerge($punctuations)
    {
        $definite_terminals = array_diff($this->terminals, $this->abbreviators);

        $merges = [];
        $merge = '';

        $filtered = array_filter($punctuations, function ($p) {
            return $p !== '';
        });

        foreach ($filtered as $punctuation) {
            $merge .= $punctuation;
            if (mb_strlen($punctuation) === 1
                && in_array($punctuation, $this->terminals)) {
                $merges[] = $merge;
                $merge = '';
            } else {
                foreach ($definite_terminals as $terminal) {
                    if (mb_strpos($punctuation, $terminal) !== false) {
                        $merges[] = $merge;
                        $merge = '';
                        break;
                    }
                }
            }
        }
        if (!empty($merge)) {
            $merges[] = $merge;
        }

        return $merges;
    }
private function punctuationMerge($punctuations)
    {
        $definite_terminals = array_diff($this->terminals, $this->abbreviators);

        $merges = [];
        $merge = '';

        $filtered = array_filter($punctuations, function ($p) {
            return $p !== '';
        });

        foreach ($filtered as $punctuation) {
            $merge .= $punctuation;
            if (mb_strlen($punctuation) === 1
                && in_array($punctuation, $this->terminals)) {
                $merges[] = $merge;
                $merge = '';
            } else {
                foreach ($definite_terminals as $terminal) {
                    if (mb_strpos($punctuation, $terminal) !== false) {
                        $merges[] = $merge;
                        $merge = '';
                        break;
                    }
                }
            }
        }
        if (!empty($merge)) {
            $merges[] = $merge;
        }

        return $merges;
    }
private function punctuationMerge ( $ punctuations ) { $ definite_terminals = array_diff ( $ this -> terminals , $ this -> abbreviators ) ; $ merges = [ ] ; $ merge = '' ; $ filtered = array_filter ( $ punctuations , function ( $ p ) { return $ p !== '' ; } ) ; foreach ( $ filtered as $ punctuation ) { $ merge .= $ punctuation ; if ( mb_strlen ( $ punctuation ) === 1 && in_array ( $ punctuation , $ this -> terminals ) ) { $ merges [ ] = $ merge ; $ merge = '' ; } else { foreach ( $ definite_terminals as $ terminal ) { if ( mb_strpos ( $ punctuation , $ terminal ) !== false ) { $ merges [ ] = $ merge ; $ merge = '' ; break ; } } } } if ( ! empty ( $ merge ) ) { $ merges [ ] = $ merge ; } return $ merges ; }
Appends each terminal item after it's preceding
non-terminals.

Multibyte.php safe (atleast for UTF-8)

For example:
[ "There ", "...", " is", ".", " More", "!" ]
... becomes ...
[ "There ... is.", "More!" ]

@param string[] $punctuations
@return string[]
Appends each terminal item after it s preceding non - terminals .