From 71a2b8de701cc2d4058ff3d42c8183399fda3b95 Mon Sep 17 00:00:00 2001 From: Naafiyan Ahmed Date: Thu, 28 Apr 2022 21:35:48 -0400 Subject: working on mapping algo --- src/client/views/InkTranscription.tsx | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/client/views/InkTranscription.tsx b/src/client/views/InkTranscription.tsx index e14a933a0..dd365e1ab 100644 --- a/src/client/views/InkTranscription.tsx +++ b/src/client/views/InkTranscription.tsx @@ -1,7 +1,7 @@ import * as iink from 'iink-js'; import { action, observable } from 'mobx'; import * as React from 'react'; -import { Doc, DocListCast } from '../../fields/Doc'; +import { DataSym, Doc, DocListCast } from '../../fields/Doc'; import { InkData, InkField } from "../../fields/InkField"; import { Cast, DateCast, NumCast } from '../../fields/Types'; import { DocumentType } from "../documents/DocumentTypes"; @@ -184,6 +184,38 @@ export class InkTranscription extends React.Component { if (exports['application/vnd.myscript.jiix']) { this.lastJiix = JSON.parse(exports['application/vnd.myscript.jiix']); // map timestamp to strokes + const timestampWord = new Map(); + this.lastJiix.words.map((word: any) => { + word.items.map((i: any) => { + const ms = Date.parse(i.timestamp); + timestampWord.set(ms, word.label); + }) + }) + + + const wordInkDocMap = new Map(); + if (this.currGroup) { + const docList = DocListCast(this.currGroup.data) + docList.forEach((inkDoc: Doc) => { + const ms = DateCast(inkDoc.creationDate).getDate().getTime(); + const word = timestampWord.get(ms); + if (!word) { + return; + } + const entry = wordInkDocMap.get(word); + if (entry) { + entry.push(inkDoc); + wordInkDocMap.set(word, entry); + } else { + const newEntry = [inkDoc]; + wordInkDocMap.set(word, newEntry); + } + + }); + console.log("getting here"); + console.log(wordInkDocMap); + + } // we can iterate through docs and for each doc index into the map by timestamp // final mapping should be word to inkDoc -- cgit v1.2.3-70-g09d2