How can I split multiple joined words?
The Viterbi algorithm is much faster. It computes the same scores as the recursive search in Dmitry’s answer above, but in O(n) time. (Dmitry’s search takes exponential time; Viterbi does it by dynamic programming.) import re from collections import Counter def viterbi_segment(text): probs, lasts = [1.0], [0] for i in range(1, len(text) + 1): prob_k, … Read more