tiers_add {act} | R Documentation |
Add tiers
Description
Adds a tiers in all transcript objects of a corpus.
If tiers should be added only in certain transcripts, set the parameter filterTranscriptNames
.
In case that you want to select transcripts by using regular expressions use the function act::search_makefilter
first.
Usage
tiers_add(
x,
tierName,
tierType = c("IntervalTier", "TextTier"),
absolutePosition = NULL,
destinationTier = NULL,
relativePositionToDestinationTier = 0,
insertOnlyIfDestinationExists = FALSE,
filterTranscriptNames = NULL,
skipIfTierAlreadyExists = TRUE
)
Arguments
x |
Corpus object. |
tierName |
Character string; names of the tier to be added. |
tierType |
Character string; type of the tier to be added. |
absolutePosition |
Integer; Absolute position where the tier will be inserted. Value 1 and values beloe 1 will insert the tier in the first position; To insert the tier at the end, leave 'absolutePosition' and 'destinationTier' open. |
destinationTier |
Character string; insert the tier relative to this tier. |
relativePositionToDestinationTier |
Integer; position relative to the destination tier; 1=immediately after; 0 and -1=immediately before; bigger numbers are also allowed. |
insertOnlyIfDestinationExists |
Logical; if |
filterTranscriptNames |
Vector of character strings; names of the transcripts to be modified. If left open, the tier will be added to all transcripts in the corpus. |
skipIfTierAlreadyExists |
Logical; if |
Details
You can either insert the new tier at a specific position (e.g. 'absolutePosition=1') or in relation to a existing tier (e.g. destinationTier='speaker1'). To insert a tier at the end, leave 'absolutePosition' and 'destinationTier' open.
Results will be reported in @history
of the transcript objects.
Value
Corpus object.
See Also
tiers_delete, tiers_rename, tiers_convert, tiers_sort
Examples
library(act)
# --- Add new interval tier.
# Since not position is set it will be inserted in the end, by default.
x <- act::tiers_add(examplecorpus,
tierName="TEST")
#check results
x@history[length(x@history)]
#have a look at the first transcript
x@transcripts[[1]]@tiers
#--> New tier is inserted in the end.
# --- Add new interval tier in position 2
x <- act::tiers_add(examplecorpus,
tierName="TEST",
absolutePosition=2)
#check results
x@history[length(x@history)]
#have a look at the first transcript
x@transcripts[[1]]@tiers
#--> New tier is inserted as second tier.
# --- Add new interval tier at the position of "Entrevistador", only if this tier exists,
# If the destination tier does not exist, the new tier will NOT be inserted.
#Have a look at the first and the second transcript.
examplecorpus@transcripts[[1]]@tiers
#Transcript 1 does contain a tier "Entrevistador" in the first position.
examplecorpus@transcripts[[2]]@tiers
#Transcript 2 does contain a tier "Entrevistador" in the first position.
#Insert new tier
x <- act::tiers_add(examplecorpus,
tierName="TEST",
destinationTier="Entrevistador",
relativePositionToDestinationTier=0,
insertOnlyIfDestinationExists=TRUE)
#Check results
x@history[length(x@history)]
#Have a look at the transcript 1:
# Tier 'TEST' was in first position (e.g. where 'Entrevistador' was before).
x@transcripts[[1]]@tiers
#Have a look at the transcript 2:
#Tier 'TEST' was not inserted, since there was no destination tier 'Entrevistador'.
x@transcripts[[2]]@tiers
# --- Add new interval tier AFTER tier="Entrevistador"
# If the destination tier does not exist, the new tier will be inserted at the end in any case.
x <- act::tiers_add(examplecorpus,
tierName="TEST",
destinationTier="Entrevistador",
relativePositionToDestinationTier=1,
insertOnlyIfDestinationExists=FALSE)
#check results
x@history[length(x@history)]
#Have a look at the transcript 1:
# Tier 'TEST' was inserted after the tier 'Entrevistador'.
x@transcripts[[1]]@tiers
#Have a look at the transcript 2:
#Tier 'TEST' was insertedat the end.
x@transcripts[[2]]@tiers