Topics

Does Praat have a membership operator (like Python "in")?

Earl Brown
 

In an interval tier I have hundreds of words, with each word delimited in a separate interval, but I'm interested in analyzing only some of them. In a TXT file on my hard drive, I have the list of words that I'm interested in analyzing. In a Praat script, I've loaded the TXT file list of words with "wds = Read Strings from raw text file: test_items_path$". Now, I'm looping over the intervals and would like to test whether the current interval label (word) is in the list of words I'm interested in analyzing.

Does Praat scripting have a membership operator, like Python and Julia "in", or R "%in%"? If not, how might I create a function in Praat scripting to create one? Or is there a better way to do this task (loop over intervals and stopping to analyze only some of the intervals, depending on whether the label of the current interval is in a list of desired words)?

Boersma Paul
 

On 12 Dec 2019, at 06:22, Earl Brown <ekbrown77@...> wrote:

I've loaded the TXT file list of words with "wds = Read Strings from raw text file: test_items_path$". Now, I'm looping over the intervals and would like to test whether the current interval label (word) is in the list of words I'm interested in analyzing.
select your Strings object, and do "To WordList". The result is a sorted list in which you can efficiently look up words with "Has word..."
_____

Paul Boersma
Professor of Phonetic Sciences, University of Amsterdam

Visiting address: Spuistraat 134, room 632, Amsterdam
Mail: P.O. Box 1642, 1000BP Amsterdam, The Netherlands
Website: http://www.fon.hum.uva.nl/paul/

Earl Brown
 

Thank you much! I got it to work after "Convert to backslash trigraphs" and "Sort", as I'm looking at Portuguese words with non-ASCII characters (e.g., "português").