87 foreach($currentAnnotations as &$nAnnot) { |
87 foreach($currentAnnotations as &$nAnnot) { |
88 $nAnnot['end'] = $currentBegin; |
88 $nAnnot['end'] = $currentBegin; |
89 } |
89 } |
90 $this->annotations = array_merge($this->annotations, $currentAnnotations); |
90 $this->annotations = array_merge($this->annotations, $currentAnnotations); |
91 $currentAnnotations = []; |
91 $currentAnnotations = []; |
|
92 } elseif($cnode->nodeType === XML_ELEMENT_NODE) { |
|
93 $content = null; |
|
94 switch ($cnode->tagName) { |
|
95 case 'Background': |
|
96 $content = [ |
|
97 'ctype' => strtolower($cnode->tagName), |
|
98 'type' => $cnode->getAttribute('type'), |
|
99 'level' => $cnode->getAttribute('level') |
|
100 ]; |
|
101 break; |
|
102 case 'Event': |
|
103 $content = [ |
|
104 'ctype' => strtolower($cnode->tagName), |
|
105 'type' => $cnode->getAttribute('type'), |
|
106 'extent' => $cnode->getAttribute('extent'), |
|
107 'desc' => $cnode->getAttribute('desc') |
|
108 ]; |
|
109 break; |
|
110 case 'Comment': |
|
111 case 'Vocal': |
|
112 $content = [ |
|
113 'ctype' => strtolower($cnode->tagName), |
|
114 'desc' => $cnode->getAttribute('desc') |
|
115 ]; |
|
116 break; |
|
117 default: |
|
118 continue; |
|
119 } |
|
120 if(is_null($content)) { |
|
121 continue; |
|
122 } |
|
123 $aData = $currentSpeaker?["speaker" => $currentSpeaker]:[]; |
|
124 $aData['content'] = $content; |
|
125 $newAnnotation = [ |
|
126 'id' => $this->document->getId()."_a".sprintf("%04d", $this->annotationCounter++), |
|
127 'begin' => $currentBegin, |
|
128 'end' => $end, |
|
129 'media' => $this->getMediaRefId(), |
|
130 'type' => $turnId, |
|
131 'content' => [ "mimetype" => "application/json", "data" => $aData], |
|
132 'meta' => [ 'id-ref' => $turnId ] |
|
133 ]; |
|
134 array_push($currentAnnotations, $newAnnotation); |
92 } |
135 } |
93 } |
136 } |
94 $this->annotations = array_merge($this->annotations, $currentAnnotations); |
137 $this->annotations = array_merge($this->annotations, $currentAnnotations); |
95 |
138 |
96 } |
139 } |