Output COMBO results to an Excel file
Nick Riches
nick.riches at gmail.com
Wed Sep 12 06:54:16 UTC 2018
Hi
I've just written an R script which will do this. The output of the 'combo'
command should be saved as a text file. The script reads this interactively
using the 'scan' function. The tidyverse needs to be loaded (dplyr commands
are used)
Here's the script:
# Read in data interactively. File should be a text file.
options(stringsAsFactors = FALSE)
script <- scan(file.choose(), what = "string", sep = "\n")
df <- as.data.frame(script)
# Create variable for type of line, e.g. "utt" = UTTERANCE, "mor" = MOR
df$type <- ""
# Function for identifying 'mor' line (by searching for downpipes)
has_downpipe <- function(string){
return(grepl("[\x7C]" , string))
}
library(tidyverse)
# Create variable showing line type (e.g. is it the 'mor' tier?)
for(i in 1:nrow(df)){
if(substr(df$script[i], 1, 8) == "*** File"){df$type[i] <- "file"}
if((substr(df$script[i], 1, 1) == "*") &
(substr(df$script[i], 5, 5) == ":")){df$type[i] <- "utt"}
if(has_downpipe(df$script[i])){df$type[i] <- "mor"}
}
# Fill down 'utt' (utterance over more than one line)
for(i in 2:nrow(df)){
if(df$type[i] == "" & df$type[i - 1] == "utt"){df$type[i] == "utt"}
}
# Remove non-essential lines and rename rows
df <- df[which(df$type != ""),]
row.names(df) <- seq(1, nrow(df))
# Create variable for filename
df$file <- ""
for(i in 1:nrow(df)){
if(df$type[i] == "file"){
vector <- unlist(gregexpr("[\x22]", df$script[i]))
start <- vector[1] + 1
stop <- vector[2] - 1
df$file[i] <- substr(df$script[i], start, stop)
}
}
# Create variables of utterance and mor line
df$utt <- ""
df$mor <- ""
file_row <- 1
for(i in 1:nrow(df)){
if(df$type[i] == "file"){file_row <- i}
if(df$type[i] == "utt"){df$utt[file_row] <- paste(df$utt[file_row],
df$script[i])}
if(df$type[i] == "mor"){df$mor[file_row] <- paste(df$mor[file_row],
df$script[i])}
}
# Remove blank lines and rename rows
df <- df[which(df$file != ""),]
row.names(df) <- seq(1, nrow(df))
# Drop unnecessary variables
df <- df %>% select(file, utt, mor)
On Thursday, August 16, 2018 at 4:26:12 PM UTC+1, Davida wrote:
>
> Nick,
>
> Right, +d6 gives you # of matches in a spreadsheet but without the
> individual utterance. You will probably have to use one of the other +d
> options (probably 1, 2, or 3) to check individual utterances. You can
> always consider copying and pasting that output to a spreadsheet (or
> another tab your other combo results spreadsheet).
>
> -Davida
>
>
> On Thu, Aug 16, 2018 at 11:09 AM, Nick Riches <nick.... at gmail.com
> <javascript:>> wrote:
>
>> Thanks - very simple!
>>
>> I now have the +d6 switch. But it doesn't quite do what I am looking for,
>> as it doesn't list each individual utterance in the database for checking
>>
>> Nick
>>
>> On Thursday, August 16, 2018 at 1:16:16 PM UTC+1, Davida wrote:
>>>
>>> Nick,
>>>
>>> Is it possible you're using an older version of CLAN (the date should
>>> appear in the lower left corner of the Commands window next to the
>>> *Recall* button)? Consider downloading a new version and you should
>>> see the option and it should work.
>>>
>>> -Davida
>>>
>>> On Thu, Aug 16, 2018 at 3:24 AM, Nick Riches <nick.... at gmail.com> wrote:
>>>
>>>> Thanks for the reply
>>>>
>>>> For COMBO, the +d switches only go from 1 - 5, so it doesn't look as if
>>>> this will work.
>>>>
>>>> Best wishes
>>>>
>>>> Nick
>>>>
>>>>
>>>> On Wednesday, August 15, 2018 at 2:06:06 PM UTC+1, Davida wrote:
>>>>>
>>>>> Dear Nick,
>>>>>
>>>>> Did you try the +d6 switch? You can always see a list and explanation
>>>>> of the options and switches if you just type the command (in this case,
>>>>> combo) in the command window and then hit return.
>>>>>
>>>>> Hope that helps,
>>>>> Davida
>>>>>
>>>>>
>>>>> On Wed, Aug 15, 2018 at 5:47 AM, Nick Riches <nick.... at gmail.com>
>>>>> wrote:
>>>>>
>>>>>> Hi
>>>>>>
>>>>>> I'm trying to output the results of a COMBO search to an Excel file
>>>>>> (e.g. with one column for a file identifier, another column for the
>>>>>> participant, a third column the speaker tier, and a fourth column for the
>>>>>> MOR tier). I understand that many commands have switches which allow output
>>>>>> to a spreadsheet format, but I cannot find an equivalent for the COMBO
>>>>>> command. Is there one?
>>>>>>
>>>>>> Thanks
>>>>>>
>>>>>> --
>>>>>> You received this message because you are subscribed to the Google
>>>>>> Groups "chibolts" group.
>>>>>> To unsubscribe from this group and stop receiving emails from it,
>>>>>> send an email to chibolts+u... at googlegroups.com.
>>>>>> To post to this group, send email to chib... at googlegroups.com.
>>>>>> To view this discussion on the web visit
>>>>>> https://groups.google.com/d/msgid/chibolts/989cf490-ee50-49f2-943e-ad24b43200fe%40googlegroups.com
>>>>>> <https://groups.google.com/d/msgid/chibolts/989cf490-ee50-49f2-943e-ad24b43200fe%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>>>> .
>>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>>
>>>>>
>>>>> --
>>>> You received this message because you are subscribed to the Google
>>>> Groups "chibolts" group.
>>>> To unsubscribe from this group and stop receiving emails from it, send
>>>> an email to chibolts+u... at googlegroups.com.
>>>> To post to this group, send email to chib... at googlegroups.com.
>>>> To view this discussion on the web visit
>>>> https://groups.google.com/d/msgid/chibolts/1e72f879-f6af-4343-9c99-3e09afdd1229%40googlegroups.com
>>>> <https://groups.google.com/d/msgid/chibolts/1e72f879-f6af-4343-9c99-3e09afdd1229%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>> .
>>>>
>>>> For more options, visit https://groups.google.com/d/optout.
>>>>
>>>
>>> --
>> You received this message because you are subscribed to the Google Groups
>> "chibolts" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to chibolts+u... at googlegroups.com <javascript:>.
>> To post to this group, send email to chib... at googlegroups.com
>> <javascript:>.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/chibolts/1345fdaa-077a-4088-b4b8-a4a2cd374538%40googlegroups.com
>> <https://groups.google.com/d/msgid/chibolts/1345fdaa-077a-4088-b4b8-a4a2cd374538%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
--
You received this message because you are subscribed to the Google Groups "chibolts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chibolts+unsubscribe at googlegroups.com.
To post to this group, send email to chibolts at googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/chibolts/c8b3328e-efd6-4c83-8b3b-f59e083809bf%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listserv.linguistlist.org/pipermail/chibolts/attachments/20180911/fe84cbd0/attachment.htm>
More information about the Chibolts
mailing list