|
|
| Perl: the Markov chain saw | |
| PerlMonks |
Re: Comparing Lines within a Word Listby Anonymous Monk |
| on Apr 27, 2016 at 15:47 UTC ( [id://1161643]=note: print w/replies, xml ) | Need Help?? |
|
So you have a looming deadline and no idea how to solve your problem (every CS problem can be solved "using regular expressions in a Perl script"), so you come here to ask us to do your homework for you... well today is your lucky day :-P My first thought was "spell checker", so I investigated how they work. Apparently one possible implementation is the use of a Trie. I've never worked with a trie before, so I decided to use this chance to try it out. Since it's the first time I'm working with tries, the code might have some bugs. I compared it to a plain, brute-force linear search regex match. In my first tests, the trie data structure takes roughly 5x the memory (as reported by Devel::Size), but on large word lists I saw a 100x to 700x speedup. (Note: My implementation of AnomalousMonk's xor+tr search seems to be roughly twice as fast as the regex implementation.) If you want to understand what's going on in the code, the book Learning Perl is a good start, as is perldsc. Also, ask here. (Protip: Don't get thrown out of your class or school for plagiarism and cite your sources.) <Reveal this spoiler or all in this thread>
In Section
Seekers of Perl Wisdom
|
|
||||||||||||||||||||||||||||||||||||||