“Anagram solver” based on statistics rather than a dictionary/table?

前端 未结 4 920
名媛妹妹
名媛妹妹 2020-12-30 01:36

My problem is conceptually similar to solving anagrams, except I can\'t just use a dictionary lookup. I am trying to find plausible words rather than real words.

I h

4条回答
  •  独厮守ぢ
    2020-12-30 01:57

    Consider the set of K letters as vertices in a graph.

    Add directed edges to represent the 2-grams from each letter to all the others, with weights that correspond to their probabilities.

    A "word", then, is a path through the (complete, directed) graph.

    You are looking for the best (least- or most-weighted) "word" (path) that uses all the letters (visits all the vertices).

    This is the asymmetric Traveling Salesman Problem. It's NP-complete. I don't think it's going to get easier if you use N-grams bigger than N=2, so you're not likely to find an efficient algorithm, but let us know if you do

    (Simulated Annealing or something like it is probably the way to go)

提交回复
热议问题