server/src/app/Libraries/Transcript/TranscriberTranscriptConverter.php
changeset 460 686926d132ff
parent 162 a6cf5a06f02d
child 476 9cffc7f32f14
--- a/server/src/app/Libraries/Transcript/TranscriberTranscriptConverter.php	Fri Dec 02 15:30:16 2016 +0100
+++ b/server/src/app/Libraries/Transcript/TranscriberTranscriptConverter.php	Fri Dec 02 17:22:16 2016 +0100
@@ -89,6 +89,49 @@
                 }
                 $this->annotations = array_merge($this->annotations, $currentAnnotations);
                 $currentAnnotations = [];
+            } elseif($cnode->nodeType === XML_ELEMENT_NODE) {
+                $content = null;
+                switch ($cnode->tagName) {
+                    case 'Background':
+                        $content = [
+                            'ctype' => strtolower($cnode->tagName),
+                            'type' => $cnode->getAttribute('type'),
+                            'level' => $cnode->getAttribute('level')
+                        ];
+                        break;
+                    case 'Event':
+                        $content = [
+                            'ctype' => strtolower($cnode->tagName),
+                            'type' => $cnode->getAttribute('type'),
+                            'extent' => $cnode->getAttribute('extent'),
+                            'desc' => $cnode->getAttribute('desc')
+                        ];
+                        break;
+                    case 'Comment':
+                    case 'Vocal':
+                        $content = [
+                            'ctype' => strtolower($cnode->tagName),
+                            'desc' => $cnode->getAttribute('desc')
+                        ];
+                        break;
+                    default:
+                        continue;
+                }
+                if(is_null($content)) {
+                    continue;
+                }
+                $aData = $currentSpeaker?["speaker" => $currentSpeaker]:[];
+                $aData['content'] = $content;
+                $newAnnotation = [
+                    'id' => $this->document->getId()."_a".sprintf("%04d", $this->annotationCounter++),
+                    'begin' => $currentBegin,
+                    'end' => $end,
+                    'media' => $this->getMediaRefId(),
+                    'type' => $turnId,
+                    'content' => [ "mimetype" => "application/json", "data" => $aData],
+                    'meta' => [ 'id-ref' => $turnId ]
+                ];
+                array_push($currentAnnotations, $newAnnotation);
             }
         }
         $this->annotations = array_merge($this->annotations, $currentAnnotations);
@@ -168,4 +211,4 @@
     }
 
 
-}
\ No newline at end of file
+}