@@ -17,7 +17,7 @@ start.rec.log(text="CharSim")
1717# ###############################################################################
1818# main parameters
1919wide <- TRUE # wide plots showing volumes as rectangles
20- narr.smooth <- TRUE # whether to use narrative smoothing
20+ narr.smooth <- TRUE # whether to use narrative smoothing or cumulative scene-based networks
2121weighted <- TRUE # whether to use the graph weights
2222sc.lim <- NA # limit on the considered scenes (NA for no limit)
2323pub.order <- TRUE # whether to use the volume publication vs. story order
@@ -98,26 +98,26 @@ tlog(0,"Evolution of similarity between pairs of characters")
9898
9999# similarity measures
100100sim.meas <- list ()
101- # sim.meas[["cosine"]] <- list(
102- # bounds=c(0,1),
103- # cname="Cosine Similarity",
104- # foo=function(a,idx) {sapply(1:nrow(idx), function(r) sum(a[idx[r,1],]*a[idx[r,2],])/sqrt(sum(a[idx[r,1],]^2)*sum(a[idx[r,2],]^2)))}
105- # )
106- # sim.meas[["pearson"]] <- list(
107- # bounds=c(-1,1),
108- # cname="Pearson Coefficient",
109- # foo=function(a,idx) {sapply(1:nrow(idx), function(r) cor(x=a[idx[r,1],], y=a[idx[r,2],]))}
110- # )
111- # sim.meas[["euclidean"]] <- list(
112- # bounds=c(0,NA),
113- # cname="Euclidean Distance",
114- # foo=function(a,idx) {sapply(1:nrow(idx), function(r) sqrt(sum((a[idx[r,1],]-a[idx[r,2],])^2)))}
115- # )
116- sim.meas [[" regequiv" ]] <- list (
101+ sim.meas [[" cosine" ]] <- list (
102+ bounds = c(0 ,1 ),
103+ cname = " Cosine Similarity" ,
104+ foo = function (a ,idx ) {sapply(1 : nrow(idx ), function (r ) sum(a [idx [r ,1 ],]* a [idx [r ,2 ],])/ sqrt(sum(a [idx [r ,1 ],]^ 2 )* sum(a [idx [r ,2 ],]^ 2 )))}
105+ )
106+ sim.meas [[" pearson" ]] <- list (
107+ bounds = c(- 1 ,1 ),
108+ cname = " Pearson Coefficient" ,
109+ foo = function (a ,idx ) {sapply(1 : nrow(idx ), function (r ) cor(x = a [idx [r ,1 ],], y = a [idx [r ,2 ],]))}
110+ )
111+ sim.meas [[" euclidean" ]] <- list (
117112 bounds = c(0 ,NA ),
118- cname = " Regular Equivalence " ,
119- foo = function (a ,idx ) {tmp <- REGE.for( M = a , E = 0 ) $ E ; sapply(1 : nrow(idx ), function (r ) tmp [idx [r ,1 ],idx [r ,2 ]] )}
113+ cname = " Euclidean Distance " ,
114+ foo = function (a ,idx ) {sapply(1 : nrow(idx ), function (r ) sqrt(sum(( a [idx [r ,1 ],] - a [ idx [r ,2 ],]) ^ 2 )) )}
120115)
116+ # sim.meas[["regequiv"]] <- list(
117+ # bounds=c(0,NA),
118+ # cname="Regular Equivalence",
119+ # foo=function(a,idx) {tmp <- REGE.for(M=a,E=0)$E; sapply(1:nrow(idx), function(r) tmp[idx[r,1],idx[r,2]])}
120+ # )
121121
122122# plot parameters
123123pal <- ATT_COLORS_FILT
0 commit comments