detect the language of a particular piece of text (no internet connection)

by alan lam » Thu, 11 Nov 2010 16:48:33 GMT


Sponsored Links
 Is there any function/library/API which can detect the language of a
particular piece of text (no internet connection)?
i.e. for an input text "This is a sentence", it should detect the
language as "English".
Or for "Esto es una sentencia" it should detect the language as
"Spanish".

--



detect the language of a particular piece of text (no internet connection)

by Kumar Bibek » Fri, 12 Nov 2010 02:11:41 GMT


 There are no such APIs that I am aware of in the Android SDK. There
might be some 3 party libraries, but again, I haven't searched for
them. Try googling.




--


Sponsored Links


detect the language of a particular piece of text (no internet connection)

by moffetta » Fri, 12 Nov 2010 02:21:58 GMT


 You could use 2 easy method

1) make a dictionary of common words for every language and test it
against the sentence. If a language has multiple match against more
words, then probably that is the language is written in;

2) (maybe a fallback if previous method didn't work or was not useful)
every language has a particular frequency of some letter - eg. in
english i think the letter "e" is very common. you should find this
rules (with google) and apply to your case.

those are just ideas, hope helped anyway




--



detect the language of a particular piece of text (no internet connection)

by Daniel Drozdzewski » Fri, 12 Nov 2010 18:58:30 GMT


 


I don't think you can do it without internet connection and utilising
some API (like Google Translate) with massive dictionaries behind it.

To establish letter frequencies, you would need to capture quite lot
of text (well, more than 1 sentence) for the analysis to be
statistically valid, otherwise you would have many errors. The
differences are small towards the end of the tail.

Please have a look at this article, to see, what you would be against:
 http://en.wikipedia.org/wiki/Letter_frequency 

Similar issue is with local dictionaries: you would need them to be
quite big in order to achieve decent results. Scanning those would
take time.


Daniel

--



Other Threads

1. Persistence of handlers registered with Context.registerReceiver

My application responds to various system-wide intents and what it
responds to depends on the configuration of the user (e.g. the use can
set whethere it should respond to incoming SMS or not, should respond
to network tickles or not, etc).

While I could just register all the handlers/receivers using the
manifest. I feel that it would be a waste of cycles if every
configurable handler gets registered via the manifest and in that
handler, will do a check against the preference settings to see
whether it should execute or not. So, I thought of assigning the
handlers programatticaly instead, simply registering the needed
handlers via Context.registerReceiver.

My issue is, the documentation does not state how persistent is the
Context.registerReceiver registry. That is, if the device gets
rebooted, do I have to re-register the recievers again (i.e. have a
service auto-start with the boot sequence which registers the
handlers)?
--~--~---------~--~----~------------~-------~--~----~

2. MySQL in android server

Hi all,

I am trying to write a piece of code on the server (where the client
can upload data). I want to use MySQL database for the same. However i
am getting an error while trying to connect. The error is:
DEBUG/dalvikvm(616): Exception Ljava/lang/ClassNotFoundException; from
PathClassLoader.java:205 not caught locally
DEBUG/dalvikvm(616): NOTE: loadClass 'com.mysql.jdbc.Driver'
0x40069960 threw an exception


My code snippet is as follows:

void open()
    {
                Log.d("entering***" , "&&&&&&&");
        try {
                try{
            Class.forName("com.mysql.jdbc.Driver").newInstance();
                }catch (Exception g) {Log.d("after forname " , " $$$$$$");
g.printStackTrace();}
                Log.d("entering55555555555" , "&&&&&&&");

            Conn = DriverManager.getConnection("jdbc:mysql://localhost/
test","rahul","gerrard");
            Log.d("entering" , "&&&&&&&");
            Stmt = Conn.createStatement();
            RS=Stmt.executeQuery("SELECT name,blog from android");
            int i=1;
            Log.d("HERE!!!! " , "I  AM ");
            while (RS.next())
            {
                results.add(i + " : " + RS.getString(1) + " writes " +
RS.getString(2));
                Log.d("results ::: ", RS.getString(1) + "  " +
RS.getString(2));
            }
            } catch (Exception e) {
                Log.d("ERROR%%%" , ":(:(:( " );
                e.printStackTrace(); }
    }


any help would be appreciated...
Thanks
Rahul
--~--~---------~--~----~------------~-------~--~----~

3. Upgrade to m5-rc15

4. Source code for android.R.layout.simple_list_item_1

5. Query People.CONTENT_URI by ID, return sql exception (very simple code with exception)

6. Get a set of contacts

7. Problems with animation on two views running parallel.