1
0
mirror of https://github.com/balkian/SOJA.git synced 2025-09-02 19:32:21 +00:00

Added socket.io PoC

This commit is contained in:
J.Fernando Sánchez
2012-03-22 19:51:10 +01:00
parent 8a517c87a0
commit e725d7a733
64 changed files with 522 additions and 63 deletions

1
bin/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
classes

View File

@@ -5,18 +5,18 @@
This file was generated by Jason 1.3.6a
http://jason.sf.net
March 20, 2012 - 16:30:55
March 22, 2012 - 19:46:25
-->
<project name ="web40sojason"
basedir=".."
default="run">
<property name="mas2j.project.file" value="Web40SOJason.mas2j"/>
<property name="mas2j.project.file" value="testSocket.mas2j"/>
<property name="debug" value=""/> <!-- use "-debug" to run in debug mode -->
<property name="build.dir" value="${basedir}/bin/classes" />
<property name="jasonJar" value="/home/miguel/trabajo/Jason-1.3.6a/lib/jason.jar"/>
<property name="jasonJar" value="/media/Data/Programs/eclipse/./lib/jason.jar"/>
<path id="project.classpath">
<pathelement location="${basedir}"/>
@@ -73,10 +73,10 @@
<copy todir="${basedir}/${ant.project.name}-jws" failonerror="no">
<fileset dir="${basedir}/lib" includes="**/*.jar" />
<fileset dir="${basedir}" includes="${ant.project.name}.jar" />
<fileset dir="/home/miguel/trabajo/Jason-1.3.6a/src/images" includes="Jason-GMoreau-Icon.jpg" />
<fileset dir="/media/Data/Programs/eclipse/./src/images" includes="Jason-GMoreau-Icon.jpg" />
</copy>
<signjar jar="${basedir}/${ant.project.name}-jws/${ant.project.name}.jar" alias="jason"
storepass="rbjhja" keypass="rbjhja" keystore="/home/miguel/trabajo/Jason-1.3.6a/src/jasonKeystore" />
storepass="rbjhja" keypass="rbjhja" keystore="/media/Data/Programs/eclipse/./src/jasonKeystore" />
<echo message="**" />
<echo message="** Java Web Start application created in directory ${ant.project.name}-jws" />
<echo message="** Update the codebase (in the second line of the .jnlp file)" />

8
bin/commonSenseAgent.asl Normal file
View File

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

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

40
bin/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)).

12
bin/testAgent.asl Normal file
View File

@@ -0,0 +1,12 @@
// Agent testAgent in project Web40 - For socket.io
!start.
/* Wait for service introduction (temporal plan, to erase) */
+!start : true
<- +have(started);
.print("Hola");
.wait(1000);
sendSocket("test","hola").
+success(yes): true
<- .print("Succes!!!!!").

60
bin/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
bin/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)).