Closed samemon closed 9 years ago
Also I wrote a main for the program as follows :
public class Main {
public static void main(String[] args) throws IOException {
// TODO Auto-generated method stub
final FrequencyAnalizer frequencyAnalizer = new FrequencyAnalizer();
final List<WordFrequency> wordFrequencies = frequencyAnalizer.load(getInputStream("text/english_tide.txt"));
final WordCloud wordCloud = new WordCloud(600, 600, CollisionMode.PIXEL_PERFECT);
wordCloud.setPadding(2);
wordCloud.setBackground(new CircleBackground(300));
wordCloud.setColorPalette(new ColorPalette(new Color(0x4055F1), new Color(0x408DF1), new Color(0x40AAF1), new Color(0x40C5F1), new Color(0x40D3F1), new Color(0xFFFFFF)));
wordCloud.setFontScalar(new SqrtFontScalar(10, 40));
wordCloud.build(wordFrequencies);
wordCloud.writeToFile("output/datarank_wordcloud_circle_sqrt_font.png");
}
private static ArrayList<String> getInputStream(String string) {
// TODO Auto-generated method stub
ArrayList<String> temp = new ArrayList<String>();
temp.add("Hello");
temp.add("Shahan");
temp.add("Rohith");
temp.add("Hello");
temp.add("Shahan");
temp.add("Rohith");
temp.add("Hello");
temp.add("Shahan");
temp.add("Rohith");
temp.add("Hello");
temp.add("Shahan");
temp.add("Rohith");
temp.add("Hello");
temp.add("Shahan");
temp.add("Rohith");
return temp;
}
But it gave me following error :
Exception in thread "main" java.lang.NoClassDefFoundError: org/hamcrest/BaseMatcher
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at wordcloud.nlp.FrequencyAnalizer.
Sorry about all the problems.
First, the getInputStream method, I defined it as be following in ITestWordCloud:
private static InputStream getInputStream(String path) {
return Thread.currentThread().getContextClassLoader().getResourceAsStream(path);
}
I was using it to load resources from within the jar for the sake of the demo. You could also pass in a FileInputStream to read/analyze text files that are external to the project jar.
The above exception java.lang.ClassNotFoundException: org.hamcrest.BaseMatcher
is cause by the project seeming to be missing LambdaJ. I'm not sure why that is as i'm not sure about your project. The pom entry for LambdaJ included in the project is:
<dependency>
<groupId>com.googlecode.lambdaj</groupId>
<artifactId>lambdaj</artifactId>
<version>2.3.3</version>
</dependency>
Feel free to try to manually add that to your project, but I'd question as to why it wasn't pulled into your project from the beginning.
Regardless, I will do some re-writing of Kumo to remove external dependencies. :) Let me know if you can't get this resolved and I can help out some more!
Feel free to re-open if you have the issue still!
Hi. I am new to Java and Eclipse. I tried to run your project and it's all fine - does not have any bugs/missing libraries, but it does not have the getInputStream method. What does this function return if I have a text file of say tweets separated by new line ?