If I type what time is it, my computer does the conversion to computer speak. This is similar to any interpreter who needs to know both languages in order to translate from common usage to Un33ks speak.
This is an example of level one abstraction of using common sentences to interface the system. The code itself is odd, but the result is not. I could name the executable anything, but in this case I called it Dude. So if I type:
Dude what time is it
I will get the time. It is just a game to play with words and shell. I decided that I could just as well make a C program that took a list of sentences and created the shell script as you see it here. The list would simply be an implied if association. This way I could write a list of question and response pairs as they would be typed and generate the shell script without even knowing that the C program was doing the conversion in C l33t speak and the shell was running shell speak. So I could have a file that I edit which contains the definition and it could compile every time I use it. As an extension thought, I could do Google for common questions and see whether it has a hit to see if it makes sense and do a silly AI that just found the sentence and then took links where it existed and parroted one of the responses at random.
if [ $1 == "what" ];then if [ $2 == "time" ]; then if [ $3 == "is" ]; then if [ $4 == "it" ]; then echo UTC is `date -u`;fi;fi else if [ $2 == "day" ]; then if [ $3 == "is" ]; then if [ $4 == "it" ]; then echo "Today is " `date`;fi;fi;fi;fi;fi if [ $1 == "am" ];then if [ $2 == "i" ]; then if [ $3 == "drunk?" ]; then echo Yes you are;fi;fi;fi
This is also how I could make a streaming English converter to a format that the gcc compiler would accept, but mostly it is an idea I had to see how quickly I could take an English sentence and use that as an interface to the system instead of all the symbols that seem to be required when being initiated to Unix. I think it is an unnecessary hurdle in the same way that the use of Latin is an extra layer of abstraction which may make the Doctor sound cool, but a bone is a bone and bones is ossa. I suppose the doctor would never get any patients if he said finger tips instead of the distal phalanges.
It does lose some of the character when done that way, but then a character is an actor and an actor is a deception. I think people like their delusions because it is entertaining and that is fine, I prefer my whiskey without an umbrella.
As far as the third query and response "Am I drunk", the answer is always yes, because a sober person wouldn't ask that question.
The program has some serious practical applications for me when combined with other things like the speech recognizer in video conversion. By using Google to take a string of words and determine how common they are, I can use that information to correct the misinterpreted transcription of MIT lectures. It would be a suggestion that perhaps the sequence was wrong, and depending on whether it was applied as the correction it could be determined if this was an effective method.
I think it is practical application and it could be named anything. So I can type in English and the computer can ask like the old Dr. Sabaitso except it would make sense more often. So I named my file "Dr".
motey@motey-desktop:~$ Dr what time is it UTC is Thu Mar 4 16:16:09 UTC 2010 motey@motey-desktop:~$
0 comments:
Post a Comment