Skip to content

Commit 4dff35b

Browse files
committed
Merge branch 'master' of https://github.com/davebraze/FDBeye
2 parents 1cf8419 + e2c5bbc commit 4dff35b

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

R/textRegions.R

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,17 @@ regdef2ias <- function(fname) {
250250
yml <- paste(l[yml], collapse="\n")
251251
parms <- yaml::yaml.load(yml)
252252

253+
## check if crucial parameters are in the yaml block
254+
parms_check <- list(parms$margins$left,
255+
parms$regions$maxH,
256+
parms$regions$minH,
257+
parms$lines$baseline)
258+
if (sum(sapply(parms_check, is.null, simplify = TRUE)) > 0) {
259+
stop(paste("At least one of the following parameters are missing in the yaml block:",
260+
"margins: left, regions: maxH, regions: minH, lines: baselines",
261+
sep = "\n"))
262+
}
263+
253264
## get regdef block
254265
tstart <- max(yidx)+1
255266
tend <- length(l)
@@ -268,6 +279,11 @@ regdef2ias <- function(fname) {
268279
sep <- FDButils::series(which(tidx), minseries=1)
269280
text_line <- c(1, sep[,1]+sep[,3])
270281

282+
## check if number of lines matches between yaml-block defined baselines and regdef-block text
283+
if (length(parms$lines$baselines)!=length(text_line)) {
284+
stop("The number of baselines (defined in the yaml block) and the number of lines in text do not match.")
285+
}
286+
271287
## set up ias data.frame to store regdef info
272288
ias <- data.frame()
273289

inst/extdata/story01-regdef.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ lines:
2222
- 576
2323
- 637
2424
- 698
25-
- 763
26-
- 824
2725
margins:
2826
top: 72 # distance from top of screen to top of 1st line of text in pixels
2927
left: 215 # distance from left edge of screen to left edge of 1st character in line of text, in pixels.

inst/extdata/story03-regdef.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ lines:
2525
- 777
2626
- 838
2727
- 899
28-
- 960
2928
margins:
3029
top: 72 # distance from top of screen to top of 1st line of text in pixels
3130
left: 215 # distance from left edge of screen to left edge of 1st character in line of text, in pixels.

0 commit comments

Comments
 (0)