Skip to contents

Replaces the segments of a document. Codings are not affected (they are stored by character offsets), only the segment numbers change. Undoable with qda_undo().

Usage

qda_segments_set(
  source,
  rule = c("blankline", "speaker", "line"),
  pattern = NULL
)

Arguments

source

Source id or unique name.

rule

"blankline" (paragraphs separated by blank lines, the default of jellyqda), "speaker" (a new segment at every speaker turn, e.g. "[00:01:12] P: ..." or "Befragte: ..."; lines without speaker label belong to the previous turn; blank lines also separate) or "line" (every non-empty line).

pattern

For rule = "speaker": regular expression (Perl) that recognises the first line of a speaker turn. The default matches an optional time stamp followed by a one-word label (up to 25 characters) and a colon; if the document contains time-stamped turns, only those count (so header lines like "Projekt: ..." are not split off).

Value

Invisibly, the new segments (tibble segment, start, end).

Examples

qda_open(file.path(tempfile(), "example.jellyqda"))
qda_import(system.file("extdata", "interview_01.txt", package = "jellyqda"))
#> # A tibble: 1 × 5
#>      id name             format chars status
#>   <int> <chr>            <chr>  <int> <chr> 
#> 1     1 interview_01.txt txt      856 ok    
qda_segments_set(1, "line")      # one segment per line
qda_segments_set(1, "speaker")   # speaker turns like "[00:01:12] P: ..."
qda_source_segments(1)
#> # A tibble: 7 × 4
#>   segment start   end text                                                      
#>     <int> <int> <int> <chr>                                                     
#> 1       1     1   101 DEMO FILE - fictional interview written for jellyqda. All…
#> 2       2   104   202 Interviewer: Good morning, and thank you for taking the t…
#> 3       3   205   325 Respondent: Sure. I am 34 years old and I have been worki…
#> 4       4   328   370 Interviewer: How did you get into this job?               
#> 5       5   373   605 Respondent: After studying business informatics I first w…
#> 6       6   608   647 Interviewer: What motivates you at work?                  
#> 7       7   650   856 Respondent: Above all the direct contact with our custome…
qda_close()