Skip to content

Commit

Permalink
update frontend of grew search and get config features based on the n…
Browse files Browse the repository at this point in the history
…ew grew services
  • Loading branch information
khansadaoudi committed Dec 10, 2024
1 parent ed7aba3 commit a58f294
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 31 deletions.
67 changes: 44 additions & 23 deletions src/components/project/DetectedTagSetDial.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,36 @@
</q-card-section>
<q-card-section v-if="selectedPos.length">
<div class="text-h6">UPOS</div>
<q-checkbox class="row q-gutter-md q-pa-md" v-for="(upos, index) in newPos" v-model="selectedPos[index]" :label="upos" />
<q-checkbox
class="row q-gutter-md q-pa-md"
v-for="(upos, index) in newPos"
v-model="selectedPos[index]"
:label="upos"
/>
</q-card-section>
<q-card-section v-if="selectedFeats.length">
<div class="text-h6">Features</div>
<div class="row q-gutter-md q-pa-md" v-for="(feat, index) in newFeats">
<q-checkbox class="col" v-model="selectedFeats[index].select" :label="feat" />
<q-select class="col" dense outlined v-model="selectedFeats[index].option" :options="featsOptions" label="Choose the type of the feature" />
</div>
<q-checkbox
class="row q-gutter-md q-pa-md"
v-for="(feat, index) in newFeats"
v-model="selectedFeats[index]"
:label="feat"
/>
</q-card-section>
<q-card-section v-if="selectedMisc.length">
<div class="text-h6">misc</div>
<q-checkbox
class="row q-gutter-md q-pa-md"
v-for="(feat, index) in newMisc"
v-model="selectedMisc[index]"
:label="feat"
/>
</q-card-section>
<q-card-section v-if="selectedRelations.length">
<div class="text-h6">Relations</div>
<div class="row q-gutter-md q-pa-md" v-for="(rel, index) in newRel">
<q-checkbox class="col" v-model="selectedRelations[index].select" :label="rel" />
<q-select class="col" dense outlined v-model="selectedRelations[index].option" :options="deprelOptions" label="Choose the type of the dependency relation"></q-select>
<q-checkbox class="col" v-model="selectedRelations[index]" :label="rel.value" />
<q-input class="col" dense outlined readonly v-model="annotationFeatures.DEPREL[rel.index].name" />
</div>
</q-card-section>
<q-card-actions align="around">
Expand All @@ -49,21 +65,25 @@ export default defineComponent({
type: Object as PropType<string[]>,
required: true,
},
newMisc: {
type: Object as PropType<string[]>,
required: true,
},
newPos: {
type: Object as PropType<string[]>,
required: true,
},
newRel: {
type: Object as PropType<string[]>,
type: Object as PropType<any[]>,
required: true,
}
},
data() {
return {
selectedPos: [] as boolean[],
selectedFeats: [] as { select: boolean, option: string }[],
selectedRelations: [] as { select: boolean, option: string } [],
featsOptions: ['FEATS', 'MISC'],
selectedFeats: [] as boolean[],
selectedMisc: [] as boolean[],
selectedRelations: [] as boolean[],
deprelOptions: [] as string[],
currentAnnotationSchema: {} as annotationFeatures_t,
}
Expand All @@ -73,8 +93,9 @@ export default defineComponent({
},
mounted() {
this.selectedPos = this.newPos.map(() => false);
this.selectedFeats = this.newFeats.map(() => ({ select: false, option: 'FEATS' }))
this.selectedRelations = this.newRel.map(() => ({ select: false, option: this.annotationFeatures.DEPREL[0].name }))
this.selectedFeats = this.newFeats.map(() => false);
this.selectedMisc = this.newMisc.map(() => false);
this.selectedRelations = this.newRel.map(() => false);
this.deprelOptions = this.annotationFeatures.DEPREL.map((deprel) => deprel.name);
},
methods: {
Expand All @@ -86,19 +107,19 @@ export default defineComponent({
}
}
for (const feat in this.selectedFeats) {
if (this.selectedFeats[feat].select) {
if (this.selectedFeats[feat].option === 'FEATS') {
this.annotationFeatures.FEATS.push({ name: this.newFeats[feat], values: []});
}
else {
this.annotationFeatures.MISC.push({ name: this.newFeats[feat], values: [] });
}
if (this.selectedFeats[feat]) {
this.annotationFeatures.FEATS.push({ name: this.newFeats[feat], values: [] });
}
}
for (const misc in this.selectedMisc) {
if (this.selectedMisc[misc]) {
this.annotationFeatures.MISC.push({ name: this.newMisc[misc], values: [] });
}
}
for (const deprel in this.selectedRelations) {
if (this.selectedRelations[deprel].select) {
const index = this.annotationFeatures.DEPREL.map(deprel => deprel.name).indexOf(this.selectedRelations[deprel].option)
this.annotationFeatures.DEPREL[index].values.push(this.newRel[deprel]);
if (this.selectedRelations[deprel]) {
const index = this.newRel[deprel].index;
this.annotationFeatures.DEPREL[index].values.push(this.newRel[deprel].value);
}
}
this.updateProjectConlluSchema(this.name, this.annotationFeatures, this.currentAnnotationSchema);
Expand Down
23 changes: 18 additions & 5 deletions src/components/project/UploadDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,13 @@
</q-card>
</q-dialog>
<q-dialog v-model="hasNewFeatures">
<DetectedTagSetDial :new-feats="newFeatsList" :new-pos="newPosList" :new-rel="newRelationsList" @reload-tags-list="reloadDetectedTagsList" />
<DetectedTagSetDial
:new-feats="newFeatsList"
:new-pos="newPosList"
:new-rel="newRelationsList"
:new-misc="newMiscList"
@reload-tags-list="reloadDetectedTagsList"
/>
</q-dialog>
</template>

Expand Down Expand Up @@ -226,11 +232,13 @@ export default defineComponent({
rtl: false,
userId: 'username',
featsList: [] as string[],
miscList: [] as string[],
posList: [] as string[],
relationsList: [] as string[],
newFeatsList: [] as string[],
newMiscList: [] as string[],
newPosList: [] as string[],
newRelationsList: [] as string[],
newRelationsList: [] as { value: string, index: number }[],
};
},
Expand All @@ -257,7 +265,7 @@ export default defineComponent({
return disable;
},
hasNewFeatures() {
return this.newFeatsList.length > 0 || this.newPosList.length > 0 || this.newRelationsList.length > 0;
return this.newFeatsList.length > 0 || this.newPosList.length > 0 || this.newRelationsList.length > 0 || this.newMiscList.length > 0;
}
},
methods: {
Expand Down Expand Up @@ -345,6 +353,7 @@ export default defineComponent({
this.uploadDialModel = false;
this.uploadSample.submitting = false;
this.featsList = response.data.data.feats;
this.miscList = response.data.data.misc;
this.posList = response.data.data.pos;
this.relationsList = response.data.data.relations;
this.checkNewFeats();
Expand All @@ -368,13 +377,16 @@ export default defineComponent({
const splitRegex = new RegExp(`[${deprels.map(({ join }) => join).join('')}]`, 'g');
this.newPosList = this.posList.filter(pos => !annotationUpos.includes(pos));
this.newFeatsList = this.featsList.filter(feat => !annotationFeats.includes(feat) && !annotationMisc.includes(feat));
this.newFeatsList = this.featsList.filter(feat => !annotationFeats.includes(feat));
this.newMiscList = this.miscList.filter(misc => !annotationMisc.includes(misc));
for (const relation of this.relationsList) {
const splittedRel = relation.split(splitRegex);
let index = 0;
for (const subRel of splittedRel) {
const found = deprels.some(({ values, join }) => values.includes(subRel) && relation.includes(join + subRel));
if (!found) this.newRelationsList.push(subRel);
index += 1;
if (!found) this.newRelationsList.push({ value: subRel, index: index });
}
}
},
Expand Down Expand Up @@ -420,6 +432,7 @@ export default defineComponent({
this.newFeatsList = [];
this.newPosList = [];
this.newRelationsList = [];
this.newMiscList = [];
}
},
});
Expand Down
3 changes: 1 addition & 2 deletions src/components/shared/TreesTypeSelect.vue
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ export default defineComponent({
{ value: 'recent', label: this.$t('grewSearch.recentTree'), icon: 'schedule' },
{ value: 'user', label: this.$t('grewSearch.userTree') },
{ value: 'validated', label: this.$t('grewSearch.validatedTree'), icon: 'verified' },
{ value: 'pending', label: this.$t('grewSearch.pendingTree'), icon: 'pending' },
{ value: 'all', label: this.$t('grewSearch.allTree'), icon: 'groups' },
{ value: 'base_tree', label: this.$t('grewSearch.baseTree'), icon: 'linear_scale' },
{ value: 'others', label: this.$t('grewSearch.otherTree'), icon: 'group' },
Expand All @@ -129,7 +128,7 @@ export default defineComponent({
if (this.grewOption != 'REWRITE') {
return this.treeTypes.filter((element) => this.grewTreeTypes.includes(element.value));
} else {
return this.treeTypes.filter((element) => this.grewTreeTypes.includes(element.value) && !['all', 'pending'].includes(element.value));
return this.treeTypes.filter((element) => this.grewTreeTypes.includes(element.value) && 'all' !== element.value);
}
},
treesFrom() {
Expand Down
2 changes: 1 addition & 1 deletion src/pinia/modules/grewSearch/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export const useGrewSearchStore = defineStore('grewSearch', {
return {
reloadGrew: 0,
lastQuery: null as null | { text: string; type: 'REWRITE' | 'SEARCH'; userType: string },
treeTypes: ['user', 'user_recent', 'recent', 'validated', 'pending', 'base_tree', 'all', 'others'],
treeTypes: ['user', 'user_recent', 'recent', 'validated', 'base_tree', 'all', 'others'],
};
},
getters: {
Expand Down

0 comments on commit a58f294

Please sign in to comment.