Comments (2)
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.
from jinsect.
Thank you for the swift reply!
from jinsect.
Related Issues (2)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jinsect.