Re: assertion to English conversion?

Hans Chalupsky <[email protected]>
Newsgroups gmane.comp.ai.powerloom
Message-ID <[email protected]>
>>>>> Joshua N Pritikin <Joshua> writes:

> On Mon, Oct 20, 2003 at 12:45:52PM -0700, Hans Chalupsky wrote:
>> There is no standard PowerLoom mechanism yet to do this.  The `lexeme'
>> and `phrase' assertions in pl-kernel-kb.ste are only some initial
>> steps towards a capability like this.  NL-rendering is fairly easy for
>> most ground assertions such as `(father-of frank joe)' (you could
>> easily write this yourself if you really need it).

> Hrm, that would probably be sufficient for my purposes.
> I just want something which is potentially as expressive
> as KM (U-Texas Knowledge Machine).

> Is there a way to compute the substitutions in the
> phrase relation?  If not, can you sketch how I can
> code this?

You'd have to use PLI function calls as shown below to perform the
proper string substitutions in the phrase string.  Here it goes -
first we generate the necessary KB definitions:

|= (in-module "PL-USER")

|= (clear-module "PL-USER")

|= (defrelation father-of (?child ?father)
     ;; Here I deviated from using the variable syntax for `phrase' and
     ;; instead used positional arguments which it easier to code this:
     :phrase "#2 is the father of #1"
     ;; I used a single valued relation instead of defining this
     ;; as a function, since looking up function proposition objects
     ;; via PLI is a bit tricky - send me mail (off list) if you need to:
     :single-valued true)

|r|FATHER-OF

;; this works around yet another deficiency of PLI which will go away
;; hopefully soon - without this call (or running a standard query first)
;; the assertions in the above definition won't be expanded - this
;; happens on demand but PLI functions don't yet trigger it automatically:
|= (process-definitions)

|= stop

Bye.

()
;; Now we run Lisp code that given a proposition object looks up its
;; relation and the relation's phrase and substitutes the arguments;
;; this should also give you an idea of how to write this in Java or
;; C++ if that's what you prefer:

CL-USER(65): (let* ((module (pli:get-module "PL-USER" stella::null))
                    (environment stella::null)
                    (prop
                     ;; generate a proposition object from a string:
                     (pli:get-nth-value
                      (pli:consify
                       (pli:s-conceive "(FATHER-OF JOE BILL)"
                                       "PL-USER"
                                       environment))
                      0))
                    ;; access the predicate object:
                    (predicate (pli:get-predicate prop))
                    ;; access the phrase string of the predicate:
                    (result
                     (pli:get-nth-string
                      (pli:get-nth-value
                       (pli:consify
                        (pli:get-binary-propositions
                         (pli:get-object "PHRASE" module environment)
                         predicate
                         stella::null module environment))
                       0)
                      2)))
               ;; substitute the arguments (this could additionally look
               ;; for `lexeme' values and substitute those:
               (loop for i from 1 to 2
                   do (setq result
                        (stella::replace-substrings
                         result
                         (pli:object-to-string (pli:get-nth-value prop i))
                         (format nil "#~d" i))))
               result)
"BILL is the father of JOE"  ;; ta da
CL-USER(66): 


So, this is a bit more than the sketch you asked for.  The reason why
this isn't built in yet is that we still need to decide on better
names for `phrase' or `lexeme' (most of our time we spend thinking
about names :-), whether they should also take a language argument,
and various other details.  Unfortunately, it's always a lot easier to
hack something up than to provide a nice, clean and general API to it.

Hans

--------------------------------------------------------------------------
PowerLoom home page:                 http://www.isi.edu/isd/LOOM/PowerLoom
PowerLoom forum:                                   [email protected]
PowerLoom request line:                      [email protected]
STELLA home page:                       http://www.isi.edu/isd/LOOM/Stella
--------------------------------------------------------------------------
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.