1

文字列に問題があり、解決策が必要です。たとえば、特定の位置にある文字を同じ位置にある文字に置き換えようとしています

 private String wordNormalize(String enteredWord,String dictionary){
    String normalizedWord = null;
// remove empty spaces at beginning and at the end of the word and change to lower case
    normalizedWord = enteredWord.trim().toLowerCase();

    //normalize term, removing all punctuation marks

    normalizedWord = normalizedWord.replaceAll("["+punctuationMarks2+"]", "[b,v]");

    //normalize word removing to character if dictionary has english lang                                           
    normalizedWord = normalizedWord.replaceFirst("to ", " ");
    //normalizeWord if dictionary has german
    if(normalizedWord.length() > 0){
        normalizedWord.replace("a,b,c","t,u,v");
    /*for(int i = 0;i<normalizedWord.length();i++){
          char currentChar = normalizedWord.charAt(i); // currently typed character
          String s1= Character.toString(currentChar);
        for(int j = 0;j<specialCharacters.length;j++){
        s1.replaceAll("[ "+specialCharacters[i]+" ]",""+replaceCharactersDe[i]+"");
        }
         = str.replace("a,b,c","t,u,v");
    }*/
    }

    //normalize term removing special characters and replacing them 
    /*for(int i = 0; i > specialCharacters.length;i++){
        if(normalizedWord.equals(specialCharacters[i])){
            normalizedWord = replaceCharactersDe[i];
        }
    }*/
    return normalizedWord;
}

したがって、ユーザーが a を入力すると t に置き換えられ、ユーザーが b を入力すると u に置き換えられ、ユーザーが c を入力すると v に置き換えられます。やるべきこと

4

1 に答える 1