Skip to content

Commit 21ea95b

Browse files
committed
fixed a number of minor bugs in the dyn net scripts
1 parent 1cf4b30 commit 21ea95b

File tree

11 files changed

+353
-192
lines changed

11 files changed

+353
-192
lines changed

src/common/_include.R

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,5 +90,6 @@ source("src/static/plot_stats_base.R")
9090
source("src/static/plot_stats_comp.R")
9191

9292
source("src/dynamic/cumulative.R")
93+
source("src/dynamic/evol_prop.R")
9394
source("src/dynamic/instant.R")
9495
source("src/dynamic/narr_smooth.R")

src/common/file_system.R

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ get.path.data.graph <- function(mode, char.det=NA, net.type, order=NA, window.si
175175
# window.size: value for this parameter (ignored for mode="scenes").
176176
# overlap: value for this parameter, specified for of the above parameter value.
177177
# (also ignored for mode="scenes").
178-
# weights: either "occurrences" or "duration" (ignored for mode="window.xxx").
178+
# weights: "occurrences", "duration", "none" (ignored for mode="window.xxx").
179179
# arc: the narrative arc to plot (optional).
180180
# vol: the volume to plot (optional, and ignored if arc is specified).
181181
# filtered: whether this concerns the filtered version of the graph.
@@ -266,7 +266,7 @@ get.path.stat.table <- function(object, mode, char.det=NA, net.type, order=NA, w
266266
# window.size: value for this parameter (ignored for mode="scenes").
267267
# overlap: value for this parameter, specified for of the above parameter value.
268268
# (also ignored for mode="scenes").
269-
# weights: either "occurrences" or "duration" (ignored for mode="window.xxx").
269+
# weights: "occurrences", "duration", "none" (ignored for mode="window.xxx").
270270
# arc: the narrative arc to plot (optional).
271271
# vol: the volume to plot (optional, and ignored if arc is specified).
272272
# filtered: whether this concerns the filtered version of the graph (or NA if not applicable).
@@ -369,7 +369,7 @@ get.path.stats.topo <- function(mode, char.det=NA, net.type, order=NA, att=NA, m
369369
# meas.name: name of the plot measure.
370370
# window.size: value for this parameter.
371371
# overlap: value for this parameter, specified for of the above parameter value.
372-
# weights: value for this parameters, either "duration" or "occurrences".
372+
# weights: value for this parameters ("occurrences", "duration", "none").
373373
# arc: the narrative arc to plot (optional).
374374
# vol: the volume to plot (optional, and ignored if arc is specified).
375375
# filtered: whether this concerns the filtered version of the graph.

src/common/plots/_plot_misc.R

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,23 +17,33 @@ source("src/common/plots/plot_distr.R")
1717
#
1818
# ylim: limits of the y axis in the plot.
1919
# volume.stats: table containing the volume characteristics.
20+
# narr.unit: narrative unit of the x axis (scene or chapter).
2021
###############################################################################
21-
draw.volume.rects <- function(ylim, volume.stats)
22+
draw.volume.rects <- function(ylim, volume.stats, narr.unit)
2223
{# rectangle colors
2324
rec.pal <- c("gray90","gray80")
2425

26+
if(narr.unit=="scene")
27+
{start.col <- COL_SCENE_START_ID
28+
end.col <- COL_SCENE_END_ID
29+
}
30+
else if(narr.unit=="narr.unit")
31+
{start.col <- COL_CHAPTER_START_ID
32+
end.col <- COL_CHAPTER_END_ID
33+
}
34+
2535
# draw each volume
2636
for(v in 1:nrow(volume.stats))
2737
{ rect(
28-
xleft=volume.stats[v,COL_SCENE_START_ID],
29-
xright=volume.stats[v,COL_SCENE_END_ID],
38+
xleft=volume.stats[v,start.col],
39+
xright=volume.stats[v,end.col],
3040
ybottom=ylim[1]-abs(ylim[1])*0.05,
3141
ytop=ylim[2],
3242
col=rec.pal[(v %% 2)+1],
3343
border=NA, density=NA
3444
)
3545
text(
36-
x=(volume.stats[v,COL_SCENE_START_ID]+volume.stats[v,COL_SCENE_END_ID])/2,
46+
x=(volume.stats[v,start.col]+volume.stats[v,end.col])/2,
3747
y=ylim[2],
3848
labels=volume.stats[v,COL_VOLUME],
3949
cex=0.55, adj=c(0.5,1)

src/common/table_cols.R

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ COL_VOLUMES_BY_ARC <- "AvgVolumesByArc" # average number of volumes by arc
3737
COL_CHAPTER <- "Chapter" # chapter number, relative to a (novel) volume
3838
COL_CHAPTER_ID <- "ChapterId"# unique chapter id (overall)
3939
COL_CHAPTERS <- "Chapters"# number of chapters in a volume/arc
40+
COL_CHAPTER_END_ID <- "EndChapterId"# unique id of an end chapter (overall)
41+
COL_CHAPTER_START_ID <- "StartChapterId"# unique id of an start chapter (overall)
4042
# TODO implement stat computation for chapters, which were added afterwards (to handle ASOIAF)
4143

4244

@@ -49,7 +51,7 @@ COL_PAGE_ID <- "PageId" # unique page id (overall)
4951
COL_PAGE_END <- "EndPage"# end page number, relative to a volume
5052
COL_PAGE_END_ID <- "EndPageId"# unique id of an end page (overall)
5153
COL_PAGE_START <- "StartPage"# start page number, relative to a volume
52-
COL_PAGE_START_ID <- "StartPageId"# unique id of an end page (overall)
54+
COL_PAGE_START_ID <- "StartPageId"# unique id of an start page (overall)
5355
COL_PAGES <- "Pages"# number of pages
5456

5557
# page stats

src/dev_ASOIAF.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,10 @@ generate.static.plots.base(data=data)
6868

6969
###############################################################################
7070
# extract dynamic networks
71-
extract.dyn.nets.asoiaf(data)
71+
extract.dyn.nets.asoiaf(data, narr.units=c("scene", "chapter"))
7272

7373
# compute and plot a few measures
74-
# TODO
74+
plot.dyn.props.asoiaf(data, narr.units=c("scene", "chapter"))
7575

7676

7777

0 commit comments

Comments
 (0)