diff --git a/5letterwoorde.txt b/5letterwoorde.txt index 8adc924..577fa2f 100644 --- a/5letterwoorde.txt +++ b/5letterwoorde.txt @@ -1,94 +1,3 @@ -AVBOB -April -Arnth -Asmaa -Augus -Aulia -Bahaa -Bybel -Chant -China -Deens -Diets -Diits -Dimli -Duits -ELDOT -Ester -Frans -Frañs -Fries -Ghana -Griek -Griet -Griik -Grike -Hakka -Hausa -Hindi -Hosea -IUSTC -Idaal -Iezza -Indië -Japan -Johan -Josua -Judas -Julie -Junie -Kaaps -Khmer -Kleef -Koran -Kraai -Kreef -LLDPE -Laris -Larth -Latyn -Letse -Lukas -Maart -Maori -Masai -Miami -Moelk -Moses -Nahum -Natal -Ngala -Ngoni -Nguni -Noors -Oesil -Oromo -Parys -Pluto -Pools -Ragma -Ronga -Shona -Sjina -Skots -Soeto -Sotho -Swati -Swazi -Tamil -Titus -Trias -Tshwa -Turks -Venda -Venus -Vulci -Waals -Wodan -Wolof -Xhosa -aalwé -aanhê aarde abdis adder @@ -109,27 +18,30 @@ almal altyd amorf amper -amper ander angel anker anode apert appel -appèl +april arend argon +arnth artse asiel +asmaa asnog asook -ateïs atome atoom +augus +aulia +avbob awend -añkom baaie babas +bahaa balie balju balle @@ -138,7 +50,6 @@ batik beaam bedag bedel -bedel bedug bedui beeld @@ -160,7 +71,6 @@ bevat bewer bewys biere -biere binne bioom blaar @@ -168,23 +78,21 @@ blaas blank blare bleik -bleik blits bloed bloei bloek bloet blyer -bláde boarm boeie -boeie boeke boere boeta bokas bokse bokwa +bolas borde boter bouer @@ -206,22 +114,21 @@ broom broot bruid bruin -bróde buike buite bulle burge +bybel bydra bylae bynes -béter -bôgom +chant china curie dagga -dagsê danig datum +deens deken deler delta @@ -231,10 +138,11 @@ dieen dieet diens diere +diets +diits +dimli diode diole -diëne -diëte djinn doepa dorre @@ -247,6 +155,7 @@ drink dronk droog druif +duits durum duvet dwerg @@ -257,6 +166,7 @@ eiens eiers einde eland +eldot elfde elite enige @@ -280,13 +190,12 @@ fliir flora fokus frank +frans frase frees freug -frése +fries fundi -fáder -fógel galop gamma gange @@ -313,7 +222,6 @@ gelas gelei geler geles -geleë geluk genie genus @@ -329,6 +237,7 @@ gewei gewel gewen ghaap +ghana gheip ghiep gholf @@ -344,10 +253,13 @@ grade grawe greep grens +griek +griet +griik +grike groei groen groep -groep groet grond groot @@ -355,6 +267,7 @@ grote gummi gwaai haaie +hakka hallo halte hamel @@ -362,6 +275,7 @@ hamer hande hanne harde +hausa heide hekke hemde @@ -372,23 +286,34 @@ herte hewel hiert hifes +hindi hings hitte -hiëna hoera honde honne hoort +hosea huise hulle -hámel +idaal +iezza inent +inhou inlig insek +iustc +japan japie +johan +josua joule joune +judas +julie julle +junie +kaaps kaart kamer kamma @@ -401,6 +326,7 @@ kegel kendo kenne kerke +khmer kiaat kiste kitse @@ -421,14 +347,16 @@ kloof klubs kluis kluit -knieë knoop knope kobra koeie koker kokke +kolom kolon +kolos +kolot komma konte konyn @@ -437,6 +365,7 @@ koord koors koper koppe +koran korts koste kraai @@ -454,7 +383,6 @@ kusse kuste kwaak kwark -kóper laaie laken lamas @@ -462,9 +390,12 @@ lampe lande langs lanne +laris +larth larwe laser later +latyn leeus leier lekke @@ -473,11 +404,13 @@ lente lepel leser lesse +letse lewer ligte linde linne liste +lldpe loepe logge lonte @@ -485,56 +418,66 @@ loods loops loper luise +lukas lumen maand maant +maart magma magte -magô² -magô¹ mamma mango manna +maori marog +masai massa matte media -melba +meent melba mense meson meter meule +miami miere mikas modus -molêr +moelk monde moord +moses motor muise -mòrre naald naand nadat nagte +nahum narre nasie +natal nefie nekke nette neuro neuse +ngala +ngoni +nguni njala nodig nonna nooit noord +noors norms nosie nulde oefen oeros +oesil oewer offer omdat @@ -552,6 +495,7 @@ optel opwek orals orkes +oromo orrel osoon otjie @@ -561,7 +505,7 @@ ousus padda papie party -passé +parys patat pater penis @@ -575,22 +519,16 @@ plaas plank plant ploeg -ploeë -plonk plonk plooi pluis +pluto poefe poefs poema polse -pols² -pols³ -pols¹ polvy -polêr -pons² -pons¹ +pools posie pouse praat @@ -602,11 +540,10 @@ proes pruik pruim punte -pèrde -pèrre radio radon radys +ragma ramme ratel ravyn @@ -616,8 +553,6 @@ reets regte reier resep -resep -reëns riete ringe riool @@ -627,14 +562,13 @@ roeke roere roers roman +ronga rosyn rugby rugge ruime ruite ruspe -rêrig -rûens saans sagie sande @@ -651,11 +585,13 @@ sesde sette seuns sfeer +shona siaan sider siene sikli sinus +sjina sjuut skaaf skaak @@ -667,9 +603,6 @@ skape skawe skeef skelm -skel² -skel³ -skel¹ skema skepe skerp @@ -681,6 +614,7 @@ skole skool skoot skors +skots skram skrap skree @@ -690,7 +624,6 @@ skuif skuld skulp skuur -skóle slaaf slaan slaap @@ -706,7 +639,6 @@ smede smelt smous smurf -sméde snags sneeu snoei @@ -714,15 +646,17 @@ sober sodat sodra soeke +soeto sogge somer sonde sonne soort +sotho souse sowat sowel -soëwe +spaar speel speld spoel @@ -761,20 +695,19 @@ swaai swaar swael swart +swati +swazi sweep sweer sweis swepe swerm -swépe syfer sypel -sònde -sònne -sómer tafel takel talle +tamil tande tanne tante @@ -783,16 +716,21 @@ tarra terug teuel titel +titus tjank tooms traag traer trage +trane trein +trias troep tronk tsaar +tshwa tulpe +turks uitse uniek unies @@ -802,6 +740,8 @@ vaart vader vanaf varke +venda +venus veral verba video @@ -818,7 +758,6 @@ vloot voete volle vorms -voëls vraag vrank vrede @@ -826,11 +765,12 @@ vrees vreet vreug vroeg -vroeë vroue vryer +vulci vyfde vygie +waals wagte wapen wasem @@ -842,17 +782,17 @@ werke wesel weste wiele +wodan wolke +wolof wolwe woord woort wrier wysie wysig -wáter xenon +xhosa yskas yster zeboe -êrens -zeboe diff --git a/5letterwords.txt b/5letterwords.txt index 9d49f52..342c454 100644 --- a/5letterwords.txt +++ b/5letterwords.txt @@ -5303,6 +5303,7 @@ unfit unfix unhip unhit +uniek unify union unite diff --git a/assets/Release_Notes.md b/assets/Release_Notes.md new file mode 100644 index 0000000..e69de29 diff --git a/src/main/java/org/example/FindLengthFive.java b/src/main/java/org/example/FindLengthFive.java index 6c0e01d..f1640f5 100644 --- a/src/main/java/org/example/FindLengthFive.java +++ b/src/main/java/org/example/FindLengthFive.java @@ -9,10 +9,7 @@ import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.KeyEvent; -import java.io.File; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.PrintWriter; +import java.io.*; import java.util.Objects; import java.util.Scanner; @@ -36,6 +33,7 @@ public class FindLengthFive extends JFrame implements ActionListener { private static final JTextArea ta_words = new JTextArea(); private static final JTextField tf_newWords = new JTextField(); private static final JButton btn_add = new JButton("Add"); + private static final JButton btn_find = new JButton("Find"); private static File wordFile = new File("5letterwords.txt"); private static final JComboBox cb_wordLength = new JComboBox(new Integer[]{5, 6}); @@ -64,7 +62,7 @@ public static void makeLeftPanel(int wordLength) { } public FindLengthFive() { - setTitle("Wordle Solver"); + setTitle("Wordle Solver: " + "File: " + wordFile + "\t Length: " + wordlength); KeyStroke ctrlD = KeyStroke.getKeyStroke(KeyEvent.VK_D, KeyEvent.CTRL_DOWN_MASK); KeyStroke ctrlS = KeyStroke.getKeyStroke(KeyEvent.VK_S, KeyEvent.CTRL_DOWN_MASK); KeyStroke ctrlB = KeyStroke.getKeyStroke(KeyEvent.VK_B, KeyEvent.CTRL_DOWN_MASK); @@ -92,6 +90,7 @@ public FindLengthFive() { btn_search.addActionListener(this); btn_clear.addActionListener(this); btn_add.addActionListener(this); + btn_find.addActionListener(this); cb_wordLength.addActionListener(this); // ✅ Put the JTextArea inside a JScrollPane @@ -103,6 +102,7 @@ public FindLengthFive() { rightPanel.add(tf_newWords, "wrap"); rightPanel.add(btn_add, "wrap"); + rightPanel.add(btn_find, "wrap"); topPanel.add(leftPanel, "cell 0 0,grow"); topPanel.add(rightPanel, "cell 1 0,grow"); @@ -173,6 +173,7 @@ private void doAdd() { wordFile, true /* append = true */)); pw.println(tf_newWords.getText()); + logger.info("Read file {}", wordFile); pw.close(); SortContentsByLinesInFile.sortFile(wordFile.getName(), wordlength); @@ -191,6 +192,60 @@ private void doClear() { } } + /** + * Checks if 'word' contains all the letters in 'letters'. + * Comparison is case-insensitive, and letter frequency matters. + * + * Examples: + * containsAllLetters("apple", "pal") → true + * containsAllLetters("apple", "ppp") → false + * containsAllLetters("banana", "nab") → true + */ + public static boolean containsAllLetters(String word, String letters) { + if (word == null || letters == null) return false; + + // Normalize to lowercase + word = word.toLowerCase(); + letters = letters.toLowerCase(); + + // Count the frequency of each letter in the word + int[] wordCount = new int[26]; + for (char c : word.toCharArray()) { + if (Character.isLetter(c)) { + wordCount[c - 'a']++; + } + } + + // Check if the word has enough of each required letter + for (char c : letters.toCharArray()) { + if (Character.isLetter(c)) { + int index = c - 'a'; + wordCount[index]--; + if (wordCount[index] < 0) { + return false; // not enough of this letter + } + } + } + + return true; + } + + private void doFind() { + String letters = tf_newWords.getText(); + try { + Scanner sc = new Scanner(wordFile); + logger.info("Open {}", wordFile); + ta_words.setText(""); + while (sc.hasNextLine()) { + String line = sc.nextLine(); + if (containsAllLetters(line, letters)) + ta_words.append(line + "\n"); + } + } catch (FileNotFoundException e) { + throw new RuntimeException(e); + } + } + private void doSearch() { StringBuilder includes = new StringBuilder(); String excludes = ""; @@ -288,8 +343,12 @@ public void actionPerformed(ActionEvent e) { int result = fc.showOpenDialog(null); if (result == JFileChooser.APPROVE_OPTION) { wordFile = fc.getSelectedFile(); + setTitle("Wordle Solver: " + wordFile); } } + case "Find": { + doFind(); + } } } diff --git a/src/main/java/org/example/Harvest.java b/src/main/java/org/example/Harvest.java new file mode 100644 index 0000000..dcc30b7 --- /dev/null +++ b/src/main/java/org/example/Harvest.java @@ -0,0 +1,59 @@ +package org.example; + +import java.io.File; +import java.io.FileNotFoundException; +import java.util.Scanner; + +public class Harvest { + + static String inputFilename = "I:\\\\BOOKS\\ASCII\\Afrikaans\\Dinsdagaand_trimmed.txt"; + static String outputFilename = ""; + static int wordLength = 5; + + /** + * Removes all punctuation characters from the start and end of a word. + * Keeps internal punctuation (like apostrophes or hyphens inside a word). + * Returns null if the word contains any characters other than A–Z or a–z. + */ + public static String trimPunctuation(String word) { + if (word == null) return null; + + word = word.toLowerCase(); + // Trim punctuation from the start and end + word = word.replaceAll("^[\\p{Punct}]+|[\\p{Punct}]+$", ""); + + // If word contains any non a–z letters, return null + if (!word.matches("^[a-zA-Z]+$")) { + return null; + } + + return word; + } + + + Harvest() { + + try { + Scanner sc = new Scanner(new File(inputFilename)); + while (sc.hasNextLine()) { + String line = sc.nextLine(); + String[] tokens = line.split(" "); + for (String token : tokens) { + token = trimPunctuation(token); + if (token.length() == wordLength) { + System.out.println( token); + } + } + } + } catch (FileNotFoundException e) { + throw new RuntimeException(e); + } + } + + + public static void main(String[] args) { + Harvest harvest = new Harvest(); + } + + +} diff --git a/src/main/java/org/example/SortContentsByLinesInFile.java b/src/main/java/org/example/SortContentsByLinesInFile.java index 5db27a3..f03bc71 100644 --- a/src/main/java/org/example/SortContentsByLinesInFile.java +++ b/src/main/java/org/example/SortContentsByLinesInFile.java @@ -1,14 +1,37 @@ package org.example; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.io.*; import java.nio.file.*; import java.util.*; public class SortContentsByLinesInFile { + private static final Logger logger = LoggerFactory.getLogger(SortContentsByLinesInFile.class); static int wl = 5; - static String fn = ""; + static String fn = "5letterwoorde.txt"; + + /** + * Removes all punctuation characters from the start and end of a word. + * Keeps internal punctuation (like apostrophes or hyphens inside a word). + * Returns null if the word contains any characters other than A–Z or a–z. + */ + public static String trimPunctuation(String word) { + if (word == null) return null; + + word = word.toLowerCase(); + // Trim punctuation from the start and end + word = word.replaceAll("^[\\p{Punct}]+|[\\p{Punct}]+$", ""); + + // If word contains any non a–z letters, return null + if (!word.matches("^[a-zA-Z]+$")) { + return null; + } + return word; + } public static void sortFile(String filename, int wordlength) { @@ -25,7 +48,8 @@ public static void sortFile(String filename, int wordlength) { try (BufferedReader br = Files.newBufferedReader(inputPath)) { String line; while ((line = br.readLine()) != null) { - + line = line.toLowerCase(); + line = trimPunctuation(line); String cleaned = normaliseLine(line); if (cleaned.length() == wordlength && !cleaned.contains(".")) { @@ -46,6 +70,7 @@ public static void sortFile(String filename, int wordlength) { bw.write(s); bw.newLine(); } + logger.info("File written: {}", inputPath); } catch (IOException e) { e.printStackTrace(); } @@ -75,4 +100,8 @@ private static String normaliseLine(String s) { return s; } + + public static void main(String[] args) { + + } }