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 website and also a few modules and tutorials on 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 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 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 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!

1 comment: