function for user for use this program
parent
ffda6973d2
commit
03dea0b503
|
@ -1,10 +1,7 @@
|
||||||
package tui;
|
package tui;
|
||||||
|
|
||||||
import java.util.Scanner;
|
|
||||||
|
|
||||||
public class Main {
|
public class Main {
|
||||||
|
|
||||||
public static void main(String[]args){
|
public static void main(String[]args){
|
||||||
TUI tui = new TUI();
|
new TUI();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,45 +5,97 @@ import facade.WordCloudManager;
|
||||||
import java.util.Scanner;
|
import java.util.Scanner;
|
||||||
|
|
||||||
public class TUI {
|
public class TUI {
|
||||||
boolean isRunning;
|
private boolean isRunning;
|
||||||
|
private Scanner scan;
|
||||||
|
private int option;
|
||||||
|
private WordCloudManager wcm;
|
||||||
|
private boolean fMenu;
|
||||||
|
|
||||||
public TUI(){
|
public TUI(){
|
||||||
|
wcm = new WordCloudManager();
|
||||||
isRunning = true;
|
isRunning = true;
|
||||||
|
fMenu = true;
|
||||||
|
scan = new Scanner(System.in);
|
||||||
tui();
|
tui();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void tui() {
|
public void tui() {
|
||||||
Scanner scan = new Scanner(System.in);
|
|
||||||
WordCloudManager wcm = new WordCloudManager();
|
|
||||||
// while(isRunning) {
|
while(isRunning) {
|
||||||
System.out.println("Welcome to Word Cloud.\nMenu:\n\n(0) Load File from main path\n(1) Load File with Gui" +
|
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) Save File\n(3) Show Picture\n(4) Exit");
|
"\n(2) Exit");
|
||||||
int option = scan.nextInt();
|
option = Integer.parseInt(scan.nextLine());
|
||||||
switch (option) {
|
switch (option) {
|
||||||
case(0):
|
case(0):
|
||||||
//Load File Path
|
|
||||||
break;
|
|
||||||
case (1):
|
|
||||||
//Load File GUI
|
//Load File GUI
|
||||||
if(wcm.loadFileGUI()) {
|
if(wcm.loadFileGUI()) {
|
||||||
System.out.println("File loaded successful!\n");
|
System.out.println("File loaded successful!\n");
|
||||||
|
fileMenu();
|
||||||
} else {
|
} else {
|
||||||
System.out.println("File cannot be loaded!\n");
|
System.out.println("File cannot be loaded!\n");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case(1):
|
||||||
|
//URL Input
|
||||||
|
break;
|
||||||
case(2):
|
case(2):
|
||||||
//Save Picture
|
|
||||||
break;
|
|
||||||
case (3):
|
|
||||||
//Show Picture
|
|
||||||
break;
|
|
||||||
case (4):
|
|
||||||
//Exit
|
//Exit
|
||||||
isRunning = false;
|
isRunning = false;
|
||||||
System.out.println("Close Program!");
|
System.out.println("Close Program!");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// }
|
}
|
||||||
scan.close();
|
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.loadFileGUI()) {
|
||||||
|
System.out.println("File loaded successful!\n");
|
||||||
|
wcm.setStopWords();
|
||||||
|
} else {
|
||||||
|
System.out.println("File cannot be loaded!\n");
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case(1):
|
||||||
|
// Add more stopwords
|
||||||
|
System.out.println("Type your stopword:\n");
|
||||||
|
String input = scan.nextLine();
|
||||||
|
wcm.addToStopWords(input);
|
||||||
|
break;
|
||||||
|
case(2):
|
||||||
|
// Set number of max words
|
||||||
|
int number = Integer.parseInt(scan.nextLine());
|
||||||
|
wcm.maxWordsInList(number);
|
||||||
|
wcm.cutWordsList();
|
||||||
|
break;
|
||||||
|
case(3):
|
||||||
|
// Set Stemming
|
||||||
|
System.out.println("Set Stemming: Input 'yes' or 'no'");
|
||||||
|
String stemmingOption = scan.nextLine();
|
||||||
|
wcm.stemming(stemmingOption);
|
||||||
|
break;
|
||||||
|
case(4):
|
||||||
|
//Create WordCloud
|
||||||
|
wcm.tokenizingText();
|
||||||
|
wcm.createWordCloud();
|
||||||
|
fMenu = false;
|
||||||
|
System.out.println("HTML File created!");
|
||||||
|
break;
|
||||||
|
case(5):
|
||||||
|
//Exit filemenu
|
||||||
|
fMenu = false;
|
||||||
|
System.out.println("Close Program!");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue