Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# ASP.NET
How can we check the language of text entered in the Textbox in ASP.NET c#
Posted 2-Oct-12 16:46pm
Comments
Sergey Alexandrovich Kryukov at 2-Oct-12 22:48pm
   
Doesn't your common sense tell you the answer? it's pretty obvious... :-)
--SA

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

This is theoretically impossible, because not all texts can be classified as some certain language (example: just digits, punctuation), too many texts are written in more them one language.
 
However, lets see if you can get some limited results.
 
If we set aside very intellectual linguistic methods and the method simply using huge databases of linguistic information — developing of such approaches belongs to computational linguistics and can take a lifetime — you can only determine the language in limited number of situations and for some limited number of languages. For example, if you know in advance that only 15 previously known languages could be used, you can draw one of 17 conclusions: one of 15, or "no specific language" or "failed to determine".
 
Having made these assumption, what languages are not good for such simple analysis? I assume we are not using dictionaries (which is unreliable, anyway, please see below) and trying to determine the language "of majority of words", by collecting some statistics. We can determine only the Unicode subsets of each characters. All Unicode code points is classified into subset, each for certain applications (such as punctuation), and most of such subsets represent a "writing system".
 
So, let's see. If a writing system is used by just one language, you can determine the language of a word by the Unicode subset. How good is this method? Right now, I remembered only three languages which could be clearly determined by the writing system: Georgian (still have dialects some consider as different languages) and Armenian. I checked Tamil writing system (Tamil script), but it appeared to be used by some other languages except Tamil. I'm sure people from different countries will give more examples.
 
Chinese writing system is also used in Korea, Japan and elsewhere; and even in China the languages using the common writing system are considered different. If you want to call the whole writing system a "language", it will be incorrect, but still give you some classification.
 
The simplest typical case is Cyrillic and Latin. Each of these writing systems is used in different languages, sometime very different. For example, Cyrillic is used by modern Mongolian, a language of Altaic family (including Turkic, Mongolic, Tungusic, and Japonic groups, basically, and Korean), and many Turkic language use either Latin or Cyrillic, as well as Arabo-Persian system. How to go about that?
 
I don't want to discuss many more complex by fairly usual situations. For example, did you see some artificially "invented" words spelled using a mix of writing systems (usually two, most people don't know more), to create humorous or catchy (advertising) effect?
 
And finally, let's imagine that you have access to all dictionaries for all world languages; and the dictionaries will work infinitely fast. Will it work? Not so simple. I already mentioned that many texts are mixed language. For example, take the speech of non-English-speaking software developers. Another example: many Ukrainians and people from southern Russian regions use the dialects mixing many Ukrainian and Russian words. Besides, there are many, many words spelled in the same writing system, totally identical in spelling, but belonging to different languages. Moreover, they may have completely different meanings in these languages — there are numerous jokes around funny coincidences in different languages.
 
As a conclusion, you should admit that the general problem is prohibitively difficult, and not really by some technical reason. The notion of the "language of the text" itself is not really correct; even though it could be applied to a relatively limited set of cases.
 
—SA
  Permalink  
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 /\jmot 230
1 Richard MacCutchan 185
2 Zoltán Zörgő 160
3 Richard Deeming 145
4 Sergey Alexandrovich Kryukov 145
0 Sergey Alexandrovich Kryukov 9,353
1 OriginalGriff 6,881
2 Peter Leow 4,537
3 Zoltán Zörgő 4,009
4 Richard MacCutchan 2,882


Advertise | Privacy | Mobile
Web03 | 2.8.150129.1 | Last Updated 2 Oct 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100