implemented functioning for use, but rework is work in progress
parent
8b7f37c791
commit
867c557bcb
|
@ -1,30 +1,94 @@
|
|||
package facade;
|
||||
|
||||
import domain.FileManager;
|
||||
import domain.PictureManager;
|
||||
import domain.FileLoader;
|
||||
import domain.WordCloudCreator;
|
||||
import domain.TextProcessing;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
public class WordCloudManager {
|
||||
FileManager fileManager;
|
||||
PictureManager pictureManager;
|
||||
private FileLoader fileLoader;
|
||||
private TextProcessing processing;
|
||||
private WordCloudCreator creator;
|
||||
private File filePath;
|
||||
private File stopwordsPath;
|
||||
private String fileFormat;
|
||||
private String fileFormathStopwords;
|
||||
private String text;
|
||||
Set<String> stopwordList = new HashSet<>();
|
||||
private HashMap<String, Integer> wordMap;
|
||||
|
||||
public WordCloudManager() {
|
||||
fileManager = new FileManager();
|
||||
pictureManager = new PictureManager();
|
||||
fileLoader = new FileLoader();
|
||||
processing = new TextProcessing();
|
||||
creator = new WordCloudCreator();
|
||||
fileFormat = "";
|
||||
fileFormathStopwords = "";
|
||||
}
|
||||
|
||||
public boolean loadFileGUI() {
|
||||
|
||||
String fileText = fileManager.loadFile();
|
||||
HashMap wordMap = fileManager.tokenizingText(fileText);
|
||||
if(wordMap != null) {
|
||||
return true;
|
||||
if (filePath == null) {
|
||||
filePath = fileLoader.loadFileGUI();
|
||||
fileFormat = fileLoader.getFileFormat(filePath);
|
||||
System.out.println("File: " + filePath);
|
||||
System.out.println("File: " + stopwordsPath);
|
||||
} else {
|
||||
stopwordsPath = fileLoader.loadFileGUI();
|
||||
fileFormathStopwords = fileLoader.getFileFormat(stopwordsPath);
|
||||
System.out.println("File: " + filePath);
|
||||
System.out.println("File: " + stopwordsPath);
|
||||
}
|
||||
else {
|
||||
if (filePath.length() > 0) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public void addToStopWords(String extraStopword) {
|
||||
stopwordList.add(extraStopword);
|
||||
System.out.println(stopwordList);
|
||||
}
|
||||
|
||||
public void setStopWords() {
|
||||
Set<String> stopwords = processing.textToSetStopwords(processing.tokenizingFile(processing.
|
||||
formatToText(stopwordsPath, fileFormathStopwords), null));
|
||||
stopwordList.addAll(stopwords);
|
||||
System.out.println(stopwordList);
|
||||
}
|
||||
|
||||
|
||||
public void stemming(String approval) {
|
||||
if(approval.equals("yes")) {
|
||||
processing.setStemming(true);
|
||||
}
|
||||
}
|
||||
|
||||
public void maxWordsInList(int number) {
|
||||
processing.setMaxWords(number);
|
||||
}
|
||||
|
||||
|
||||
// ab hier noch nicht fertig.
|
||||
public void tokenizingText() {
|
||||
wordMap = (HashMap<String, Integer>) processing.tokenizingFile(processing.fileToTextString(filePath, fileFormat)
|
||||
, !stopwordList.isEmpty() ? stopwordList : null);
|
||||
System.out.println(wordMap.keySet() + "\n" + wordMap.values());
|
||||
}
|
||||
|
||||
public void cutWordsList() {
|
||||
|
||||
|
||||
wordMap = (HashMap<String, Integer>) processing.maxShowWords(processing.sortList(wordMap));
|
||||
processing.sortList(wordMap);
|
||||
System.out.println(wordMap.keySet() + "\n" + wordMap.values());
|
||||
}
|
||||
|
||||
public void createWordCloud() {
|
||||
creator.insertWordsIntoTemplate(wordMap);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue