Sunday, October 30, 2011

Wednesday, October 5, 2011

If a programming language was a boat

I saw this article in a programming forum and I found it nice and accurate in describing programming languages and shows us the difference between them in a simple way, so I copied it here for you.

Java
Java is a cargo ship. It’s very bulky. It’s very enterprisey. Though it can also carry a lot of weight. Will carry a project, but not very fun to drive.



Perl
Perl is a tugboat. Powerful enough to tug Java around, in 80 characters or less.



Ruby
Ruby is difficult to describe. It’s sleek, sexy, and very fun to drive. Here’s a picture. Very trendy.



PHP
PHP is a bamboo raft. A series of hacks held together by string. Still keeps afloat though.



C
C is a nuclear submarine. The instructions are probably in a foreign language, but all of the hardware itself is optimized for performance.



C-sharp
Like a luxury cruiser. Sleek, good looking and quite comfy. However, not very fast , expensive and somewhat limiting.



Visual Basic

As time went on you realized it was completely bloody useless.



HTML

HTML isn’t really a programming language boat.



Python
Undeniably beautiful and elegant in the water, tends to be solid and reliable. Will work with little intervention, but also provides sails to help you go that little bit faster.



Javascript

Like James Bond Q Boat. It’s small but powerful and it’s really easy to get yourself killed trying to use it.



FORTRAN77

A concrete boat that still lurkes under the surface. You wouldn’t want to set sail with it though. Try navigating around it.



Monday, September 19, 2011

htkdict load error in Julius

some people met this error while trying to operate julius 4.1.x

Error: voca_load_htkdict: the line content was: DECORATE [DECORATE] d eh k er ey t sp
Error: voca_load_htkdict: line 3118: triphone "ax-d+sp" not found
Error: voca_load_htkdict: line 3118: triphone "d-sp+*" or biphone "d-sp" not found
Error: voca_load_htkdict: the line content was: DECORATED [DECORATED] d eh k er ey dx ax d sp
Error: voca_load_htkdict: line 3119: triphone "iy-s+sp" not found
Error: voca_load_htkdict: line 3119: triphone "s-sp+*" or biphone "s-sp" not found
Error: voca_load_htkdict: the line content was: DECREASE [DECREASE] d ix k r iy s sp
Error: voca_load_htkdict: line 3120: triphone "ax-z+sp" not found
Error: voca_load_htkdict: line 3120: triphone "z-sp+*" or biphone "z-sp" not found
Error: voca_load_htkdict: the line content was: DECREASES [DECREASES] d ix k r iy s ax z sp
Error: voca_load_htkdict: line 3121: triphone "ix-ng+sp" not found
Error: voca_load_htkdict: line 3121: triphone "ng-sp+*" or biphone "ng-sp" not found
Error: voca_load_htkdict: the line content was: DECREASING [DECREASING] d ix k r iy s ix ng sp
Error: voca_load_htkdict: line 3122: triphone "r-iy+sp" not found
Error: voca_load_htkdict: line 3122: triphone "iy-sp+*" or biphone "iy-sp" not found

and so on ( the error is sill long)
************************************

Error reason:
julius optput these messages when your word dictionary contains words that are not trained in the Acoustic Model because the "voca_load_htkdict.c" tries to match the triphones in dict file with the triphone list in Acoustic Model, so when it does not find it, it shows this error and stops the program.

Possible error solutions:
1. enable -forcedict option or uncomment it jconf file to Skip error words in dictionary and force running.
or..
2. map the "not found triphone" to the most close physical triphone in hmmlist file "tiedlist".
for example:
b-ey+t v-eh+t
The first column is the name of triphone (generated from your dictionary), and the second column is the name of the HMM actually defined in your AM.

but this solution can be done if the "not found triphones" are little not too many.

3. the best solution is to not to include words in your dict file that are not in the A.M
note that the first two solutions are for testing julius only because for production or comercial projects you must train the acoustic model and language model with the same corpus.

How software is produced

this is how software is produced from what the user wanted and what is really done, I found it while crawling in the net.
and believe me, as a developer .. I can say that this is really true :D


Monday, June 27, 2011

Function calls in Julius ASR

That's what I was feeling when I began to develop and modify in Julius code (an open source ASR system implemented by C language by a brilliant Japanese person).


When to use static nested classes?

It may be confusing at first that, which one to use when using nested classes? static nested classes or inner classes? and in this article I will answer this question for you.

first:
the use of terms:
A nested class is a class which is contained in another class at the source code level.
If you declare it with the static modifier, then its name is static nested class.
A non-static nested class is called inner class.

second:
the key differences between static nested classes and inner classes
static nested classes:
1. They do not have access to the fields and methods of the enclosing class.
2. they can be instantiated without a corresponding instance of the outer class.
inner classes:
1. inner class has an implicit reference to the enclosing class, so they have access to the fields and methods of the enclosing class even if they are declared private.
2. they cannot be instantiated without a corresponding instance of the outer class.

third:
when to use nested classes in general?
if you just want to keep your classes together if they belong typically together or if you need a class that do some functionality that is exclusively related to the outer class, The nesting creates a type of namespace. To denote a nested class from outside its enclosing class, the nested class is prefixed with the name of the enclosing class.

when to use static vs non static?
from an OO design point of view you decide which one to use depending on whether you want your nested class to have access to enclosing class members or no, so ask yourself, does your nested class need that access?
it is a better idea if you are using a nested class is to start off with it being static, and then decide if it really needs to be non-static based on your usage.

to fully understand the decision rule we can see a practical and real example that is in LinkedList class
note my comments beside the code.


public class LinkedList
{
transient int size = 0;

transient Node first; /*LinkedList consists of Nodes so we made it as nested class*/
transient Node last;
...

private class ListItr implements ListIterator { /* ListItr needs access to outer class members to iterate through them, it needs access to size, first and last members, so we made it inner class*/
private Node lastReturned = null;
private Node next;
private int nextIndex;
private int expectedModCount = modCount;
...
}

private static class Node { /*Node do not need access to the outer class members so it is declared as static, Node is the basic unit that consist the LinkedList*/
E item;
Node next;
Node prev;
...
}

} //outer class end

references:
Sybex SCJP for Java platform SE6, Richard F. Raposa
http://stackoverflow.com/questions/70324/java-inner-class-and-static-nested-class
http://stackoverflow.com/questions/253492/static-nested-class-in-java-why
http://www.javaworld.com/javaworld/javaqa/1999-08/01-qa-static2.html
http://www.javaworld.com/javaworld/javaqa/1999-08/01-qa-static2.html