-
Notifications
You must be signed in to change notification settings - Fork 0
/
cloud.java
129 lines (116 loc) · 3.32 KB
/
cloud.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
import java.util.*;
import java.io.*;
import Stemming.*;
import Sorting.*;
import StopWordRemoval.*;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import java.awt.*;
import javax.swing.SwingUtilities;
class cloud
{
public static void main(String args[])throws IOException
{
int i,j;
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter the path of directory: ");
String path=br.readLine();
RemoveStopWord.copy_stop_words_mem(path+"/../StopWords.Stemmed");
File f1=new File(path);
String s[]=f1.list();
System.out.println("Processing first 100 file of dataset. . .\n");
System.out.println("Please Wait for few minutes. . .\n");
int r;
for(i=0;i<100;i++)
{
System.out.println((i+1)+". File Processed: "+s[i]);
Porter ob=new Porter();
FileInputStream f2=new FileInputStream(path+"/"+s[i]);
String hash="";
while((r=f2.read())!=-1)
{
char c=(char) r;
if((c>='A'&&c<='Z')||(c>='a'&&c<='z')||c==' '||c=='\t'||c=='\n')
{
if(c==' '||c=='\t'||c=='\n')
{
if(hash.length()!=0)
RemoveStopWord.remove_stop_words(ob.stripAffixes(hash));
hash="";
}
else
{
hash=hash+Character.toLowerCase(c);
}
}
}
if(hash.length()!=0)
RemoveStopWord.remove_stop_words(ob.stripAffixes(hash));
RemoveStopWord.RemoveStopWord_main(path+"/../Dictionary");
}
Sort obj=new Sort();
obj.Sort_main(path);
TestOpenCloud.Cloud_main(path);
}
}
class TestOpenCloud {
static String path;
protected void initUI() {
File f=new File(path+"/../Top100");
String Str;
String WORDS[]=new String[100];
int FREQ[]=new int[100];
String shuffle[]=new String[100];
ArrayList<String> shuffling = new ArrayList<String>();
int count=0,i,temp=1000000;
try{
Scanner br=new Scanner(f);
while (br.hasNextLine())
{
Str=br.nextLine();
shuffling.add(Str);
}
br.close();
}catch (FileNotFoundException e) {
e.printStackTrace();
}
Collections.shuffle(shuffling);
for(String str : shuffling)
{
WORDS[count]=str.substring(0,str.indexOf(' '));
FREQ[count]=Integer.parseInt(str.substring(str.indexOf(' ')+1,str.length()));
if(FREQ[count]<temp)
temp=FREQ[count];
count++;
}
JFrame frame = new JFrame(TestOpenCloud.class.getSimpleName());
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JPanel panel = new JPanel();
//Cloud cloud = new Cloud();
Random random = new Random();
for (i=0;i<100;i++) {
final int red = (int) (Math.random() * 150);
final int green = (int) (Math.random() * 150);
final int blue = (int) (Math.random() * 150);
final JLabel label = new JLabel(WORDS[i]);
label.setOpaque(false);
label.setFont(new Font("Andalus", Font.PLAIN, ((FREQ[i]*10)/temp)));
Color color=new Color(red,green,blue);
label.setForeground(color);
panel.add(label);
}
frame.add(panel);
frame.setSize(1366, 768);
frame.setVisible(true);
}
public static void Cloud_main(String Path) {
path=Path;
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
new TestOpenCloud().initUI();
}
});
}
}