У меня есть несколько больших транскриптов речей, которые я пытаюсь получить в формате фрейма данных, где каждая строка представляет речь / высказывание, а имя соответствующего оратора находится в столбце.
Вот снимок текста в его структурированном виде:
"sr. presidente domínguez.- "
" Tiene la palabra el señor diputado por Buenos Aires."
""
"sr. ATANASOF, ALFREDO NESTOR.- "
" Señor presidente: también quiero adherir en nombre del Frente Peronista a este homenaje al Gringo Soria. "
" Me tocó compartir con él muchos años de trabajo en esta Cámara y luego funciones en el Poder Ejecutivo nacional. Realmente, durante esos años pude descubrir los valores del Gringo: un gran militante y peronista, quien siempre anteponía la resolución de los temas a las situaciones de conflicto."
" Hemos sentido mucho dolor cuando nos enteramos de esta desgraciada situación. Por ello, en nombre de nuestro bloque, quiero adherir al homenaje que hacemos a un amigo. Justamente, el Gringo Soria era un amigo para mí. (Aplausos.)"
""
Я использовал следующий цикл, чтобы попытаться проанализировать текст таким образом, чтобы каждая строка представляла говорящего и соответствующую речь / высказывание:
test <- readtext(text)
testtxt <- test$text
trans.prep <- function(testtxt) {
testtxt <- gsub("\\s{2,}", " ", testtxt, perl = T)
#gets rid of double spaces and replaces them with single spaces
testtxt <- subset(testtxt, nchar(testtxt) > 0)
#gets rid of lines that are empty (length of line is zero)
#collapse down to utterances
my.line <- 1
while (my.line <= length (testtxt)) {
utterance <- length(grep(".-", testtxt[my.line], perl = T))
if (utterance == 1) {my.line <- my.line + 1 }
if (utterance == 0) {testtext[my.line-1] <-paste(testtext[(my.line-1):my.line], collapse = " ")
testtext <- testtext[-my.line]} }
testtxt <- subset(testtxt, nchar(testtxt) > 0)
return(testtxt)}
Цикл должен возвращать проанализированный транскрипт, но когда я запускаю цикл, ничего не происходит, и R не выдает сообщение об ошибке.
Я новичок в разборе и все еще новичок в R, так что я уверен, что это часть моей проблемы. Любой совет будет принята с благодарностью.