Closed jjedele closed 12 years ago
I'm still figuring out why this happens, but I analyzed one thing:
You always get x^n results, where x is how often you already processed the viterbi algorithm and n is the amount of observations given in the second argument. So for your example I get for the first run only (1^5) = 1 result. For the second run I get (2^5)=32 results and so on.
Any thoughts or feelings about this problem?
The backtracking is taking place at the _viterbipath.
When running once it takes the condition viterbi_path(_, 0, []).
but it sets a backtracking point there because the abort condition (any emotion, a path length of zero and an empty path) also apllies to viterbi_path(Emotion, PathLength, Path)
.
In principle the program should crash because the variable HeadLength is always decrease by 1 and when the HeadLength of 0 is given, it should decrease to infinity.
I will look into your idea but I also found a bug myself:
We dynamically add the backtracking pointers to the database in process_emotions
but never retract them after the query has finished. This should cause exactly our problem...
retractall(matrix_path(_,_,_))
after backtracking the path solved the problem.
When called e.g. with "viterbi([anger, disgust, disdain, surprise, fear], [7,7,7,7,7], X)." several results appear. This should not be - trace what's happening...