Telly - turn telephone numbers into words

Hans's picture
Mon, 2009-09-14 20:14 by Hans

Telly

Table of contents

for this article

Telly is a computer program that finds real words for telephone numbers that can be typed into a phone instead of the number and that may be easier to remember. It currently covers two languages—English and German. Try it, you may like it.

Instructions for use

  1. Requirements: Telly will run in any modern web browser, but due to browser inefficiencies it may work very slowly on computers with less than 1 GB RAM and in older browsers. JavaScript needs to be enabled.
  2. Open Telly.
  3. Choose the desired language.
  4. Type in your telephone number.
  5. Click on the button or press the return key.
  6. If you don't get an immediate result, wait. Wait some more. If you think your browser is not doing anything, keep waiting. It can take a long time.
  7. If your browser says the script program has been running for too long and asks you to break off, say [No]. Internet Explorer sometimes does that for no good reason.
  8. Enjoy the results, but don't be disappointed if there aren't any good ones. Some numbers simply don't match any nice words.
  9. If you use Internet Explorer, it is better to open a new instance just for Telly, as IE tends to become unresponsive during operations, particularly during the initial dictionary loading. Or, if you want to browse the web while Telly is already working, open a second instance of IE then.

A long number can take an inordinate time, so you may have to break off. You can do that by clicking on your web browser's reload button.

Limitations

  • Telly works in three phases:
    1. Loading and preparing the relevant part of the dictionary. This can be very fast on some browsers or take a few minutes on others. For technical reasons there is no progress indicator. After the dictionary is loaded, you can process as many telephone numbers as you like without having to wait for a complete dictionary reload again. The English dictionary is larger, so it takes more time to load and usually yields more results.
    2. Searching for words. Here you will see a progress bar.
    3. Filtering, sorting, and formatting the final result. Again no progress indicator.

    The time for each step depends greatly on your browser and on your computer's processor speed. The fastest browser in 2009 seems to be the latest version of Firefox, which needs only a few seconds to load the dictionary and to filter the output.

  • There are no letters for the figures 0 and 1, so these have to stay in place.
  • If you enter a long number, finding all word combinations can take a long time. If you run out of patience, just reload the web page by clicking on your browser's reload button. This aborts the processing.
  • Telly knows a lot of words and abbreviations, including some foreign words, so some of its results may not make sense. Just ignore those you don't like.
  • Internet Explorer can be used, but it is slow and shows some strange flaws, so use another browser, if you can. For example, it blocks other IE instances and also Windows Explorer during dictionary loading. It also sometimes issues a wrong warning telling you that a script has taken too much time, when, in fact, it hasn't. To continue, choose No when asked whether you want to abort the script. The program will then continue normally, but may do this again. And it frequently takes an inordinately long time for some operations, for example to change the language, where there is actually no work to do.
  • The dictionaries are not filtered for good or bad language. Ignore the words you don't like.

Progress bar

The progress bar is only shown in phase 2 (see above), while the program is searching for words. It shows two figures, the number of complete conversions and the total number currently being held, which also includes partial conversions waiting for further conversion attempts.

The width of the bar is a hyperbolic function of the second figure.

When the total number shrinks or stays the same, the bar changes its color from violet to yellow.

The final number of results may be smaller than the figures shown in the progress bar, because the results are filtered before they are ultimately put on the screen.

Project history

The idea had been with me for a couple of years already. I saw it as an interesting exercise to check out what JavaScript can do, how it behaves in current web browsers, and how well I could invent a suitable algorithm. In fact there are near-trivial algorithms for this problem, but they are slow. While tuning it, I could increase the speed of the program more than 100-fold.

First I searched for suitable dictionaries. Since I have no inflection engine, I needed large dictionaries that contained the most important inflected versions of the words. I also wanted upper and lower case, so the user can notice names and all-upper-case abbreviations. There are not many suitable dictionaries around, but I found one for English and one for German and reformatted and preprocessed these for my purposes.

Then I wrote the program. The first fully functional version was written in one day.

Finally I polished and rewrote parts of it several times to improve their output quality and performance and added nice display elements, which took a few days.

Web browsers

Over the course of my work I compared the behavior of a few web browsers under the heavy load of Telly.

One of the most unpleasant problems I had to solve is there by design—browsers unavoidably throw a warning dialog to the user when a script program runs for a certain time. Usually the time is 5 seconds, but Internet Explorer throws them after 5,000 statements or lines of code or some such, which makes it difficult to predict and prevent from the JavaScript program itself.

Another problem is that the JavaScript implementations, also by design, do not provide for multi-threading. Even worse, the browser itself becomes unresponsive as long as a JavaScript program runs. Only Opera does this better.

To defeat the browsers, I had to cut the work into time-sliced chunks and give the browser short intervals of free time. The grotesque consequence is that my program could be perfectly multi-threaded, yet the browsers cannot make use of this and force it back into a single thread.

My impression was that I was not working with and using the browser, but fighting them and defending against their undesirable behavior, because they refused, by design, to do what I think they should do.

In short, today's browsers are still a rather poor platform for general cross-platform computing, but they seem to be getting better.

Technical details

Telly is a client-server program system, where most of the actual work is done on the client and only a few key functions on the server. This makes it possible to avoid performance degradation due to many simultaneous users. In fact, Telly scales to thousands of simultaneous users.

The programming language for the client is, of course, JavaScript, the most widespread, underestimated, and misunderstood language of our time. JavaScript is extremely flexible and powerful, and its expressiveness is very hard to beat. JavaScript beats programming languages like Java hands-down in these respects.

The current version of Telly is moderately optimized for speed. It can still take a long time for long numbers though, which is probably unavoidable, because the program lists each combination of partial results, yielding large numbers of results for longer telephone numbers.

The telephone number length is currently arbitrarily limited to 20 characters, the first of which can be a plus sign (+). All other characters beside the plus and digits are automatically removed.

The program now limits itself to as few words as possible in each solution, plus one or two. If, for example, the best result has three words, the program will ignore solutions with more than five words, and if there are enough solutions with three or four words, it will output only these and no five-word solutions.

The limit is currently set as follows. If the best and second-best solutions, judged by the number of words needed, yield more than 256 solutions, only these will be given, otherwise all third-best solutions are also given.

A problem is the long loading time when a language is used for the first time. There is also no progress display on the first loading page, because it is just one command (JSON.parse) that takes a long time, like minutes, on slow browsers, while taking only seconds on Firefox. While this one command is being executed, the browser cannot do anything else, like displaying a progress bar.

The reason is that a significant amount of data has to be put into a JavaScript dictionary object, which is done through a JSON parser. Modern browsers have native JSON support, but only Firefox seems to do it right and has put JSON into the fast native code of the interpreter. The others, including Internet Explorer 8 and Google Chrome, also provide native JSON support, but the performance is like that of Douglas Crockford's JavaScript JSON implementation, json2.js. This gives rise to the strong suspicion that the other browser makers have taken the shortcut of simply implementing JSON in interpreted JavaScript, which is the cheapest, poorest way to go.

This means that you currently may have to wait a minute or more until the program has loaded a language on Internet Explorer or other browsers. Only in Firefox can you currently experience Telly as it should be.

During one session without reload Telly keeps the English and one other dictionary in the browser's memory at the same time. That is why the second use and subsequent uses of the same language can be a lot faster, and you can always switch to and from English quickly, once the dictionaries are loaded.

In fact, Telly is a good stress test of the browser. A good browser will pass muster, while a bad one can be many times slower and even give error messages.

Keywords: Programm Telefonnummer Telefonnummern Nummer Nummern Zahl Zahlen Ziffern deutsch deutsches Wort deutsche Wörter Buchstaben übersetzen umsetzen konvertieren umwandeln phonetisch Handy English figures digit digits letters convert transform phonetic

Discussion

Please participate by adding a new comment or replying to existing comments.

Vote for Telly: