%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Similarity
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

/*******************************************************************************
En la parte de Atributos, se creara una funcion para cada valor de Penalty
0..1 --> Valor de Penalizacion constante para todos los posibles cambios
2    --> Se usa archivo propio de debugFuzzyXPath, similarity.pl
3    --> Usamos WorNet, para encontrar similaridad...
4    --> Archivo de similaridad señalado por el usuario
********************************************************************************/

/*

EE = Encontrados
ES = si si encuentra, entonces se suma 1 a EE y se pasa en EE
Label1 = Label de la Consulta
Label2 = label del XML
2,3,..10 = tipo de Penalizacion
type = si es atributo es igual a @
EE = Encontrados hasta el momento
ES = Encontrados con el actual
LabelF = Label resultante
*/

simG(Label1, Label2, Type, tv(Similarity, [tag(LabelF), [Label1=Label2]])):-
	            chainOrder(Label1, Label2, LaMe, LaMa), sim(LaMe, LaMa, Similarity), concat(Type,Label2, LabelF),!.
simG(Label1, Label2, Type, tv(Similarity, [tag(LabelF), [Label1=Label2]])):-
                    chainOrder(Label1, Label2, LaMe, LaMa), simWN(LaMe, LaMa, Similarity), concat(Type,Label2, LabelF),!.
simG(Label1, Label2, Type, tv(Similarity, [tag(LabelF), [Label1=Label2]])):-
	            chainOrder(Label1, Label2, LaMe, LaMa), simUS(LaMe, LaMa, Similarity), concat(Type,Label2, LabelF), !.
simG(Label1, Label2, Type, tv(Similarity, [tag(LabelF),[]])):-
                    chainOrder(Label1, Label2, LaMe, LaMa), simEqual(LaMe, LaMa, Similarity), concat(Type,Label2, LabelF), !.

simG(_,_, _, tv(0.0,[[tag(noExist),[]],[],[]])):-!. % Cuando no encuentra nada

/*
pondemos todo en uno, para no hacer el chain order varias veces.
simi(Label1, Label2, Similarity):- sim
	            chainOrder(Label1, Label2, LaMe, LaMa), sim(LaMe, LaMa, Similarity), concat(Type,Label2, LabelF),!.
*/

% Deben de ser iguales.
simEqual(X,X,1.0):-!.

% Ponemos un conjunto de hechos, para denorar similaridades.
%sim (Tag_Original_de_busqueda, Tag_reemplazo, TV de relacion)
sim(around,close_to,0.8).
sim(author, writer, 0.8).
sim(beside,close_to,0.7).
sim(bib, library, 0.9).
sim(book, books, 0.9).
sim(book, novel, 0.8).
sim(book, paper, 0.8).
sim(charge,price,0.8).
sim(close_to,near,0.9).
sim(close_to,nigh,0.6).
sim(cost,price,0.9).
sim(date,year,0.9).
sim(hostal,hotel,0.8).
sim(hotel,guesthouse,0.6).
sim(lido,pool,0.8).
sim(metro,subway,0.7).
sim(metro,underground,0.8).
sim(name,title,0.9).
sim(price,valuation,0.6).
sim(publication,publishing,0.5).
sim(publication,release,0.7).
sim(subtitle, title, 0.2).

%%	WorNet
simWN(publication,release,0.7).
simWN(subtitle, title, 0.2).

%%	Archivo del Usuario
simUS(publication,release,0.7).
simUS(subtitle, title, 0.2).













