Permalink
Browse files

add setTransliterationEngine

  • Loading branch information...
malayaleecoder committed Aug 21, 2016
1 parent 67ed0f2 commit 10fbed0f0cb0a4d90c1e23eeb930ad2bf99e4250
@@ -0,0 +1,38 @@
package org.smc.inputmethod.indic;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Scanner;


public class Varnam{

public String readfromurl(String input) {
String starting = "https://api.varnamproject.com/tl/ml/";
String urlstring = starting + input;

try {
URL url = new URL(urlstring);
Scanner scan = new Scanner(url.openStream());
String finalresult = new String();
while(scan.hasNext())
finalresult += scan.nextLine();
scan.close();
JSONObject json = new JSONObject(finalresult);
JSONArray dummy = json.getJSONArray("result");
return dummy.getString(0);
} catch (MalformedURLException e) {
throw new RuntimeExceptio(e);
} catch (IOException e) {
throw new RuntimeExceptio(e);
} catch (JSONException e) {
throw new RuntimeExceptio(e);
}
return "";
}
}
@@ -29,6 +29,7 @@
import org.smc.inputmethod.event.CombinerChain;
import org.smc.inputmethod.event.Event;
import org.smc.inputmethod.indic.define.DebugFlags;
import org.smc.inputmethod.indic.Varnam;
import com.android.inputmethod.latin.utils.CoordinateUtils;
import com.android.inputmethod.latin.utils.StringUtils;

@@ -64,7 +65,7 @@
// as an ad-hockery here.
private String mRejectedBatchModeSuggestion;
private InputMethod mTransliterationMethod;

private Varnam mTransliterationEngine;
// Cache these values for performance
private CharSequence mTypedWordCache;
private int mCapsCount;
@@ -111,6 +112,9 @@ public void setTransliterationMethod(InputMethod transliterationMethod) {
mTransliterationMethod = transliterationMethod;
}

public void setTransliterationEngine(Varnam vm) {
mTransliterationEngine = vm;
}
/**
* Clear out the keys registered so far.
*/
@@ -57,6 +57,7 @@
import org.smc.inputmethod.indic.Suggest.OnGetSuggestedWordsCallback;
import org.smc.inputmethod.indic.SuggestedWords;
import org.smc.inputmethod.indic.SuggestedWords.SuggestedWordInfo;
import org.smc.inputmethod.indic.Varnam;
import org.smc.inputmethod.indic.WordComposer;
import org.smc.inputmethod.indic.define.DebugFlags;
import org.smc.inputmethod.indic.define.ProductionFlags;
@@ -2309,9 +2310,10 @@ public void enableTransliteration(String transliterationMethod, Context context)
}

public void enableTransliterationByEngine(String transliterationEngine, Context context) {
InputMethod im;
try {

Varnam vm = new Varnam();
mWordComposer.setTransliterationEngine(vm);
//mConnection.setTransliterationEngine(vm);
isTransliteration = true;
} catch (Exception e) {
e.printStackTrace();

0 comments on commit 10fbed0

Please sign in to comment.