1
0
mirror of https://github.com/balkian/SOJA.git synced 2025-09-03 11:52:20 +00:00

Initial commit

This commit is contained in:
Miguel Coronado
2012-03-20 17:16:44 +01:00
commit 0017e5efda
41 changed files with 2223 additions and 0 deletions

View File

@@ -0,0 +1,8 @@
// Agent userAgent in project Web40
/* Initial beliefs and rules */
/* Initial goals */
/* Plans */

40
src/asl/nluAgent.asl Normal file
View File

@@ -0,0 +1,40 @@
// Agent nluAgent in project Web40SOJason
/* Initial beliefs and rules */
/* Initial goals */
/* Plans */
@in_msg
+user_msg(Msg, Query) : true
<- sendNLU(Query, Msg);
-user_msg(Msg, Query). // clear the memory
/* Tell the user agent what the NLU system understood */
+price(Terms, Price)[query(Query), domain(travel)] : true
<- .send(userAgent, tell, price(Terms, Price)[query(Query)], domain(travel));
.print("Percibido: price ",Terms, " ", Price ).
+date(Terms, Day, Month, Year)[query(Query), domain(travel)] : true
<- .send(userAgent, tell, date(Terms, Day, Month, Year)[query(Query), domain(travel)]);
.print("Percibido: date ",Terms, " ", Day, " ", Month, " ", Year).
+time(Terms, Hours, Minutes)[query(Query), domain(travel)] : true
<- .send(userAgent, tell, time(Terms, Hours, Minutes)[query(Query), domain(travel)]);
.print("Percibido: time ",Terms, " ", Hours, " ", Minutes).
+location(Terms, Place)[query(Query), domain(travel)] : true
<- .send(userAgent, tell, location(Terms, Place)[query(Query), domain(travel)]);
.print("Percibido: location ",Terms, " ", Place).
+type(Terms)[query(Query), domain(travel)] : true
<- .send(userAgent, tell, type(Terms)[query(Query), domain(travel)]);
.print("Percibido: type ",Terms).
@sendFindTravel
+done[query(Query), domain(Domain)] : true
<- .wait(1000); // wait until all other information is sent
.print("Percepcion completada");
.send(userAgent, achieve, find(Domain, Query)).

60
src/asl/travelAgent.asl Normal file
View File

@@ -0,0 +1,60 @@
// Agent travelAgent in project Web40
/* Initial beliefs and rules */
canFindTravel(Query)
:- location(from,_)[query(Query)] &
location(to,_)[query(Query)] &
date(departure,_,_,_)[query(Query)].
/* Initial goals */
contact(userAgent).
my_service(travel).
my_service(train).
/************** Plans *****************/
/* Introduce myself to the user agent */
@introduce_myself
+my_service(Domain)
: contact(Agent) & .my_name(Me)
<- .send(Agent, tell, service(Me, Domain)).
@introduction_rety
+my_service(Domain) : not contact(Agent)
<- -+my_service(Domain).
/* Find travel plans */
@findTravel1
+!find(travel, Query) : not canFindTravel(Query) & not delay(Query)
<- .print("Not enought data. Lets wait some time");
.wait(3000);
+delay(Query);
!find(travel, Query).
@findTravel2
+!find(travel, Query) : not canFindTravel(Query) & delay(Query)
<- -delay(Query);
.print("Not enought data. Lets ask!").
@findTravel3
+!find(travel, Query) : canFindTravel(Query)
<- ?location(to, To);
?location(from, From);
?date(departure, Day, Month, Year);
findTravel(From, To, Day, Month, Year);
.print("ok").
@findTravelFailureRety
-!find(travel, Query) : not error(Msg, Query)<- !findTravel(Query).
@findTravelFailureError
-!find(travel, Query) : error(Msg, Query)
<- .print("Problema al encontrar viajes:", Msg);
!findTravel(Query).
/* log results */
@log_the_journey
+journey(From, To, Departure, Arrival, Fares) : true
<- .print("Travel found: From ", From,"<", Departure, "> to ", To, "<", Arrival, "> for ", Fares).

56
src/asl/userAgent.asl Normal file
View File

@@ -0,0 +1,56 @@
// Agent userAgent in project Web40
/* Initial beliefs and rules */
new_query(Query) :- .random(R) & Query = (1000*R)+1.
!start.
/* Initial goals */
/******* Plans ***************************/
/* Wait for service introduction (temporal plan, to erase) */
+!start : true
<- .wait(1000);
+user_msg("I want to travel from Madrid to Cuenca in the morning that costs no more than 200€ and dinner in a romantic restaurant").
/* Ask the nlu agent */
+user_msg(Msg) : new_query(Query)
<- .send(nluAgent, tell, user_msg(Msg, Query) ).
/* Log the received data */
+price(Terms, Price)[query(Query), domain(Domain)] : true
<- .print("Percibido: price ",Terms, " ", Price );
+data(price(Terms), Query, Domain).
+date(Terms, Day, Month, Year)[query(Query), domain(Domain)] : true
<- .print("Percibido: date ",Terms, " ", Day, " ", Month, " ", Year);
+data(date(Terms, Day, Month, Year), Query, Domain).
+time(Terms, Hours, Minutes)[query(Query), domain(Domain)] : true
<- .print("Percibido: time ",Terms, " ", Hours, " ", Minutes);
+data(time(Terms, Hours, Minutes), Query, Domain).
+location(Terms, Place)[query(Query), domain(Domain)] : true
<- .print("Percibido: location ",Terms, " ", Place);
+data(location(Terms, Place), Query, Domain).
+type(Terms)[query(Query), domain(Domain)] : true
<- .print("Percibido: type ",Terms).
/* find travel */
/*@find_travel
+!find(travel, Query) : true
<- .println("lets find travel ", Query);
.findall(Name, service(Name, travel), List);
.send(List, achieve, find(travel, Query)).
*/
@do_search
+!find(Domain, Query) : true
<- .print("Perform find ", Domain, " ", Query);
.findall(Name, service(Name, Domain), AgList);
.findall(Atom[query(Query)], data(Atom, Query, Domain), DataList);
.send(AgList, tell, DataList);
.send(AgList, achieve, find(Domain, Query)).