}
}
}
private File tokenizeInput(File plainTextDictFile, Language language) throws IOException {
Tokenizer wordTokenizer = language.getWordTokenizer();
String encoding = getOption("fsa.dict.encoding");
String separatorChar = hasOption("fsa.dict.separator") ? getOption("fsa.dict.separator") : "";
File tempFile = File.createTempFile(SpellDictionaryBuilder.class.getSimpleName(), ".txt");
try (Scanner scanner = new Scanner(plainTextDictFile, encoding)) {
try (Writer out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(tempFile), encoding))) {
while (scanner.hasNextLine()) {
String line = scanner.nextLine();
int sepPos = separatorChar.isEmpty() ? -1 : line.indexOf(separatorChar);
String occurrences = sepPos != -1 ? line.substring(sepPos + separatorChar.length()) : "";
String lineWithoutOcc = sepPos != -1 ? line.substring(0, sepPos) : line;
List<String> tokens = wordTokenizer.tokenize(lineWithoutOcc);
for (String token : tokens) {
if (token.length() > 0) {
out.write(token);
if (sepPos != -1) {
out.write(separatorChar);