Learn R Programming

emuR (version 1.0.0)

requery_hier: Requery hierarchical context of a segment list in an emuDB

Description

Function to requery hierarchical context of a segment list queried from an emuDB

Usage

requery_hier(emuDBhandle, seglist, level, collapse = TRUE, calcTimes = T,
  timeRefSegmentLevel = NULL, verbose = FALSE)

Arguments

emuDBhandle

emuDB handle as returned by load_emuDB

seglist

segment list to requery on (type: emuRsegs)

level

character string: name of target level

collapse

collapse the found items in the requested level to a sequence (concatenated with ->). If set to FALSE separate items as new entries in the emuRsegs object are returned.

calcTimes

calculate times for resulting segments (results in NA values for start and end times in emuseg/emuRsegs). As it can be very computationally expensive to calculate the times for large nested hierarchies, it can be turned off via this boolean parameter.

timeRefSegmentLevel

set time segment level from which to derive time information. It is only necessary to set this parameter if more than one child level contains time information and the queried parent level is of type ITEM.

verbose

be verbose. Set this to TRUE if you wish to choose which path to traverse on intersecting hierarchies. If set to FALSE (the default) all paths will be traversed (= legacy EMU bahaviour).

Value

result set object of class emuRsegs

Details

A segment is defined as a single item or a chain of items from the respective level, e.g. if a level in a bundle instance has labels 'a', 'b' and 'c' in that order, 'a' or 'a->b' or 'a->b->c' are all valid segments, but not 'a->c'. For each segment of the input segment list seglist the function checks the start and end item for hierarchically linked items in the given target level, and based on them constructs segments in the target level. As the start item in the resulting segment the item with the lowest sample position is chosen; for the end item that with the highest sample position. If result and input segment list have the same length (for each input segment one segment on the target level was found), the result segment list has the same length and order as the input list; in 'upwards' requeries this can cause a resulting segment list to contain two (or more) copies of the same segment, if the same item from the input list was linked twice or more to an item of the target level, e.g. a phoneme 'p' requeried to the word level might result in two identical segments 'Papa' in the result list. If the length of input and output list differ (e.g. because a link is missing in the emuDB), a synchronous ordering is not possible and therefore a warning is generated.

See Also

query requery_seq emuRsegs

Examples

Run this code
# NOT RUN {
##################################
# prerequisite: loaded ae emuDB 
# (see ?load_emuDB for more information)

## Downward requery: find 'Phoneme' sequences of all words 'beautiful' (of level 'Text')
## Note that the resulting segments consists of phoneme sequences and have therefore 
## the same length as the word segments.

sl1 = query(ae, "Text == beautiful")
requery_hier(ae, sl1, level = "Phoneme")

## Upward requery: find all word segments that dominate a 'p' on level 'Phoneme'
## Note that the resulting segments are larger than the input segments,
## because they contain the complete words.

sl1 = query(ae, "Phonetic == p")
requery_hier(ae, sl1, level = 'Text')

## Why is there a 'p' the word 'emphazised'? Requery the whole words back down to 'Phoneme' level:

requery_hier(ae, sl1, level = 'Phoneme')

## ... because of 'stop epenthesis' a 'p' is inserted between 'm' and 'f'

## Combined requery: last phonemes of all words beginning with 'an'.
## Note that we use a regular expression 'an.*' (EQL operator '=~') in the query.

sl1=query(ae, "Text =~ an.*")
requery_seq(ae, requery_hier(ae, sl1, level = 'Phoneme'), offsetRef = 'END')

# }

Run the code above in your browser using DataLab