Permalink
Browse files

Final working Varnam

  • Loading branch information...
malayaleecoder committed Aug 22, 2016
1 parent a72da92 commit f5c90de6af7548fd8b483cde2a277d0ad2bbe605
Showing with 21 additions and 5 deletions.
  1. +21 −5 java/src/org.smc.inputmethod/indic/WordComposer.java
@@ -242,7 +242,9 @@ public void applyTransliteration(final Event event) {
}
}
}
String finalword = "";
String previousreplacement = "";
int startPosition;
public void applyTransliterationByEngine(final Event event) {
context = "";
final int primaryCode = event.mCodePoint;
@@ -252,10 +254,24 @@ public void applyTransliterationByEngine(final Event event) {
String mTypedWord = mTypedWordCache.toString();
if(mTransliterationEngine != null && Constants.CODE_DELETE != event.mKeyCode) {
String current = new String(Character.toChars(primaryCode));
int startPos = mTypedWord.length() - 1 > mTransliterationEngine.getMaxKeyLength() ? mTypedWord.length() - mTransliterationEngine.getMaxKeyLength() - 1: 0;
String input = mTypedWord.subSequence(startPos, mTypedWord.length()).toString();
String replacement = mTransliterationEngine.transliterate(input);
mCombinerChain.replace(startPos, mTypedWord.length(), replacement);
if(previousreplacement == "") {
startPosition = mTypedWord.length() - 1 > mTransliterationEngine.getMaxKeyLength() ? mTypedWord.length() - mTransliterationEngine.getMaxKeyLength() - 1 : 0;
}
else {
int startPosition = previousreplacement.length() - 1 > mTransliterationEngine.getMaxKeyLength() ? previousreplacement.length() - mTransliterationEngine.getMaxKeyLength() - 1: 0;
}
//String input = mTypedWord.subSequence(startPos, mTypedWord.length()).toString();
String dummyintermediate = mTypedWord.subSequence(mTypedWord.length() - 1, mTypedWord.length()).toString();
if(mTypedWord.length() == 1 && finalword.length() != 0) {
finalword = dummyintermediate;
}
else {
finalword += dummyintermediate;
}
String replacement = mTransliterationEngine.transliterate(finalword);
previousreplacement = replacement;
mCombinerChain.reset();
mCombinerChain.replace(startPosition, replacement.length(), replacement);
context += current;
if(context.length() > mTransliterationEngine.getContextLength()) {

0 comments on commit f5c90de

Please sign in to comment.