You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello,
I'm getting a stack overflow error using the code below, on text from here.
Stringtext = "";
// set text to contents of https://pastebin.com/JuFsX5VV// text = ...DocumentWordGraphwg = newDocumentWordGraph();
wg.setDataString(text); // stack overflow error
The text was updated successfully, but these errors were encountered:
In DocumentWordGraph we utilize the utils.splitToWords function, to split the text to words.
There we used a RegExp to split based on punctuation and spaces:
Originally it was String [] sRes = sStr.split("(\\s|\\p{Punct})+");
In the specific files, there exist too many whitespace characters. Can be fixed by simply ignoring full groups of whitespace/punctuation as follows: String [] sRes = sStr.split("(\\s+|\\p{Punct}+)+");
As a temporary solution, you can simply replace all multi-whitespace sequences in the text with a single space, before feeding it to the graph:
String text = utils.loadFileToString("inputText.txt");
text = text.replaceAll("\\s+", " ");
DocumentWordGraph wg = new DocumentWordGraph();
wg.setDataString(text); // stack overflow error - no longer here! :)
System.out.println(wg.getGraphLevel(0));
I will try to update the utils class appropriately... sometime soon.
Hello,
I'm getting a stack overflow error using the code below, on text from here.
The text was updated successfully, but these errors were encountered: