noun : e.g. manager, weather verb : present/past tense verbs. e.g. allows imp_verb : imperative verb. e.g. send inf_verb : infinitive verb. e.g. go intr_imp_v : imperative intrastitives. e.g. quit pn : proper nouns e.g. 'Adam Cheyer', 'Boston' adj : adjectives. e.g. red, big adv : adverbs. e.g. quickly. Adverbs are presently ignored in resulting ICL expression. prep : preposition. Many preps are already defined but you may additional ones if the current set doesn't meet your needs.
Def should be a list containing the "semantics" and "syntax" of the word, where the semantics is what is generated in the ICL and the syntax are the words that will appear in the sentence.
oaa_AddData(vocabulary(noun, [manager, boss]),[]) who is my boss? --> manager('Adam Cheyer', [], X)
Prepositional attachments, a complicated subject to get right for all cases, are handled in a simplified way, where they are gathered along with adjectives in a parameter list. This defers the interpretation to the implementer of the predicate.
eg: find all cheap hotels with a pool --> oaa_Solve(hotels([cheap, with(pool), X), [strategy(query)])
A large "show" grammar is included as part of the imperative and query sentence types. This accepts a number of sentences expressed with common prefixes such as:
I'm interested in knowing more about XXXX. Tell me about XXX? Can you please tell me XXX?As demonstrated by the example above (find all hotels), queries and imperatives try to map into the same representation:
Find the manager of adam cheyer. Who is the manager of adam cheyer. Can you tell me who the manager of adam cheyer is? all produce: oaa_Solve(manager('Adam Cheyer', [], X), [strategy(query)])
The general ICL structures generated are in the form:
verb(+DirectObject, +ParamList) e.g. send mail to Bill --> send(mail, [to(bill)]) noun(+DirectObject, +ParamList, -ResultVar) e.g. Find the manager of adam. --> manager(adam,[], Manager)
Parameter lists contain adjectives and prepositional phrases, and are included even if empty to simplify writing the predicates.
When working with large databases and such, it is often prohibitive to have to declare then entire contents of the database as vocabulary words. In an attempt to handle this problem, DCG_NL will try to "guess" the type of unknown words, and if an unknown one or two word sequence could be a proper name, the PN type will be used.
Send mail to Kachru Ravinder. What is the weather in Bosnia?
These sentences will parse without even though "Bosnia" and "Kachru Ravinder" are not defined as vocabulary words. Although the strategies used work in many cases, be warned that unexpected results may occur. To turn off word guessing, call the solvable nl_to_icl() with the parameter guess(false).
DCG-NL's syntactic rules can be extended by defining solvables for nl_sentence_ext and nl_translate_ext for a particular domain.
Find a hotel that serves breakfast. find the hotel where karen is. Send the message adam cheyer sent to karen to robot one.
Find a hotel for less than ten dollars within two miles of downtown.
Find a cheap good hotel.
Mail arrives. Karen manages Bill. Karen is cheap. The manager ran.
a) AUX STATEMENT Will mail arrive? Does Karen manage Bill? b) WH VP Who manages Bill? Who sent the mail? Who sent the mail to Bill? Who arrived? c) WH AUX STATEMENT Where will the mail arrive? When will the mail arrive? Who is the manager of Bill? Who is Bill's manager? What is the time? Which hotel is Bill at? Who does Bill manage?
Move the hotel. Move the hotel there. Robot one, move the hotel to there. % Find/show sentences are now actually queries... Find the chepeast hotel within two miles of downtown. Find a hotel between downtown and chinatown. Find all hotels for less than ten dollars. Find a hotel between ten and twenty dollars. Find all mail from karen about "security". Find all mail from karen about security.
If mail arrives for me, send it to Karen. Whenever news exists in "ba.jobs" get it to Karen.
Version: 2.0
Language: Prolog (Text-based, UNIX)