Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

daliirc modifications #41

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 23 additions & 17 deletions src/active_dali_wi.pl
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
set_prolog_flag(discontiguous_warnings,off),
open(FI,read,Stream,[]), read(Stream,Me), close(Stream),
Me \= end_of_file,
agent(File, AgentName, Ontolog, Lang, Fil, Lib, UP, DO, Specialization) = Me,
agent(File, AgentName, Ontolog, Lang, Fil, Lib, UP, DO, Specialization,AgentType) = Me,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

anche qui che succede se uno studente decide di far girare la versione basic? In quel caso i types non sono utilizzati

open('server.txt',read,Stream2,[]),read(Stream2,T),close(Stream2),
if(UP=no, true, assert(user_profile_location(UP))),
if(DO=no,true,assert(dali_onto_location(DO))),
Expand All @@ -104,8 +104,12 @@

delete_agent_files(File),
token(File),
start1(File, AgentName, Lib, Fil).

start1(File, AgentName, Lib, Fil,AgentType).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

idem

replace_substring(String, To_Replace, Replace_With, Result) :-
( append([Front, To_Replace, Back], String)
-> append([Front, Replace_With, Back], Result)
; Result = String
).
load_ontology_file(Ontolog,Agent):-
open(Ontolog,read,Stream,[]),
read(Stream,PrefixesC),
Expand All @@ -119,7 +123,7 @@

filtra_fil(FI):-arg(1,FI,File),token_fil(File),retractall(parentesi(_)),togli_var_fil(File).

start1(Fe,AgentName,Libr,Fil):-
start1(Fe,AgentName,Libr,Fil,AgentType):-
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

idem

set_prolog_flag(discontiguous_warnings,off),
if(Libr=no,true,libreria(Fe,Libr,Fil)),

Expand Down Expand Up @@ -165,9 +169,13 @@
ass_internal_repeat,

ass_stringhe_mul(FilePlv),

open(FilePlv, append, Stream),
atom_concat(' ?-',AgentType,E1),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

idem

atom_concat(E1,'.',E2),
write(Stream, E2),
close(Stream),
compile(FilePlv),

apri_learn(FileTxt),
start_learn,
manage_export_past,
Expand Down Expand Up @@ -227,7 +235,6 @@
repeat,
member(M,L),
spezza(M),

M==U,!,retractall(rule_base(_)), if(clause(mul(_),_),ass_mul_first,true).

examine_mul:-if(clause(mul(_),_),examine1_mul,true).
Expand Down Expand Up @@ -539,7 +546,7 @@

name(F,Lista),append(Lista1,[101],Lista),
append(Lista1,[102],Lista3),name(Plf,Lista3),

see(Plf),
repeat,
read(T),
Expand Down Expand Up @@ -656,7 +663,7 @@



aprifile_en(F):-see(F),
aprifile_en(F):-see(F),
repeat,
read(T),
assert(clause_man(T)),
Expand Down Expand Up @@ -693,7 +700,7 @@
%print('RECEIVED: '),print(message(Ind,Ag,IndM,AgM,Language,Ontology,Con)),nl,
if(clause(receive(Con),_),chiama_con(AgM,IndM,Language,Ontology,Con),not_receivable_meta(AgM,IndM,Language,Ontology,Con)).

chiama_con(AgM,IndM,Language,Ontology,Con):-if(receive(Con),true,not_receivable_message(AgM,IndM,Language,Ontology,Con)).
chiama_con(AgM,IndM,Language,Ontology,Con):-write(Con),if(receive(Con),true,not_receivable_message(AgM,IndM,Language,Ontology,Con)).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a che serve questa write?


%%EDITONTO asserisci_ontologia/2
send_message(E,AgM):-clause(ext_agent(AgM,IndM,Ontology,_),_),
Expand Down Expand Up @@ -953,7 +960,7 @@
fai(X,T,Ag):-functor(X,F,_),if(F=message,em_mess0(X,T,Ag),choose_action(X)),if(F\=message,(ver_az_int(X,T,Ag),!),true).

choose_action(X):-functor(X,F,_),if(member(F,[drop_past,look_up_past,add_past,set_past,callasp]),
take_past_actions(F,X),(print(make(X)),nl)),save_on_log_file(make(X)).
take_past_actions(F,X),(print(make(X)),nl)).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

perché hai tolto il log?


take_past_actions(F,X):-write('Sono in Take_past_actions'),arg(1,X,E),caso0_past(F,E,X).
caso0_past(F,X,Y):-if(F=drop_past,drop_evento(X),caso1_past(F,X,Y)).
Expand Down Expand Up @@ -994,9 +1001,8 @@
%% Azione di invio del messaggio
emetti_ms(To,M,S,IndS,IndTo):-clause(own_language(Lang),_),
invia_terms_ontology(O),
out(message(IndTo,To,IndS,S,Lang,O,M)),
out(message(IndTo,To,IndS,S,Lang,O,M)).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

qui cosa è diverso?

%print(send_message_to(To,M,Lang,O)),nl,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

perché togliere anche qui il log?

save_on_log_file(send_message(M)).

invia_terms_ontology(O):-
clause(agent(Agent),_),
Expand Down Expand Up @@ -1579,7 +1585,7 @@
%APRE IL FILE PLV ED ASSERISCE LE REGOLE PER GLI EVENTI SINGOLI DEGLI EVENTI ESTERNI MULTIPLI
%% e' chiamato dalla "take_meta_var" contenuta in "togli_var.pl"
%% Il file PLV non è vuoto. Contiene cioè che è scritto nel file PL.
aprifile_head_mul(F):-see(F),
aprifile_head_mul(F):- see(F),
repeat,
read(T),expand_term(T,Te),
if(T=end_of_file,true,
Expand Down Expand Up @@ -1685,7 +1691,7 @@



apri_learn(F):-see(F),
apri_learn(F):-see(F),
repeat,
read(T),expand_term(T,Te),
if(T=end_of_file,true,
Expand All @@ -1706,7 +1712,7 @@
format(Stream,"'~p'.",[T]),nl(Stream),
close(Stream),leggi_l(Ag).

leggi_l(Ag):-clause(agent(A),_),see('prova1%13%.txt'),
leggi_l(Ag):-clause(agent(A),_),see('prova1%13%.txt'),
read(T),send_msg_learn(T,A,Ag),
seen, if(file_exists('prova1%13%.txt'),delete_file('prova1%13%.txt'),true).

Expand Down Expand Up @@ -1992,7 +1998,7 @@


save_on_log_file(P):-clause(agent(N),_),
name('log/log_',L0),name(N,L1),name('.txt',L2),
name('Examples/advanced/log/log_',L0),name(N,L1),name('.txt',L2),
append(L0,L1,L01),append(L01,L2,L02),name(Q,L02),
open(Q,append,Stream,[]),
write(Stream,P),nl(Stream),
Expand Down
2 changes: 1 addition & 1 deletion src/communication_onto_utils.pl
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
member(binding([name=Var], Type, Value), BindList),
if(Type=uri,
take_name_uri(Value, NormalizedValue),
if(Type=literal, take_name(Value,NormalizedValue), Value=NormalizedValue) %% ultimo caso significa che c'� un nodo blank.
if(Type=literal, take_name(Value,NormalizedValue), Value=NormalizedValue) %% ultimo caso significa che c'� un nodo blank.
),!.

fetch_ask(Response,Bool):-
Expand Down
2 changes: 1 addition & 1 deletion src/meta1.pl
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@


%CHECK PER PROPOSE
esegui_propose(H,C,Ag):-vere_cond(H,C,Ag).
esegui_propose(H,C,Ag):-write(C),vere_cond(H,C,Ag).
vere_cond(A,Lc,Ag):-Lc=[H|T],functor(H,F,N),current_predicate(F/N),call(H),!,vere_cond(A,T,Ag).
vere_cond(A,Lc,Ag):-Lc=[H|T],evp(H),!,vere_cond(A,T,Ag).
vere_cond(A,[],Ag):-assert((do_propose(A,Ag):-cd(A),asse_cosa(do_action(A,Ag)))),assert(do_action_propose(A,Ag)).
Expand Down
2 changes: 1 addition & 1 deletion src/togli_var.pl
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
%e chiusura file

atom_concat(Infile,'.pl',File),
see(File),
see(File),
leggiChars_var(Txt), !,
seen.

Expand Down
10 changes: 5 additions & 5 deletions src/tokefun.pl
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@


examine_all1(Me):-if(member(Me,['(',')']), conta_parentesi(Me),true),
if(tempo(Me), scrittura(Me), % controlla se � stato inserito il deltat, se si scrivo nel file pl e asserisco time_add
if(tempo(Me), scrittura(Me), % controlla se � stato inserito il deltat, se si scrivo nel file pl e asserisco time_add
(if(variabile(Me),examine_variable(Me),
if(label(Me),examine_label(Me),write_NovarNolabel(Me)))

Expand All @@ -198,17 +198,17 @@
isa_variable(El):-El>64,El<91.
isa_variable(El):-El=95.

%Verifica se � stato inserito il delta Temporale dall'agente
%Verifica se � stato inserito il delta Temporale dall'agente

tempo(Me):- name(Me,L), nth0(0,L,El,L1), El==116, numbertime(L1). %controlla che il primo carattere � una t
numbertime(L1):- nth0(0,L1,El,L_rest),check_number(El), scorri(L_rest). %controlla se il primo elemento della lista � un numero e scorre la lista
tempo(Me):- name(Me,L), nth0(0,L,El,L1), El==116, numbertime(L1). %controlla che il primo carattere � una t
numbertime(L1):- nth0(0,L1,El,L_rest),check_number(El), scorri(L_rest). %controlla se il primo elemento della lista � un numero e scorre la lista
check_number(El):- El>47, El<58. %range in ASCII per i numeri da 0 a 9
scorri(L_rest):-if(L_rest=[],true, scorri_list(L_rest)). %controlla che tutti gli elementi della lista sono numeri
scorri_list(L_rest):- nth0(0,L_rest,X,L2), check_number(X),scorri(L2).
scrittura(Me):- name(Me,L),nth0(0,L,R,L3), append([100,101,108,116,97,116,40],L3,L1), %scrittura sul file pl del deltat inserito dall'agente
append(L1,[41],L2), clause(buffer(Parsed),_), retractall(buffer(_)),
append(Parsed,L2,Parola),assert(buffer(Parola)),
clause(deltaT(X),true),retractall(deltaT(X)),assert(deltaT(1)). %asserisco deltat a 1 in modo tale da sapere che � stato inserito
clause(deltaT(X),true),retractall(deltaT(X)),assert(deltaT(1)). %asserisco deltat a 1 in modo tale da sapere che � stato inserito
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

non capisco qui dove sono le differenze




Expand Down
2 changes: 1 addition & 1 deletion src/utils.pl
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rompe la compatibilità con la versione esempi basic, non posso accettare un path hard-coded

Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
ple_from_name(Name, NameExt):- name(Name,L), append(L,[46,112,108,101],L1), name(NameExt,L1).
plf_from_name(Name, NameExt):- name(Name,L), append(L,[46,112,108,102],L1), name(NameExt,L1).
txt_from_name(Name, NameExt):- name(Name,L), append(L,[46,116,120,116],L1), name(NameExt,L1).
log_from_name(Name, NameExt):- name('log/log_',L0), name(Name,L1), name('.txt',L2), append(L0,L1,L01), append(L01,L2,L02), name(NameExt,L02).
log_from_name(Name, NameExt):- name('Examples/advanced/log/log_',L0), name(Name,L1), name('.txt',L2), append(L0,L1,L01), append(L01,L2,L02), name(NameExt,L02).

%% Eliminates agent files except plf
delete_agent_files(F):-
Expand Down