I am continuing to study sentence parsing in Dr.
Dougherty's book, but my current progress is more in the area of semantics.
I am making some good progress at taking a verb, direct object, and a modifier
and determining the command that fits the concept so expressed. I
am, of course, implementing this in Prolog. My concept is still in the
test phase, so my source code deals with only about
5 commands and their English equivalents.
I intend to parse imperative sentences of the basic
form [Verb], [Determiner], [Direct Object]. Obviously the parser
will wade through more words than that, but those words should be sufficient
to derive meaning. The "command" statements
provide the information to match these words to Linux commands.
But merely matching one sentence to a command is
no better than complex aliasing. That is one problem with commercially
available speech recognition software. While editing using Dragon
software, the user must know exactly what command to issue. That
is speech recognition, but it is not Natural Language Processing.
That is not a serious step forward in user interface design.
My current solution to the problem is through a
set of synonyms. The "synonym" statements
in the source code list some pairs of synonyms. The "issyn"
statements introduce some rules to put the various synonyms together.
They introduce the reflexive, commutative, and transitive properties to
the synonym list. The transitive property is not nearly as strong
as it should be, because I haven't mastered recursion in Prolog.
If any chain of pairs of synonyms implies another pair, that pair should
be recognized. But going through any number of items requires recursion,
and my attempts at recursion have been yielding infinite loops. The
"thecomm" statement combines the functionality of
the other statements and allows the user to find commands to fit sentences.
The compiled version of this program is now on csunix
in the /home/dwils865/499 directory. The name of the program is syn2.
If you want to see how it works, try queries such as the following:
issyn(list,print).
issyn(hello,hello).
thecomm(C,show,all,files).
thecomm(C,display,my,environment).
When finished, press cntl-D.
In the next week I will continue working on parsing
the syntax. That's looking very technical right now, but I will keep
pushing on. I will also expand the scope of the semantic analysis.
That really needs to launch a great number of programs in response to many
user commands. I will be enlisting the help of some end users to
determine how they would tell the computer what they want to do. Finally,
I will work on tying it all together with some C++ code. That is
an essential part of any successful shell, this one included.
Source Code: syn2.pro
To be compiled with gplc, the gnu Prolog compiler.
/*syn2.pro*/
synonym(list, show).
synonym(list, display).
synonym(show,print).
synonym(directory,folder).
synonym(directory,path).
command(ls, list, Z,files).
command(du, show, used, disk).
command(df, show, free, space).
command(env, show, Z, enivronment).
command(cd, change, Z, directory).
issyn(A,A).
issyn(A,B) :- synonym(B,A).
issyn(A,B) :- synonym(A,B).
issyn(A,B) :- synonym(A,C), synonym(C,B).
issyn(A,B) :- synonym(C,A), synonym(C,B).
issyn(A,B) :- synonym(A,C), synonym(B,C).
issyn(A,B) :- synonym(C,A), synonym(B,C).
thecomm(C,V,D,O) :- command(C,V1,D1,O1),issyn(V,V1),issyn(D,D1),
issyn(O,O1),
write(C).