Stack overflow error
See original GitHub issuejava.lang.StackOverflowError at java.util.ArrayList.iterator(ArrayList.java:814) at org.ahocorasick.interval.IntervalNode.determineMedian(IntervalNode.java:43) at org.ahocorasick.interval.IntervalNode.<init>(IntervalNode.java:17) at org.ahocorasick.interval.IntervalNode.<init>(IntervalNode.java:36) at org.ahocorasick.interval.IntervalNode.<init>(IntervalNode.java:36) at org.ahocorasick.interval.IntervalNode.<init>(IntervalNode.java:36) at org.ahocorasick.interval.IntervalNode.<init>(IntervalNode.java:36)
(chopping of rest for sake of brevity)
Here is what I am doing.
In test setup I am loading a dictionary into a trie and a set of sentences. Then I am passing each one of the sentences in a loop to the trie and after processing two sentences I get the above error.
for (String sentence : sentences) {
Collection<Token> tokens = trie.tokenize(sentence);
for (Token token : tokens) {
System.out.println("token: " + token);
}
System.out.println("\n");
}
Does the trie need to be reset after processing of a sentence? If so, what is the call?
Thanks.
Issue Analytics
- State:
- Created 10 years ago
- Comments:6 (2 by maintainers)
Top GitHub Comments
I found the problem. It has to do with adding a word of size 0 (“”) as a dictionary. A bug in the dictionary parsing code (, at end of line) caused it to generate words of 0 length which were being added to the trie. Once I removed the additional commas, it worked.
I guess you can test it by doing trie.addKeyword(“”). Maybe throwing an exception or handling that case gracefully by ignoring it would be better.
Your desired implementation has been implemented. I pushed a v0.2.2 to Maven Central. It should be availabe in a couple of hours, 24 hours max.
Once more, thanks for spotting the bug!