Skip to content

Commit

Permalink
next version
Browse files Browse the repository at this point in the history
  • Loading branch information
agricolamz committed Jul 13, 2024
1 parent 73e6649 commit 07b4c94
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: phonfieldwork
Type: Package
Title: Linguistic Phonetic Fieldwork Tools
Version: 0.0.15
Version: 0.0.16
Depends: R (>= 3.5.0)
Imports:
tuneR,
Expand Down
5 changes: 4 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
# phonfieldwork 0.0.16

- small fix

# phonfieldwork 0.0.15

- small fix in `df_to_tier` of cases with non-equal time_end and time_start values in the dataframe


# phonfieldwork 0.0.14

- small fix
Expand Down
13 changes: 10 additions & 3 deletions R/df_to_tier.R
Original file line number Diff line number Diff line change
Expand Up @@ -41,23 +41,30 @@ df_to_tier <- function(df, textgrid, tier_name = "", overwrite = TRUE) {

n_tiers <- as.numeric(gsub("\\D", "", tg[7]))
tg[7] <- paste0("size = ", n_tiers + 1, " ")
textgrid_duration <- gsub("[a-z\\=\\s]", "", tg[5]) |> as.double()

if (!(FALSE %in% (df$time_start == df$time_end))) {
df <- df[, -which(names(df) %in% "time_end")]
}

if (TRUE %in% (df$time_end[-nrow(df)] != df$time_start[-1])){
wrong_time_end <- which(df$time_end[-nrow(df)] != df$time_start[-1])
silence <- lapply(wrong_time_end, function(i){
silence <- lapply(rev(wrong_time_end), function(i){
df <<- rbind(df[c(1:i),],
data.frame(time_start = df$time_end[i],
time_end = df$time_start[i+1],
content = ""),
df[-c(1:i),]
)
df[-c(1:i),])
})
}

if(df$time_end[nrow(df)] != textgrid_duration){
df <- rbind(df,
data.frame(time_start = df$time_end[nrow(df)],
time_end = textgrid_duration,
content = ""))
}

tier_class <- ifelse("time_end" %in% names(df),
' class = "IntervalTier" ',
' class = "TextTier" '
Expand Down

0 comments on commit 07b4c94

Please sign in to comment.