public Set<Pair<String, Integer>> getSingleEditCandidates(String query, int edits) {
		Set<Pair<String, Integer>> candidates = new HashSet<Pair<String, Integer>>();	

		for (int i = 0; i < query.length(); i++) {
			StringBuilder cand = new StringBuilder(query);
			for (char c : alphabet) {
				if (query.charAt(i) != c) {
					// Insertion
					cand.insert(i, c);
					if (_lm.hasNOrFewerInvalidWords(cand.toString(), 0)) {
						candidates.add(new Pair<String, Integer>(cand.toString().trim().replace("  ", " "), edits));
					}
					cand.deleteCharAt(i);	

					// Substitution
					char origChar = cand.charAt(i);
					cand.setCharAt(i, c);
					if (_lm.hasNOrFewerInvalidWords(cand.toString(), 0)) {
						candidates.add(new Pair<String, Integer>(cand.toString().trim().replace("  ", " "), edits));
					}
					cand.setCharAt(i, origChar);
				}
			}
			// Deletion
			cand.deleteCharAt(i);
			if (_lm.hasNOrFewerInvalidWords(cand.toString(), 0)) {
				candidates.add(new Pair<String, Integer>(cand.toString().trim().replace("  ", " "), edits));
			}
		}

		// Transposition
		for (int i = 0; i < query.length() - 1; i++) {
			StringBuilder cand = new StringBuilder(query);
			// Substitutions
			char c1 = cand.charAt(i);
			char c2 = cand.charAt(i + 1);
			cand.setCharAt(i, c2);
			cand.setCharAt(i + 1, c1);
			if (_lm.hasNOrFewerInvalidWords(cand.toString(), 0)) {
				candidates.add(new Pair<String, Integer>(cand.toString().trim().replace("  ", " "), edits));
			}
		}

		return candidates;
	}