<commit_before>package ntu.csie.keydial;

import static java.util.Collections.*;

import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public class Prediction {

	static final Prediction instance = new Prediction();

	static Prediction getInstance() {
		return instance;
	}

	static final String OMEGA = "Ω";

	TreeMap<String, Integer> corpus = new TreeMap<String, Integer>(String.CASE_INSENSITIVE_ORDER);

	Pattern SENTENCE = Pattern.compile("^.*\\w+$", Pattern.CASE_INSENSITIVE);
	Pattern SPACE = Pattern.compile("\\s+");

	public List<String> completeSentence(String s, int limit) {
		if (SENTENCE.matcher(s).matches()) {
			String[] input = SPACE.split(s);
			if (input.length > 0) {
				String prefix = input[input.length - 1];
				if (prefix.length() > 0) {
					return completeWord(prefix, limit);
				}
			}
		}
		return emptyList();
	}
<commit_msg>* if no suggestions are available, just suggest the current input to make at least make it easy to type word+space via tab-tab completion<commit_after>package ntu.csie.keydial;

import static java.util.Collections.*;

import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public class Prediction {

	static final Prediction instance = new Prediction();

	static Prediction getInstance() {
		return instance;
	}

	static final String OMEGA = "Ω";

	TreeMap<String, Integer> corpus = new TreeMap<String, Integer>(String.CASE_INSENSITIVE_ORDER);

	Pattern SENTENCE = Pattern.compile("^.*\\w+$", Pattern.CASE_INSENSITIVE);
	Pattern SPACE = Pattern.compile("\\s+");

	public List<String> completeSentence(String s, int limit) {
		if (SENTENCE.matcher(s).matches()) {
			String[] input = SPACE.split(s);
			if (input.length > 0) {
				String prefix = input[input.length - 1];
				if (prefix.length() > 0) {
					List<String> options = completeWord(prefix, limit);
					if (options.size() > 0) {
						return options;
					} else {
						return singletonList(prefix);
					}
				}
			}
		}
		return emptyList();
	}

{'fraction_non_alphanumeric': 0.12999185004074978, 'fraction_numerical': 0.0028524857375713123, 'mean_word_length': 4.179324894514768, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1196211', 'n_tokens_mistral': 873, 'n_tokens_neox': 778, 'n_words': 198}