2

I'm in the process of building an application and i would like to include the ability for my application to read what a user has entered into a text box as they are entering it, and based on the sentence so far present the user with two things.

1) A list of possible phrases they are typing to allow easy auto complete, I'm guessing i would use a preset list of phrases that i could search through to get these suggestions.

2)A list of the most likely word that will come next in the sentence based on the sentence structure or simply based on the last word typed.

My question is, is there anything else out there like this? And what is the best way to search through possibly thousands of strings to find a match as quickly and effectively as possible? Should the strings be stored in a text file on the sd card or directly in code or in some sort of database or xml file or even cvs file? Any ideas would be great

Peter
  • 5,071
  • 24
  • 79
  • 115
  • hey, i want to implement the exact same thing in one of my JAVA projects. Do you know any java libraries which can do the task? or some NLP libraries with the same functionality?? – thekosmix May 20 '14 at 12:51

2 Answers2

1

I was looking into this myself, i think you should look at this

The code they used:

 public class CountriesActivity extends Activity {
 protected void onCreate(Bundle icicle) {
     super.onCreate(icicle);
     setContentView(R.layout.countries);

     ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
             android.R.layout.simple_dropdown_item_1line, COUNTRIES);
     AutoCompleteTextView textView = (AutoCompleteTextView)
             findViewById(R.id.countries_list);
     textView.setAdapter(adapter);
 }

 private static final String[] COUNTRIES = new String[] {
     "Belgium", "France", "Italy", "Germany", "Spain"
 };

}

You can declare your preset phrases into a static final string, and use that in place of "COUNTRIES" in the above example.

Now if you're trying to do a "predict" next word type of thing, that's another story. There's an app out there called Swiffkey which predicts a number of words that might come after a sentence. Maybe u can google that and see if there's sourcecode that might show you how to implement that feature.

user1848850
  • 463
  • 7
  • 20
1

You could check out Google Scribe - it does pretty much what you're talking about. The link used to be http://scribe.googlelabs.com but it seems to be gone now :(. Also, many keyboards like swiftkey and even the standard Android keyboard feature basic "next word" prediction.

For current word prediction, a weighted dictionary which you filter through would probably be best. Then next word prediction could be done similarly based on syntax (this would require some semantic structure in your dictionary i.e. which words are subjects, which are verbs what are the different forms a verb can take such as phrasal, modal, etc.)

Some links for your research:

Any database should work that allows you to attach and quickly search through such tagged data, the difficulty is actually building it - very ambitious project and I wish you luck!

agryson
  • 297
  • 2
  • 9