Skip to content

Commit

Permalink
fix the merge of undefined metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
khansadaoudi committed Aug 7, 2024
1 parent 8b49090 commit 2d29412
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/components/sentence/SentenceSegmentation.vue
Original file line number Diff line number Diff line change
Expand Up @@ -486,12 +486,14 @@ export default defineComponent({
mergedSentence.metaJson = {
...firstSentenceJson.metaJson,
...secondSentenceJson.metaJson,
text: firstSentenceJson.metaJson.text + ' ' + secondSentenceJson.metaJson.text,
text_en: firstSentenceJson.metaJson.text_en + ' ' + secondSentenceJson.metaJson.text_en,
phonetic_text: firstSentenceJson.metaJson.phonetic_text + ' ' + secondSentenceJson.metaJson.phonetic_text,
timestamp: firstSentenceJson.metaJson.timestamp > secondSentenceJson.metaJson.timestamp ? firstSentenceJson.metaJson.timestamp: secondSentenceJson.metaJson.timestamp,
sent_id: this.proposeMergedSentId(firstSentenceJson.metaJson.sent_id as string, secondSentenceJson.metaJson.sent_id as string),
};
for (const key of Object.keys(firstSentenceJson.metaJson).filter(key => key.includes('text'))) {
if (Object.keys(secondSentenceJson.metaJson).includes(key)) {
mergedSentence.metaJson[key] = `${firstSentenceJson.metaJson[key]} ${secondSentenceJson.metaJson[key]}`
}
}
return mergedSentence;
},
proposeMergedSentId(firstSentId: string, secondSentId: string) {
Expand Down

0 comments on commit 2d29412

Please sign in to comment.