String matching algorithem in android

+2 Usman Mohy ud Din · October 14, 2014
Hy everyone,

I am developing a mobile word game which used Arabic dictionary for the validation of a word made by user.
The problem i am facing is How to apply a string matching algorithm on Arabic dictionary.

Please guide me
Waiting for your response.

Thanks in Advance

Post a Reply


Oldest  Newest  Rating
0 Usman Mohy ud Din · October 20, 2014

Thanks a lot for your wonderful logic. :)
+1 Alex Sweps · October 19, 2014
To limit processing you could create 24 files and split your dictionary into alphabetical order. Use a switch case statement on the first letter of the word and then run your search method with the appropriate txt file. Something like:

        case: "a"
        //Open the file with the letter A and read line by line searching for the string. 

Theres a method in Java that will read each line of a txt file. I think its .readLines? I dont have time to write and test the code but the above logic will work. If its still too much processing you can split your txt files again and search through the first 2 letters of the word.

Not sure if this the best approach because 1 50 000 is a loot of words to search through. Splitting up the files so your reading from a much smaller list should drastically help though. 
+2 Albo Coder · October 17, 2014
you can get an input from file any time the loop runs so no storing data is needed but I guess you will have to delete the line of input in each loop iteration or find a way to input different lines for each iteration.

I am kinda  busy so I cannot help more than this. You have to figure of the last part of your problem.
0 Usman Mohy ud Din · October 17, 2014


Thanx for your response

In may case,dictionary has 1,50,000 words in a text file.
If i store them in a temporary array and then compare, a lot of time will be required for processing.

Is there any efficient way to response in real time.?? 
+2 Albo Coder · October 15, 2014
There is a method in java IDK if it is same in android.
+1 Alex Sweps · October 15, 2014
This should work too:

public void searchString(){
String test = "test";
String dict[] = {"foo", "bar", "blah", "cat"};
for(int x = 0; x < dict.length; x ++){
System.out.println("The word " + test + " exists");

Or you could replace .contains with .equals
+1 Albo Coder · October 14, 2014
I dont know how that alphabet looks like but lets say you got a string. 
you should have an array of strings having all of the words in 

String wordTaken;
String dictionary[];
Boolean found; 
for(int x=0; x< dictionary.length(); x++)
      for(int y=0; y< wordTaken.length(); y++)
              if([x].at(y) )

// I know you want it in android but I dont know it but it works in Java so this should work
  • 1

Java / Android Development


Very popular language used to create desktop applications, website applets, and Android apps.

Bucky Roberts Administrator