Skip to content

Commit

Permalink
unique corpus_id
Browse files Browse the repository at this point in the history
  • Loading branch information
parkchamchi committed Oct 17, 2024
1 parent 1701145 commit 266d44b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/backend/gs_index/src/components/Corpus.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
sharedState,
showPre: false,
mounted: false,
}
},
computed: {
Expand Down Expand Up @@ -229,14 +230,18 @@
this.reannotate([p_index], target_tokens);
},
},
mounted() {
this.mounted = true;
}
}
</script>

<template>
<div class='corpus_wrapper'>
<hr>
<h4 @click="toggleCorpusVisibility()">{{ header + ": " + corpus_id }}</h4>
<div v-if="isCorpusVisible" class="corpus">
<div v-if="mounted && isCorpusVisible" class="corpus">
<span class="corpus_buttons_span">
<button class="corpus_button btn btn-light" @click="download()">Download</button>

Expand Down
15 changes: 14 additions & 1 deletion src/backend/gs_index/src/components/CorpusesView.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<script>
import { EventBus } from "../EventBus.js";
import { GsApi } from "../GsApi.js"
import { sharedState } from "../sharedState.js";
import sampleCorpuses from "../sampleCorpuses.json"
import Corpus from "./Corpus.vue"
Expand Down Expand Up @@ -52,8 +53,17 @@
})*/;
},
async addLocalCorpus({corpus_id, corpus}) {
//corpus_id to be unique and not ""
let unique_corpus_id = corpus_id;
if (unique_corpus_id == "") unique_corpus_id = "Corpus";
const existingIds = new Set(this.localCorpuses.map(c => c.corpus_id));
let counter = 1;
while (existingIds.has(unique_corpus_id))
unique_corpus_id = `${corpus_id} (${counter++})`;
this.localCorpuses.push({
"corpus_id": corpus_id,
"corpus_id": unique_corpus_id,
"corpuses_history": [corpus],
});
},
Expand All @@ -68,6 +78,9 @@
this.getRemoteSamples();
},
mounted() {
sharedState.currentOpenCorpus = "";
},
beforeDestroy() {
EventBus.off("updateCorpuses", this.updateCorpuses); // Clean up the event listener
EventBus.off("addLocalCorpus", this.addLocalCorpus); // From UploadView
Expand Down

0 comments on commit 266d44b

Please sign in to comment.