implemented functioning for use, but rework is work in progress

pull/6/head
Daniel Fromm 2025-05-11 21:00:16 +02:00
parent 8b7f37c791
commit 867c557bcb
1 changed files with 77 additions and 13 deletions

View File

@ -1,30 +1,94 @@
package facade; package facade;
import domain.FileManager; import domain.FileLoader;
import domain.PictureManager; import domain.WordCloudCreator;
import domain.TextProcessing;
import java.io.File; import java.io.File;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.HashSet;
import java.util.Set;
public class WordCloudManager { public class WordCloudManager {
FileManager fileManager; private FileLoader fileLoader;
PictureManager pictureManager; 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() { public WordCloudManager() {
fileManager = new FileManager(); fileLoader = new FileLoader();
pictureManager = new PictureManager(); processing = new TextProcessing();
creator = new WordCloudCreator();
fileFormat = "";
fileFormathStopwords = "";
} }
public boolean loadFileGUI() { public boolean loadFileGUI() {
if (filePath == null) {
String fileText = fileManager.loadFile(); filePath = fileLoader.loadFileGUI();
HashMap wordMap = fileManager.tokenizingText(fileText); fileFormat = fileLoader.getFileFormat(filePath);
if(wordMap != null) { System.out.println("File: " + filePath);
return true; 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; 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);
}
}