diff --git a/DESCRIPTION b/DESCRIPTION index 3ed13ee..b2a1383 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: phonfieldwork Type: Package Title: Linguistic Phonetic Fieldwork Tools -Version: 0.0.13 +Version: 0.0.15 Depends: R (>= 3.5.0) Imports: tuneR, diff --git a/NEWS.md b/NEWS.md index bfe3d93..8bfaa1f 100755 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,16 @@ +# 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 + +# phonfieldwork 0.0.13 + +- fix encoding detection + # phonfieldwork 0.0.12 - add a `separate_duration` argument to the `concatenate_soundfiles()` function that makes it possible to use some silent separator during the file concatenation. diff --git a/R/df_to_tier.R b/R/df_to_tier.R index 643aee9..7ef6235 100644 --- a/R/df_to_tier.R +++ b/R/df_to_tier.R @@ -46,6 +46,18 @@ df_to_tier <- function(df, textgrid, tier_name = "", overwrite = TRUE) { 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){ + 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),] + ) + }) + } + tier_class <- ifelse("time_end" %in% names(df), ' class = "IntervalTier" ', ' class = "TextTier" ' diff --git a/R/utils.r b/R/utils.r index d555c01..77efd17 100644 --- a/R/utils.r +++ b/R/utils.r @@ -12,7 +12,7 @@ read_textgrid <- function(file_name) { } else { # thanks to Artem Klevtsov for this code con <- file(file_name, - encoding = readr::guess_encoding(file_name)$encoding) + encoding = readr::guess_encoding(file_name)$encoding[1]) tg <- readLines(con) close(con) } diff --git a/codemeta.json b/codemeta.json index ee75941..e251d2c 100644 --- a/codemeta.json +++ b/codemeta.json @@ -8,13 +8,19 @@ "codeRepository": "https://github.com/ropensci/phonfieldwork", "issueTracker": "https://github.com/ropensci/phonfieldwork/issues", "license": "https://spdx.org/licenses/GPL-2.0", - "version": "0.0.13", + "version": "0.0.15", "programmingLanguage": { "@type": "ComputerLanguage", "name": "R", "url": "https://r-project.org" }, - "runtimePlatform": "R version 4.3.3 (2024-02-29)", + "runtimePlatform": "R version 4.4.1 (2024-06-14)", + "provider": { + "@id": "https://cran.r-project.org", + "@type": "Organization", + "name": "Comprehensive R Archive Network (CRAN)", + "url": "https://cran.r-project.org" + }, "author": [ { "@type": "Person", @@ -229,7 +235,7 @@ }, "SystemRequirements": "pandoc (>= 1.14) - http://pandoc.org" }, - "fileSize": "4059.603KB", + "fileSize": "2085.848KB", "citation": [ { "datePublished": "2023",