109 lines
3.7 KiB
Java
109 lines
3.7 KiB
Java
package tui;
|
|
|
|
import facade.WordCloudManager;
|
|
|
|
import java.util.Scanner;
|
|
|
|
public class TUI {
|
|
private boolean isRunning;
|
|
private Scanner scan;
|
|
private int option;
|
|
private WordCloudManager wcm;
|
|
private boolean fMenu;
|
|
|
|
public TUI(){
|
|
wcm = new WordCloudManager();
|
|
isRunning = true;
|
|
scan = new Scanner(System.in);
|
|
tui();
|
|
|
|
}
|
|
|
|
public void tui() {
|
|
while(isRunning) {
|
|
System.out.println("Welcome to Word Cloud.\nType number in the following Menu to access your targeted Option.\nMenu:\n\n(0) Load File\n(1) URL Path" +
|
|
"\n(2) Exit");
|
|
option = Integer.parseInt(scan.nextLine());
|
|
switch (option) {
|
|
case(0):
|
|
//Load File GUI
|
|
if(wcm.loadFile()) {
|
|
System.out.println("File loaded successful!\n");
|
|
fMenu = true;
|
|
fileMenu();
|
|
} else {
|
|
System.out.println("File cannot be loaded!\n");
|
|
}
|
|
break;
|
|
case(1):
|
|
//URL Input
|
|
break;
|
|
case(2):
|
|
//Exit
|
|
isRunning = false;
|
|
System.out.println("Close Program!");
|
|
break;
|
|
}
|
|
}
|
|
scan.close();
|
|
}
|
|
|
|
public void fileMenu() {
|
|
while(fMenu) {
|
|
System.out.println("(0) Load Stopwords\n(1) Add to Stopwords\n(2) Set Max Words in HTML\n" +
|
|
"(3) Stemming? (only German available)\n(4) Create WordCloud\n(5) Exit FileMenu");
|
|
option = Integer.parseInt(scan.nextLine());
|
|
switch(option) {
|
|
case (0):
|
|
// Load stopwords file
|
|
if(wcm.loadFile()) {
|
|
if(wcm.loadStopwords()) {
|
|
System.out.println("File loaded successful!");
|
|
}
|
|
else{
|
|
System.out.println("Cannot load one more File!");
|
|
}
|
|
} else {
|
|
System.out.println("File cannot be loaded!");
|
|
}
|
|
break;
|
|
case(1):
|
|
// Add more stopwords
|
|
System.out.println("Type your stopword: ");
|
|
String input = scan.nextLine();
|
|
wcm.addToStopWords(input);
|
|
break;
|
|
case(2):
|
|
// Set number of max words
|
|
System.out.println("How much max words do you want? ");
|
|
int number = Integer.parseInt(scan.nextLine());
|
|
wcm.setMaxWords(number);
|
|
break;
|
|
case(3):
|
|
// Set Stemming
|
|
System.out.println("Stemming: Input 'yes' or 'no'? ");
|
|
String stemmingOption = scan.nextLine();
|
|
if(stemmingOption.equals("yes")) {
|
|
wcm.setStemming(true);
|
|
}
|
|
break;
|
|
case(4):
|
|
//Create WordCloud
|
|
if(wcm.createWordCloud()) {
|
|
System.out.println("HTML File created!");
|
|
fMenu = false;
|
|
}
|
|
else {
|
|
System.out.println("HTML FIle not created!");
|
|
}
|
|
break;
|
|
case(5):
|
|
//Exit Filemenu
|
|
fMenu = false;
|
|
System.out.println("Close Program!");
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|