Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

[REBOL] LFReD Scripting Basic Info and Examples

From: terry::depotcity::com at: 21-Feb-2001 3:35

Creating Natural Language interfaces for your projects is easy using LFReD. Below is a brief outline on how to script. Please post your sample scripts so I can plug 'em in. Then try them out by speaking with LFReD at http://www.lfred.com My goal to create a large list of predicates and synonyms, as well as a knowledge base of various user defined topics. LFReD SCRIPT in a NUTSHELL nutshell: [ " nutshell " " condensed " " brief " " concise " " to the point " " summary "] FS 'NUTSHELL Words are symbols. Symbols have a particular meaning or meanings. The symbol "toaster" represents that object in the kitchen that heats up bread to a point that it becomes brown. The symbol "tostadora" means the same thing, but only to those that understand Spanish word-symbols. To emphasize the point lets agree that the following symbols have these values or meanings... " > " means "a nose" " P " means "LFReD" and " # " means "does not possess". It is easy to understand the following statement... P # > A basic understanding of language is necessary to write the scripts... Sentence facts. A. There are only 3 types of sentences in any form of language. 1. Declaration - "I have a green apple" 2. Query - "What color is the apple?" 3. Command - "Get me a green apple?" (The following sentence is a declaration...) By listening to any conversation, you can easily classify each sentence into one of those categories. B. Every sentence consists of a "subject" and a "predicate". 1. "I have a green apple" - Subject is "I", Predicate is "possesses a green apple" 2. "What color is the apple?" - Subject is "Apple", Predicate is "what color" 3. "Get me a greeen apple" - Subject is "Me", Predicate is "obtain and deliver a green apple to" Synonyms Synonyms are word-symbols that have the same (general) meaning. To create the NL for LFRed we first create any and all synonyms using the following format... apples: [" apple " " Macintosh " " Granny Smith " " Golden Delicious " " manzana"] FS 'APPLES ;Note manzana is Spanish for apple.. The FS function must follow the list's of synonyms. Synons need the white space on both ends. Otherwise "apple" could be read as "apple-cider". Of course, this could be useful as in " appl" for "apple" "apples" or "applications". color: [ " color " " shade " " hue " " tinge "] FS 'COLOR what: [ " what " " que "] FS 'WHAT We then use LFReD's "the-funk" function to process the sentence... the-funk: [a b c d] (d: is the output you wish to say if the criteria is met) the-funk what color apple "The apple is green" Note: Use a set of quotes with one space ( " " )for unused (a b and c) inputs. This will answer the following questions... What hue is the Macintosh What color is the apple What shade are the Granny Smith apples? Can you tell me what color I would expect to find when I open your box of Golden Delicious apples? Hello, I was wondering if granny smith apples are red in color? Que color es la manzanas and many others... But it won't answer... Where are the green macintosh apples? ... completely different predicate. To answer this query you could create the following... where: [" where " " donde "] ;---"Donde", Spanish for "where". FS 'WHERE colors: [" red " " green " " orange " " yellow " " pink " " blue " " rojo "] FS 'COLORS the-funk where colors apples "The colored apples are in the corner." Which would answer... ?Donde esta la rojo manzanas? Where are the yellow Golden Delicious? Where is a good place to put the green granny smith apples? Here is one more example. who: [" who " " quien "] FS 'WHO creator: [" creator " " program" " maker " " made " " created " " script" " author " " builder " " built " " father " " inventor "] FS 'CREATOR rebol: [" rebol " " command " " core " " view "] FS 'REBOL the-funk who creator rebol "Carl Sassenrath is the founder of Rebol and created etc etc." FRAMER http://www.rebol.com/about.html (The FRAMER function will pop the trailing url into the frame when the criteria is met.) Of course, these are simple examples. There is much greater control over predicates and the such. Also the data can be handled in infinite ways. If your interested in learning more, please contact me at [info--orionalliance--com] Thank you, Terry Brownell