i want to create an android application that can search word in sqlite database using approximate string matching.
for example if someone misspelled the word "switch" with " swithc", the sistem will correct the word and show message "did you mean 'switch' ".
its like google that can correct wrong word. how can i do it ?
have a look at this answer
Java: how to find the most probable string in a list of strings?
you can use the way of string matching as you desire. there is also a github project for this at:
https://github.com/northpoint/blur
Related
In my application users enters mobile number's country code with '+' symbol. Right now I am checking for + symbol. If they enter '+INDIA', according to my code this is correct. But according to logic this is wrong. They needs to enter '+91'. Means they can enter only 1, 2 or 3 digit number with '+' symbol. for example '+1', '+91' or '+234'. How I can achieve this type of validation in android?
You could write your own Pattern to check the format. I could give you the example, but I think the site I linked explains it much better.
It should probably start with something like \+\d\d?\d?
You could try using Google's own implementation of Phone Numbers or this xml list.
Hope it helps !
Is there any way to find the text programmatically?
I would like put a extensive text in a TextView or other way, and then to search for specific words, as if you used Ctrl + F. I don't found information, I found SearchView but these search data only of a View, no?
Thanks in advance.
You can use the method .contains provided by the String class that "Returns true if and only if this string contains the specified sequence of char values" (Oracle Docs) within your algorithm for searching for text then based on what that method returns execute certain code to do what you want if the CharSequence exists or not.
String Class (Oracle)
I'm writing an Andriod app, and I'd like to see if there is a quick way for this. I don't really want to split the whole string into multiple array elements, as the contents might contain non-English characters.
I've tried to use whereContains("myColumn", ), but it doesn't return any result. Can anyone please shed some light on this?
If you are looking for a SQL query why not use the LIKE
For example
SELECT * FROM your_table_name WHERE your_column_name LIKE '%your_sub_string%';
I hope this helps!
Based on the tags you placed, I assume you are talking about Parse.
Try this:
yourQuery.whereMatches(<yourfield>,<text you are searching>, "im");
See http://www.parse.com/docs/android/api/com/parse/ParseQuery.html#whereMatches(java.lang.String,%20java.lang.String,%20java.lang.String)
Example:
titleQuery.whereMatches("title", "hello", "im");
i - Case insensitive search
m - Search across multiple lines of input
I have the following idea:
In German we have four extra letters (ä, ö, ü, ß) and I don't know any other language which has these vocals but I think French people with their accents also know this problem. We have a lot of apps in the Google Play store for cities, bus stations, trains and other stuff like that. Now it is really exhausting that we always have to write these letters if we are on the go. It would be much easier to write Munchen (=München [de] = Munich [en]), Osterreich (Österreich [de] = Austria [en]) or something like Uberwasserstrasse (Überwasserstraße [de] = Over-Water-Street [en]). So my question is now:
A lot of apps show suggestions for our just typed word. I think in the code it is something like this:
String current = editText.getText().toString();
db.lookUp(current); // Of course SQL statement
Can we hook this so that Android thinks that we have typed an ä, ö, ü, ß if we write an a, o, u, ss and the system looks for words with one of these vowels and suggests both? Here I do not want to ask for code - I want to discuss if we are able to write a hack or hook for the Android system. Also, root-rights can be assumed with the solution. I'm looking forward to your ideas.
You could do this the other way around, by "normalizing" typed characters into their related non-diacritical versions. You can use the java.Text.Normalizer class for this. A good snippet can be found in this article:
public static String removeAccents(String text) {
return text == null ? null :
Normalizer.normalize(text, Form.NFD)
.replaceAll("\\p{InCombiningDiacriticalMarks}+", "");
}
When applied to "Münich", this returns "Munich". That way, you can use a simple string comparison using these normalized versions.
This wouldn't work for "ß" though. If that's the only special case, you could handle it separately.
What you are looking for is called accent-insensitive collating sequence. SQLite's COLLATE operator can be used to do such searches, but I learned from another post that there might be bugs you'll need to look out for.
can any one know about how to add/insert emotions/smiles to text(which ever i typed in my edit text for my notes). i have little confusion about if i want to add these smiles of type .png in to edit text type of string, is it possible? and also i have to save these input into sqlite database. normally i know to store string data taken from edit text.
but along with that text i want to also add smiles symbols where ever my cursor placed and to be store in sqlite data base. and get it back to read.
so guys any ideas, most welcome!
Try to use java (i.e. android) spannable method to implement smiley (i.e.) images for that. You will surely get it, search in google for "how to add images/smiley with java spannable method in android?" you will get good idea.
Reading your question the first thing I can think of is Mapping each image to a sequence of letters, for example :) is smiley.png etc. Now your database also has these smaller representation However while reading from the database you can convert those special character sequences to appropriate image.
For simplicity in seraching those Strings You can wrap them in some less used characters i.e. [ or { or <.