Skip to content

Instantly share code, notes, and snippets.

@sleepynight2024
Created December 4, 2020 16:53
Show Gist options
  • Save sleepynight2024/0e4d8ee010ad4c246f5ec79f52345c5e to your computer and use it in GitHub Desktop.
Save sleepynight2024/0e4d8ee010ad4c246f5ec79f52345c5e to your computer and use it in GitHub Desktop.
/**
* Check if there are unique Kurdish letters written in English (e.g. sh --> ş)
* @param badWord the word to check
* @param dictionary the dictionary to compare with
* @return the result if there is any
* */
static TreeSet uniqueKurdishLetters(String badWord, HashSet dictionary) {
TreeSet resultSet = new TreeSet<String>(); // Set to return results
if (badWord.contains("ch")){ // ch could be ç
String word = badWord.replaceAll("ch", "ç");
if (dictionary.contains(word)){
resultSet.add(word);
}
}
if (badWord.contains("sh")){ // sh could be ş
String word = badWord.replaceAll("sh", "ş");
if (dictionary.contains(word)){
resultSet.add(word);
}
}
String[] possibleDuplicates = {"ee", "ei", "ie", "ii", "ae", "ea", "ai", "ia"}; // Famous Kurdish spelling mistakes
String[] possibleMeanings = {"î", "ê", "iya", "iyê", "iyan", "a", "e", "i"}; // Possible meanings of them
for (String str : possibleDuplicates){
if (badWord.contains(str)){
for (String corrected : possibleMeanings){
String word = badWord.replace(str, corrected);
if (dictionary.contains(word)){
resultSet.add(word);
}
}
}
}
return resultSet;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment