in reply to Re^7: n-dimensional statistical analysis of DNA sequences (or text, or ...)
in thread n-dimensional statistical analysis of DNA sequences (or text, or ...)
Aldebaran thank you for testing this module so thoroughly and persistently.
I have made some modifications so that it uses johngg's method of getting a sliding window of $ngram_length words at a time from Re: improving speed in ngrams algorithm. My original code was not sliding at all! Thanks for pointing it out.
I have also added another feature --process-paragraphs which will first convert the text to paragraphs using this algorithm: replace all single newlines with a space so that repeated newlines will be the boundary separating paragraphs. And apply the sliding ngram window on paragraphs rather than lines which is the default. When in "lines" mode, the sliding window does not take into account previous, next lines. But it will stop at the end of the line. Then start a new sliding window at next line. I have noticed that your test input (shelley) has newlines separating each line of text. So, using --process-paragraphs you will get different output, hopefully the markov learner will be more accurate.
A very big issue is the word separator. Which you can specify via --separator '\s+' (note the single quote, you need to protect that backslash from the shell). Or make it like --separator '[-'"'"'"\:,;\s\t.]+' which separates on space or those punctuation marks. I find that this is good enough for my needs and anything more complex should go to another module or use another module to convert a corpus to pure text.
Anyway, this works as expected:
bin/analyse_text.pl --input-corpus data/2.short.shelley.txt --ngram-le +ngth 8 ... "elixir|of|life|is|a|chimera|but|these" => 1, "the|elixir|of|life|is|a|chimera|but" => 1, ... # and bin/analyse_text.pl --input-corpus data/2.short.shelley.txt --ngram-le +ngth 8 --process-paragraphs ... "been|done|exclaimed|the|soul|of|Frankenstein|more" => 1, "done|exclaimed|the|soul|of|Frankenstein|more|far" => 1, "exclaimed|the|soul|of|Frankenstein|more|far|more" => 1, "Frankenstein|more|far|more|will|I|achieve|treading" => 1, "has|been|done|exclaimed|the|soul|of|Frankenstein" => 1, "of|Frankenstein|more|far|more|will|I|achieve" => 1, "soul|of|Frankenstein|more|far|more|will|I" => 1, "the|soul|of|Frankenstein|more|far|more|will" => 1, ...
You will also see that I have included a new goodie: bin/analyze_image.pl and bin/predict_image.pl which does not work (yet?) as expected. But it does open a whole new can of exciting possibilities ...
The distribution can be installed from : https://github.com/hadjiprocopis/Algorithm-Markov-Multiorder-Learner (for the moment).
Thanks for your feedback (which has been acknowledged in pod) and let me know if you need or discover something else, bw bliako
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^9: n-dimensional statistical analysis of DNA sequences (or text, or ...)
by Aldebaran (Curate) on Jul 05, 2019 at 23:30 UTC | |
by bliako (Abbot) on Jul 06, 2019 at 00:43 UTC | |
by Aldebaran (Curate) on Jul 07, 2019 at 01:17 UTC |