简体   繁体   中英

Cleaning up this PHP Markov Chain output?

This is my first time working with Markov chains.

I want to combine two sources of text and get a readable Markov Chain. The implementation I'm using is here - the sources of text are stripped of markup, etc.

I was first exposed to Markov Chains with the Ruby Rbot IRC bot. Their Markov plugin source is here .

I'm finding my use of the PHP markov algorithm's output is messy. One thing I am able to see is that the rbot implementation chains two words together to start. Is there a clear way to make this happen with the PHP implementation I've linked? If not, is there a PHP implementation that can do this?

Do you want to do word chaining or letter chaining? The PHP implementation you have above does letter chaning, which will tend towards gibberish, not just words seemingly out of place, at low order values. It looks like the rbot does word chaining, which implicitly generates more 'readable' text.

Markov chaining is pretty simple to implement. I don't think it would be too hard to adapt the PHP source to split and chain by word instead of letter. I've been thinking of making a pure sql stored procedure which can take a table and generate a string.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM