1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
| package fr.guehenneux.wordgen;
import java.io.IOException;
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.stream.Stream;
/**
* Based on sciencetonnante video
* https://www.youtube.com/watch?v=YsR7r2378j0
*
* @author Jonathan Guéhenneux
*/
public class WordGenerator {
private static final char NULL_CHARACTER = 0;
private static final Random RANDOM = new Random();
/**
* @param arguments
* @throws IOException
*/
public static void main(String[] arguments) throws IOException {
String dictionaryPath = arguments[0];
int windowSize = Integer.parseInt(arguments[1]);
int wordLength = Integer.parseInt(arguments[2]);
int wordCount = Integer.parseInt(arguments[3]);
WordGenerator wordGenerator = new WordGenerator(dictionaryPath, windowSize);
int generatedWordCount = 0;
while (generatedWordCount < wordCount) {
System.out.println(wordGenerator.generateRandomWord(wordLength));
generatedWordCount++;
}
} |
Partager