Friday, May 30, 2014

One year later

One year ago, I published my first web app in HTML and Javascript on this blog. Basically, to get myself started I borrowed heavily from the w3schools.com website and also a few modules and tutorials on codecademy.com. For doing my own experiments, I used the“try it yourself” testing areas in w3schools and I also downloaded Notepad++ when I started feeling more comfortable and wanted to run the code in different browsers to see the results.

The first English-Spanish exercise that I published was based on this w3schools.com prompt() method example and this JS array object example

Here is the original code:

Click the button to demonstrate the prompt box.

At the time I was quite pleased with my Eureka moment because after telling so many friends that I wanted to figure out how to program some language learning apps on the web, I finally had a simple example, albeit it only tested in one direction (English to Spanish) and only had 3 vocabulary words (cat, dog, and house). What made it dynamic was the random number: Math.floor((Math.random()*3)+1). I believe I found that solution on a stackoverflow.com forum about random numbers. Once this worked and I got some feedback from friends who wanted more vocabulary and the possibility to work in the other direction (Spanish to English), the app started to improve little by little. This also explains why after 1 year, there are still only about 10 apps on the blog.

The blog and my coding experience are a work in progress. I still have lots of ideas for things that I would like to develop, but the difficulty with product development is that it leads to lots of testing, debugging, and continual improvements and tweaking. Many of the other apps that I have added have gone through several major improvements and changes, especially as I hit walls with my limited experience or discover some breakthrough that transforms some way of doing something.

What is my favorite concept in coding? Arrays!

For vocabulary, verb conjugations, or sentence structures, most of the content can be stored as arrays. I have done this with Spanish vocabulary and also with Russian vocabulary. I decided to spend more time preparing apps for Russian because as a language learner, I wanted to test some of the exercises on myself to see if they were helpful or instructive, and if not, make the necessary changes. Also, I figured that Russian was a challenge both for programming and for language learning. If I could make it work in Russian, then applying the results to English or Spanish would then seem easier.

For Russian vocabulary arrays, I have even organized them as multidimensional arrays by animacy, gender, and case with number (singular/plural), attributing each dimension a value. animacy (0=inanimate, 1=animate); gender(0=male; 1=neuter; 2=female); case (nominative singular=0, nominative plural=1; accusative singular=2; accusative plural=3; genitive singular=4; genitive plural=5; dative singular=6; dative plural=7; instrumental singular=8; instrumental plural=9; prepositional singular=10; prepositional plural=11). The Russian word for car is машина, which is feminine. So the array slot representing this inanimate feminine noun in the nominative singular would be [0][2][0] =”машина”. For a while, this approach seemed to work when taking into consideration lots of linguistic variables, but when it came to semantics, arrays were not enough.

In theory it is possible to make lots of combinations of adjectives and nouns. Let's consider two adjectives (blue and red) and four nouns (car, table, woman, boy). In total there would be 8 combinations; blue + car or red + table make sense, but blue + woman or red + boy seem a bit absurd. This is not a problem of combinatorial programming, rather it is an inherent trait of semantics. Not all nouns share the same properties. It's ok for objects to have color, but other nouns, like people might not. At first this forced me to limit vocabulary to a strict number of semantically congruent words, but even then there were combinations that I preferred to avoid, but learning to program and filter for exceptions became too complex. An innocent combination like my + wife became an admission of polygamy when switched to the plural: my wives. Luckily, I discovered a solution in the form of JavaScript objects and properties. I was then able to define types of vocabulary words as objects and establish other objects as their properties. I would first create a set of objects called adjectives and their declension as a property, and the translation into another language could also be considered a property. Then I created a new set of objects called nouns with one of their properties being adjectives; later I split this into singular adjectives and plural adjectives. So then it became possible to specify that the noun 'wife' can have a property of 'singular adjective' 'my', but not in the property 'plural adjective' in order to avoid saying 'my wives'. This semantic specification has allowed me to add more vocabulary in a meaningful way. I can also consult frequency lists to see which nouns frequently go with which adjectives. It is also possible to attach a frequency weight to each combination so that more frequent combinations in the language appear more frequently in the program

Currently, my next goal after combining nouns and adjectives is to combine them with verbs in order to generate meaningful sentences and not just bland verb conjugations with subject pronouns. This next step would be able to generate sentences like “my wife plays her guitar” or “the cat jumped onto the bed”. Unfortunately, at the moment I have been attempting this with Russian sentences, but I have not yet found clear spelling/pronunciation rules that modify certain prepositions like (в/во or с/со).

Recently, I have been testing duolingo.com and I have found that with their algorithms and combinations it is quite possible to generate sentences that are not very meaningful or useful for language learners. How useful is it for me to know how to say “il coltello è nello stivale” = “the knife is in the boot” in Italian? I don't imagine telling this to a customs agent upon arrival in Rome.

What are other difficulties? Sound and adapting content to different browsers or platforms I think I've been a bit naive, hoping that HTML5 methods would become universal across browsers and platforms, but currently it is not easy to find a one-size-fits-all solution for using audio. I've had limited success with Safari and mobile Chrome when using the audio() method. Also, when trying to use CSS, I've seen display problems in different versions of Internet Explorer. I've also tried to adapt content to the screen size of mobile devices like cell phones and ipads, but it quickly becomes complex, especially for a novice programmer. I usually take a look at solutions from websites that work well on different platforms by taking a look at their source code, but it isn't always easy to interpret and implement the same solution. There still are lots of things and tricks to learn!

Tuesday, May 6, 2014

Time-Machine

Clock
English What time is it?
Deutsch Wie spät ist es?
Español España ¿Qué hora es?
Español México ¿Qué hora es?
Français Quelle heure est-il?
Italiano Che ora è?
日本語 何時ですか。
Português Brasil Que horas são?
Português Portugal Que horas são?
По-русски Который час?

Select a time: :

Clock
English What time is it?
Deutsch Wie spät ist es?
Español España ¿Qué hora es?
Español México ¿Qué hora es?
Français Quelle heure est-il?
Italiano Che ora è?
日本語 何時ですか。
Português Brasil Que horas são?
Português Portugal Que horas são?
По-русски Который час?

Tested in Safari, click on any of the text above to hear the pronunciation.

Thanks to Lyndon Armitage for his explanation and permission to use his code for making an Analog Clock.


Follow us on facebook and twitter

Links to other exercises/Enlaces a otros ejercicios
Multilingual Talking Calculator/Calculadora que habla en 25 idiomas
- add, subtract, multiply, divide and listen to numbers in 25 languages, also with customizable number dictation.
- suma, resta, multiplica, divide y escucha los números, también con dictado a medida de números.
Multilingual Talking Keyboard/Teclado que habla en 17 idiomas
- write and listen to text in 17 languages using Google Text-to-Speech technology. Currently, for best audio results, use Safari or Apple devices with Safari.
- escribir y escuchar texto con la tecnología auditiva de Google Translate. Para mejor resultos, se recomienda usar Safari o aparatos de Apple con Safari.
English Sentence Generator/Generador de oraciones en inglés
- customizable practice exercise for conjugations of English verbs in the 12 tenses with downloadable progress reports.
- ejercicio a medida de conjugaciones de verbos ingleses en los 12 tiempos con reportes de progreso descargables.
English Verb Conjugator/Conjugador de verbos ingleses
- interactive conjugation table of English verbs and review of auxiliary verbs.
- tabla interactiva de verbos en inglés con revisión de verbos auxiliarios.
English Pronouns, Possessive Adjectives, Contractions/Pronombres, adjetivos posesivos y contracciones en inglés
- review table and simple exercise.
- tabla de revisión y ejercicio sencillo.
Russian Sentence Generator/Generador de oraciones en ruso
- customizable practice exercise for conjugations of Russian verbs (Imperfective/Perfective) in Present, Past, and Future with downloadable progress reports.
- ejercicio a medida de conjugaciones de verbos rusos (imperfectivos/perfectivos) en presente, pasado, futuro con reportes de progreso descargables.
Russian noun and adjective declensions/Declensiones de sustantivos y adjetivos en ruso
- customizable practice for Russian nouns and adjectives in the 6 cases with detailed, downloadable progress reports.
- ejercicio a medida para los sustantivos y adjetivos rusos en los 6 casos con reportes de progreso detallados y descargables.
Spanish-English nouns and determiners/Sustantivos y modificadores en español y inglés
- vocabulary practice trainer of basic words in both languages.
- entrenador de palabras básicas en ambos idiomas.
Text-to-Speech Downloader/Descargador de texto a voz
- listen to the pronunciation of words in 25 languages and download mp3s; best results with Safari.
- escuchar la pronunciación de palabras en 25 idiomas y descargar archivos en formato mp3; mejores resultados con Safari.