ELAN import¶
Reading ELAN's exported text, keeping the provenance line that names the media.
Read ELAN's exported text, which is how other people's annotations arrive.
_annotate.from_elan reads .eaf, ELAN's own project file. This reads the other thing
ELAN produces and the one collaborators actually send: File > Export > Tab-delimited
text, usually saved with a .csv extension and comma separators.
The provenance line is the most important thing in the file. An ELAN export begins
with a comment naming the media it was annotated against and that media's duration. Times
in the body are on THAT file's clock. Annotations of a cut, re-encoded or differently
trimmed copy will land silently in the wrong place if the reader takes the numbers and
throws the header away, so every span carries source_file and source_duration_s and
the caller can compare them against the recording it is about to attach them to.
This is not hypothetical. The human annotations of this project's dance corpus were made on cut 25 fps videos running 36 to 39 per cent of our recordings' length, with a different ratio per session --- so no single scale maps them, and a reader that hid the provenance would have made that impossible to notice.
Three time columns are exported for every boundary: hh:mm:ss.ms, seconds, and PAL
timecode. Only seconds is read. The other two are derived from it, and PAL assumes 25 fps,
which is a property of the export rather than of the recording.
read_elan_csv ¶
read_elan_csv(path, source='elan')
Read an ELAN tab-delimited export into a :class:Hierarchy.
Every non-time column becomes a level named after the column, which is the tier name ELAN wrote. Rows with an empty cell in a column contribute nothing to that level: an export carries one row per span on ANY tier, so blanks are the normal state and turning them into annotations would invent data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
The exported file. |
required | |
source
|
str
|
Recorded on each Action, so spans pooled from several sources can
be told apart. Defaults to |
'elan'
|
Returns:
| Name | Type | Description |
|---|---|---|
Hierarchy |
Hierarchy
|
One level per annotation column, each in time order. Every Action |
Hierarchy
|
carries |
|
Hierarchy
|
provenance line, plus |
Raises:
| Type | Description |
|---|---|
ValueError
|
If no header row with a seconds column can be found. |
Source code in musicalgestures/_elan.py
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 | |