-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b646387
commit 1db0a9b
Showing
26 changed files
with
438 additions
and
252 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
#' Create boundaries in a texgrid tier | ||
#' | ||
#' | ||
#' @author George Moroz <[email protected]> | ||
#' | ||
#' @param textgrid character with a filename or path to the TextGrid | ||
#' @param tier value that could be either ordinal number of the tier either name of the tier | ||
#' @param new_tier_name a name of a new created tier | ||
#' @param n_of_annotations number of new annotations per annotation to create | ||
#' @param each non-negative integer. Each new blank annotation is repeated every first, second or ... times | ||
#' @param omit_blank logical. If TRUE (by dafault) it doesn't create subannotation for empy annotations. | ||
#' @param overwrite logical. If TRUE (by dafault) it overwrites an existing tier. | ||
#' | ||
#' @return a string that contain TextGrid. If argument write is \code{TRUE}, then no output. | ||
#' | ||
#' @examples | ||
#' create_subannotation(textgrid = example_textgrid, tier = 1, overwrite = FALSE) | ||
#' | ||
#' @export | ||
#' | ||
|
||
create_subannotation <- function(textgrid, | ||
tier = 1, | ||
new_tier_name = "", | ||
n_of_annotations = 4, | ||
each = 1, | ||
omit_blank = TRUE, | ||
overwrite = TRUE){ | ||
|
||
# read TextGrid ----------------------------------------------------------- | ||
if(grepl("TextGrid", textgrid[2])){ | ||
tg <- textgrid | ||
} else{ | ||
tg <- readLines(normalizePath(textgrid)) | ||
} | ||
|
||
df <- phonfieldwork::tier_to_df(tg, tier = tier) | ||
df | ||
|
||
if(omit_blank){ | ||
df <- df[df$annotation != "",] | ||
} | ||
|
||
lapply(1:nrow(df), function(i){ | ||
t <- seq(df$start[i], df$end[i], length.out = each*(n_of_annotations+1)) | ||
data.frame(start = t[-length(t)], | ||
end = t[-1]) | ||
}) -> | ||
l | ||
|
||
final <- Reduce(rbind, l) | ||
final <- cbind(id = 1:nrow(final), final, annotation = "") | ||
phonfieldwork::df_to_tier(final, | ||
textgrid = textgrid, | ||
tier_name = new_tier_name, | ||
overwrite = overwrite) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,10 @@ | ||
,id,start,end,annotation | ||
1,1,0,0.108702066839713, | ||
2,2,0.108702066839713,0.184762881187424, | ||
3,3,0.184762881187424,0.577955857574024, | ||
4,4,0.577955857574024,0.689276652082925, | ||
5,5,0.689276652082925,1.03734416788977, | ||
6,6,1.03734416788977,1.13213917296352, | ||
7,7,1.13213917296352,1.39421768707483, | ||
"","id","start","end","annotation" | ||
"1",1,0,0.0981938873393881,"" | ||
"2",2,0.0981938873393881,0.180033198124212,"ı" | ||
"3",3,0.180033198124212,0.482154195011338,"" | ||
"4",4,0.482154195011338,0.578069846032217,"" | ||
"5",5,0.578069846032217,0.691528890529359,"æ" | ||
"6",6,0.691528890529359,0.912063492063492,"" | ||
"7",7,0.912063492063492,1.03562599269282,"" | ||
"8",8,1.03562599269282,1.13048519382978,"ɒ" | ||
"9",9,1.13048519382978,1.39421768707483,"" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.