-
Notifications
You must be signed in to change notification settings - Fork 0
/
deleteAnnotations.py
36 lines (27 loc) · 1.03 KB
/
deleteAnnotations.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#-----------------------------------------------------------------------------------
# Marta Villegas (UAB) VIW project (Visual into Words http://pagines.uab.cat/viw)
#
# removes annotations Tokens + dependent Tiers
#
# usage: $ deleteAnnotations.py elanFile.eaf
#
# output is written in a new eaf file: elanFile-Tokens.eaf
#-----------------------------------------------------------------------------------
import sys
import pympi # Imports pympi to work with elan files
# Specify file path
args = sys.argv
elan_file_path = args[1]
# Initialize the elan file
eaf = pympi.Elan.Eaf(elan_file_path)
# Gets Tokens children
children = eaf.get_child_tiers_for('Tokens')
# Removes Annotations in Tokens children
for child in children:
eaf.remove_all_annotations_from_tier(child, clean=True)
# Removes Annotations in Tokens tier
eaf.remove_all_annotations_from_tier('Tokens', clean=True)
### Write the results to file with the -Tokens suffix
eaf.to_file(elan_file_path.replace('.eaf', '-Clean.eaf'))