From 1600ab3446f533a6824512d616131c7d02a037c7 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Tue, 20 Oct 2020 19:25:35 +0200 Subject: add footnote type and text plate type. keep track of footnotes when accumulating paragraphs. --- animism-align/frontend/app/utils/transcript.utils.js | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'animism-align/frontend/app/utils/transcript.utils.js') diff --git a/animism-align/frontend/app/utils/transcript.utils.js b/animism-align/frontend/app/utils/transcript.utils.js index f343d76..dc351c0 100644 --- a/animism-align/frontend/app/utils/transcript.utils.js +++ b/animism-align/frontend/app/utils/transcript.utils.js @@ -6,14 +6,16 @@ import { FULLSCREEN_UTILITY_ANNOTATION_TYPES, } from 'app/constants' -export const buildParagraphs = (annotationOrder, sectionCount) => { +export const buildParagraphs = (annotationOrder, sectionCount, footnoteCount) => { const state = store.getState() const { lookup: annotationLookup } = state.annotation.index const { lookup: paragraphLookup } = state.paragraph.index let currentParagraph = {} const paragraphs = [] + const footnotes = [] sectionCount = (sectionCount || 0) + footnoteCount = (footnoteCount || 0) // loop over the annotations in time order annotationOrder.forEach((annotation_id, i) => { @@ -85,12 +87,16 @@ export const buildParagraphs = (annotationOrder, sectionCount) => { paragraphs.push(currentParagraph) } + if (annotation.type === 'footnote') { + footnoteCount += 1 + annotation.footnote_id = footnoteCount + footnotes.push(annotation) + } + // if this annotation is a paragraph_end, set the end timestamp if (annotation.type === 'paragraph_end') { currentParagraph.end_ts = annotation.start_ts - } - - // otherwise, just append this annotation to the paragraph + } // otherwise, just append this annotation to the paragraph else { currentParagraph.annotations.push(annotation) } @@ -107,7 +113,7 @@ export const buildParagraphs = (annotationOrder, sectionCount) => { paragraphs[i].start_ts = paragraphs[i+1].start_ts - 0.01 } } - return paragraphs + return { paragraphs, footnotes } } const getParagraphType = (annotation, paragraph) => { -- cgit v1.2.3-70-g09d2