Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _parseShortTextgrid(data):
'''
Reads a short textgrid file
'''
newTG = Textgrid()
intervalIndicies = [(i, True)
for i in utils.findAll(data, '"IntervalTier"')]
pointIndicies = [(i, False) for i in utils.findAll(data, '"TextTier"')]
indexList = intervalIndicies + pointIndicies
indexList.append((len(data), None)) # The 'end' of the file
indexList.sort()
tupleList = [(indexList[i][0], indexList[i + 1][0], indexList[i][1])
for i in range(len(indexList) - 1)]
# Set the textgrid's min and max times
header = data[:tupleList[0][0]]
headerList = header.split("\n")
tgMin = float(headerList[3].strip())
tgMax = float(headerList[4].strip())
newTG.minTimestamp = tgMin
def _parseShortTextgrid(data):
'''
Reads a short textgrid file
'''
newTG = Textgrid()
intervalIndicies = [(i, True)
for i in utils.findAll(data, '"IntervalTier"')]
pointIndicies = [(i, False) for i in utils.findAll(data, '"TextTier"')]
indexList = intervalIndicies + pointIndicies
indexList.append((len(data), None)) # The 'end' of the file
indexList.sort()
tupleList = [(indexList[i][0], indexList[i + 1][0], indexList[i][1])
for i in range(len(indexList) - 1)]
# Set the textgrid's min and max times
header = data[:tupleList[0][0]]
headerList = header.split("\n")
tgMin = float(headerList[3].strip())
tgMax = float(headerList[4].strip())
newTG.minTimestamp = tgMin
newTG.maxTimestamp = tgMax
def _findIndicies(data, keyword):
indexList = utils.findAll(data, keyword)
indexList = [data.rfind("\n", 0, i) for i in indexList]
return indexList