TextGrid 是 Praat 程序使用的“分段”文件。我想编写一个解析器来验证数据。我的问题是:
您将如何为这种格式编写解析器?逐行阅读还是其他什么?这是已知格式吗?
File type = "ooTextFile"
Object class = "TextGrid"
xmin = 0
xmax = 93.0538775510204
tiers? <exists>
size = 3
item []:
item [1]:
class = "IntervalTier"
name = "diph"
xmin = 0
xmax = 93.0538775510204
intervals: size = 65
intervals [1]:
xmin = 0
xmax = 1.300090702947846
text = ""
intervals [2]:
xmin = 1.300090702947846
xmax = 1.5300845864661654
text = "ey_s"
intervals [3]:
xmin = 1.5300845864661654
xmax = 3.4648692624493815
text = ""
(然后重复到 EOF,间隔 [4....n])
最佳答案
TextGrid 解析器已经存在,它是 NLTK Toolkit 的一部分。 Python文件在这里:
http://nltk.googlecode.com/svn/trunk/nltk_contrib/nltk_contrib/textgrid.py
更新链接:
https://github.com/nltk/nltk_contrib/blob/master/nltk_contrib/textgrid.py
关于python - 如何解析这种格式(Praat TextGrid),我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/6167630/