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

前端 未结 4 936
名媛妹妹
名媛妹妹 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:39

    You could also do it stochastically with a Markov chain. For starters, make sure that your N-gram table includes a "beginning of word" symbol; then find the available transitions from that state, and filter them so that they only include available letters from your pool, and choose randomly among them using weighted probabilities. Then find the transitions from the next state, filtering down to the still-available letters, and end when there are no more letters in the pool (or, if you reach a state that you can't transition out of, go back to the beginning and try again).

    You may actually find it useful that this is more random than some of the other available options, and if it's too random you have the option of massaging the probabilities, or simply generating some number n (say 100) of random words, sorting them by their "likelihood", and then choosing randomly from among the top m (perhaps 10), which gives you relatively fine control over whether the words you generate from any bag of letters are more consistent or more random.

提交回复
热议问题