13

I am doing some research on string matching algorithms. One of the most usable I came across is the one my cellphone uses (android 2.3.4 on SE xPeria neo v).

enter image description here

As seen in the screenshot, I pressed the characters jiw which are near the ones I wanted and it suggested correctly.

It seems like the algorithm is similar to levenstein distance (distance between my input and the dictionary). Somehow the near characters have some value in the string-matching.

Any idea about the algorithm being used?

Odys
  • 8,951
  • 10
  • 69
  • 111
  • 5
    Can some of the close-voters explain why they think this is non-constructive? The question is very precise ("What algorithm is used?") and the source code for the system is publicly available so the question may be possible to answer. – Emil Vikström Jun 16 '12 at 19:07
  • 4
    +1 for a concise, answerable, interesting question. – goat Jun 16 '12 at 19:10
  • 2
    Very Interesting programming question, +1 VOTE and good luck for your project – mm24 Jun 16 '12 at 19:50

2 Answers2

4

I pulled the Android source code and looked for spell checking. I found this directory which seems to contain the sources you are looking for:

packages/inputmethods/LatinIME/java/src/com/android/inputmethod/latin/

The file spellcheck/AndroidSpellCheckerService.java looks like the one doing all the heavy work, but Suggest.java also seems to be involved in some way.

Emil Vikström
  • 90,431
  • 16
  • 141
  • 175
2

This excellent information retrieval book has a detailed section on Levenstein distance, including weighted variations. The weights could then be taken to be the distance between keys on your keypad.

phs
  • 10,687
  • 4
  • 58
  • 84
  • Thank you @phs. The article gives much information and points me to my initial suspicion that Levenstein distance is the metric for string comparison in Android. But yet only suspicions.. – Odys Jun 17 '12 at 00:48