Click here to Skip to main content
12,697,311 members (28,344 online)
Rate this:
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
Doesn't your common sense tell you the answer? it's pretty obvious... :-)

1 solution

Rate this: bad
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.


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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170118.1 | Last Updated 2 Oct 2012
Copyright © CodeProject, 1999-2017
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