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