@@ -642,7 +642,7 @@ read.inter.table <- function(
642642 inter.df [,COL_RANK ] <- rank(volume.stats [inter.df [,COL_VOLUME_ID ],COL_RANK ]* (nrow(inter.df )+ 1 ) + 1 : nrow(inter.df ), ties.method = " first" )
643643
644644 # check unused characters
645- pb.char <- setdiff(char.stats [,COL_NAME ], unique(unlist(scene.chars )))
645+ pb.chars <- setdiff(char.stats [,COL_NAME ], unique(unlist(scene.chars )))
646646 if (length(pb.chars )> 0 )
647647 { # cat(paste(pb.chars,collapse="\n"))
648648 msg <- paste0(" WARNING: while reading file \" " ,inter.file ," \" . The following names are defined in file \" " ,CHAR_FILE ," \" , but appear in no scene: " ,paste(pb.chars ,colapse = " ," ))
@@ -918,47 +918,56 @@ read.char.list <- function(file)
918918# ##############################################################################
919919read.corpus.data <- function (char.det )
920920{ tlog(2 ," Reading statistics and character lists" )
921+ result <- list ()
921922
922923 # interactions
923924 file <- get.path.stats.corpus(char.det = char.det , pref = " _interactions" )
924925 tlog(2 ," Reading interaction file \" " ,file ," \" " )
925926 inter.df <- read.csv(file = paste0(file ," .csv" ), header = TRUE , check.names = FALSE , stringsAsFactors = FALSE )
926927 for (col in c(COL_CHAR_FROM , COL_CHAR_TO ))
927928 inter.df [,col ] <- fix.encoding(strings = inter.df [,col ])
929+ result $ inter.df <- inter.df
928930
929931 # panel stats
930932 file <- get.path.stats.corpus(object = " panels" , char.det = char.det , pref = " _panel_stats" )
931933 tlog(2 ," Reading panel stats file \" " ,file ," \" " )
932934 panel.stats <- read.csv(file = paste0(file ," .csv" ), header = TRUE , check.names = FALSE , stringsAsFactors = FALSE )
935+ result $ panel.stats <- panel.stats
933936 # panel chars
934937 file <- get.path.stats.corpus(object = " panels" , char.det = char.det , pref = " _panel_chars" )
935938 tlog(2 ," Reading panel chars file \" " ,file ," \" " )
936939 panel.chars <- read.char.list(file = paste0(file ," .txt" ))
940+ result $ panel.chars <- panel.chars
937941
938942 # page stats
939943 file <- get.path.stats.corpus(object = " pages" , char.det = char.det , pref = " _page_stats" )
940944 tlog(2 ," Reading page stats file \" " ,file ," \" " )
941945 page.stats <- read.csv(file = paste0(file ," .csv" ), header = TRUE , check.names = FALSE , stringsAsFactors = FALSE )
946+ result $ page.stats <- page.stats
942947 # page chars
943948 file <- get.path.stats.corpus(object = " pages" , char.det = char.det , pref = " _page_chars" )
944949 tlog(2 ," Reading page chars file \" " ,file ," \" " )
945950 page.chars <- read.char.list(file = paste0(file ," .txt" ))
951+ result $ page.chars <- page.chars
946952
947953 # scene stats
948954 file <- get.path.stats.corpus(object = " scenes" , char.det = char.det , pref = " _scene_stats" )
949955 tlog(2 ," Reading scene stats file \" " ,file ," \" " )
950956 scene.stats <- read.csv(file = paste0(file ," .csv" ), header = TRUE , check.names = FALSE , stringsAsFactors = FALSE )
957+ result $ scene.stats <- scene.stats
951958 # scene chars
952959 file <- get.path.stats.corpus(object = " scenes" , char.det = char.det , pref = " _scene_chars" )
953960 tlog(2 ," Reading scene chars file \" " ,file ," \" " )
954961 scene.chars <- read.char.list(file = paste0(file ," .txt" ))
962+ result $ scene.chars <- scene.chars
955963
956964 # characters
957965 file <- get.path.stats.corpus(object = " characters" , char.det = char.det , subfold = " unfiltered" , pref = " _char_stats" )
958966 tlog(2 ," Reading char stats file \" " ,file ," \" " )
959967 char.stats <- read.csv(file = paste0(file ," .csv" ), header = TRUE , check.names = FALSE , stringsAsFactors = FALSE )
960968 for (col in c(COL_NAME , COL_NAME_SHORT ))
961969 char.stats [,col ] <- fix.encoding(strings = char.stats [,col ])
970+ result $ char.stats <- char.stats
962971
963972 # possibly deal with chapters
964973 file <- get.path.stats.corpus(object = " chapters" , char.det = char.det , pref = " _chapter_stats" )
@@ -968,10 +977,12 @@ read.corpus.data <- function(char.det)
968977 chapter.stats <- read.csv(file = paste0(file ," .csv" ), header = TRUE , check.names = FALSE , stringsAsFactors = FALSE )
969978 for (col in c(COL_TITLE , COL_VOLUME , COL_ARC ))
970979 chapter.stats [,col ] <- fix.encoding(strings = chapter.stats [,col ])
980+ result $ chapter.stats <- chapter.stats
971981 # chapter chars
972982 file <- get.path.stats.corpus(object = " chapters" , char.det = char.det , pref = " _chapter_chars" )
973983 tlog(2 ," Reading chapter chars file \" " ,file ," \" " )
974984 chapter.chars <- read.char.list(file = paste0(file ," .txt" ))
985+ result $ chapter.chars <- chapter.chars
975986 }
976987
977988 # volume stats
@@ -980,33 +991,27 @@ read.corpus.data <- function(char.det)
980991 volume.stats <- read.csv(file = paste0(file ," .csv" ), header = TRUE , check.names = FALSE , stringsAsFactors = FALSE )
981992 for (col in c(COL_SERIES , COL_TITLE , COL_ARC ))
982993 volume.stats [,col ] <- fix.encoding(strings = volume.stats [,col ])
994+ result $ volume.stats <- volume.stats
983995 # volume chars
984996 file <- get.path.stats.corpus(object = " volumes" , char.det = char.det , pref = " _volume_chars" )
985997 tlog(2 ," Reading volume chars file \" " ,file ," \" " )
986998 volume.chars <- read.char.list(file = paste0(file ," .txt" ))
999+ result $ volume.chars <- volume.chars
9871000
9881001 # arc stats
9891002 file <- get.path.stats.corpus(object = " arcs" , char.det = char.det , pref = " _arc_stats" )
9901003 tlog(2 ," Reading arc stats file \" " ,file ," \" " )
9911004 arc.stats <- read.csv(file = paste0(file ," .csv" ), header = TRUE , check.names = FALSE , stringsAsFactors = FALSE )
9921005 for (col in c(COL_TITLE ))
9931006 arc.stats [,col ] <- fix.encoding(strings = arc.stats [,col ])
1007+ result $ arc.stats <- arc.stats
9941008 # arc chars
9951009 file <- get.path.stats.corpus(object = " arcs" , char.det = char.det , pref = " _arc_chars" )
9961010 tlog(2 ," Reading arc chars file \" " ,file ," \" " )
9971011 arc.chars <- read.char.list(file = paste0(file ," .txt" ))
1012+ result $ arc.chars <- arc.chars
9981013
999- # build result list and return
1000- result <- list (
1001- inter.df = inter.df , # interactions
1002- panel.stats = panel.stats , panel.chars = panel.chars , # panels
1003- page.stats = page.stats , page.chars = page.chars , # pages
1004- scene.stats = scene.stats , scene.chars = scene.chars , # scenes
1005- char.stats = char.stats , # characters
1006- chapter.stats = chapter.stats , chapter.chars = chapter.chars , # chapters
1007- volume.stats = volume.stats , volume.chars = volume.chars , # volumes
1008- arc.stats = arc.stats , arc.chars = arc.chars # arcs
1009- )
1014+ # return result list
10101015 return (result )
10111016}
10121017
0 commit comments