Skip to content

Commit

Permalink
forbid empty values for lemma and form
Browse files Browse the repository at this point in the history
  • Loading branch information
khansadaoudi committed Nov 22, 2024
1 parent 5180a74 commit 4f6c947
Show file tree
Hide file tree
Showing 5 changed files with 85 additions and 13 deletions.
1 change: 1 addition & 0 deletions src/components/sentence/AttributeTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
dense
:options="computeValueOptions(props.row)"
@input-value="onInput()"
:rules="[(val) => (val && val.length > 0) || $t('attributeTable.feat')]"
>
</q-select>
</q-td>
Expand Down
57 changes: 48 additions & 9 deletions src/components/sentence/ConlluDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,41 @@
</q-td>
<q-td key="FORM" :props="props">
{{ props.row.FORM }}
<q-popup-edit v-model="props.row.FORM" auto-save v-slot="scope" >
<q-input v-model="scope.value" dense autofocus />
<q-popup-edit
v-model="props.row.FORM"
buttons
label-set="Save"
label-cancel="Close"
:validate="checkForm"
v-slot="scope"
>
<q-input
v-model="scope.value"
dense
autofocus
:error="formatErrorTable.FORM.error"
:error-message="formatErrorTable.FORM.message"
/>
</q-popup-edit>
</q-td>
<q-td key="LEMMA" :props="props">
{{ props.row.LEMMA }}
<q-popup-edit v-if="!props.row.ID.includes('-')" v-model="props.row.LEMMA" auto-save v-slot="scope" >
<q-input v-model="scope.value" dense autofocus />
<q-popup-edit
v-if="!props.row.ID.includes('-')"
v-model="props.row.LEMMA"
buttons
label-set="Save"
label-cancel="Close"
:validate="checkLemma"
v-slot="scope"
>
<q-input
v-model="scope.value"
dense
autofocus
:error="formatErrorTable.LEMMA.error"
:error-message="formatErrorTable.LEMMA.message"
/>
</q-popup-edit>
</q-td>
<q-td key="UPOS" :props="props">
Expand Down Expand Up @@ -206,7 +233,7 @@ export default defineComponent({
data() {
const conllTable: any[] = [];
const conllColumns = ['ID', 'FORM', 'LEMMA', 'UPOS', 'XPOS', 'FEATS', 'HEAD', 'DEPREL', 'DEPS', 'MISC'];
const conllColumnsToCheck = ['UPOS', 'FEATS', 'HEAD', 'DEPREL'];
const conllColumnsToCheck = ['FORM', 'LEMMA', 'UPOS', 'FEATS', 'HEAD', 'DEPREL'];
const nodesJson: nodesJson_T = {};
const groupsJson: groupsJson_T = {};
const table: table_t<tokenJson_T> = {
Expand Down Expand Up @@ -286,9 +313,9 @@ export default defineComponent({
this.conllTable.push({
...node,
HEAD: node.HEAD === -1 ? '_' : node.HEAD,
FEATS: this.formatTableEntry(node.FEATS, '='),
DEPS: this.formatTableEntry(node.DEPS, ':'),
MISC: this.formatTableEntry(node.MISC, '='),
FEATS: node.FEATS.length ? this.formatTableEntry(node.FEATS, '=') : '_',
DEPS: node.DEPS.length ? this.formatTableEntry(node.DEPS, ':') : '_',
MISC: node.MISC.length ? this.formatTableEntry(node.MISC, '='): '_',
});
}
},
Expand Down Expand Up @@ -354,14 +381,26 @@ export default defineComponent({
notifyMessage({ message: 'Conll Copied!' });
});
},
checkLemma(val: string) {
if (val === '') {
return this.setError('LEMMA', true, 'Lemma must not be empty');
}
return this.setError('LEMMA', false, '');
},
checkForm(val: string) {
if (val === '') {
return this.setError('FORM', true, 'Form must not be empty');
}
return this.setError('FORM', false, '');
},
checkUPOS(val: string) {
if(!this.annotationFeatures.UPOS.includes(val) && val !== '_') {
return this.setError('UPOS', true, 'This UPOS does not exist in your annotation config');
}
return this.setError('UPOS', false, '');
},
checkHEAD(val: number) {
if (val !== -1 && (val < 0 || val > this.conllTable.length)) {
if ((val !== -1 && (val < 0 || val > this.conllTable.length)) || String(val) === "") {
return this.setError('HEAD', true, 'HEAD value must be either -1 or 0 or < sentence length');
}
return this.setError('HEAD', false, '');
Expand Down
34 changes: 30 additions & 4 deletions src/components/sentence/FeaturesDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,18 @@
</q-bar>

<q-card-section class="q-gutter-md">
<q-input outlined v-model="form" label="FORM" />
<q-input outlined v-model="lemma" label="LEMMA" />
<q-input
outlined
v-model="form"
label="FORM"
:rules="[(val) => (val && val.length > 0) || $t('attributeTable.form')]"
/>
<q-input
outlined
v-model="lemma"
label="LEMMA"
:rules="[(val) => (val && val.length > 0) || $t('attributeTable.lemma')]"
/>
<q-separator />
</q-card-section>

Expand Down Expand Up @@ -51,8 +61,21 @@
</q-card-section>

<q-card-actions class="sticky-card-actions" align="around">
<q-btn v-close-popup outline color="primary" :label="$t('cancel')" style="width: 45%; margin-left: auto; margin-right: auto" />
<q-btn v-close-popup color="primary" label="Ok" style="width: 45%; margin-left: auto; margin-right: auto" @click="onFeatureDialogOk()" />
<q-btn
v-close-popup
outline
color="primary"
:label="$t('cancel')"
style="width: 45%; margin-left: auto; margin-right: auto"
/>
<q-btn
v-close-popup
color="primary"
label="Ok"
style="width: 45%; margin-left: auto; margin-right: auto"
@click="onFeatureDialogOk()"
:disable="disableBtn"
/>
</q-card-actions>
</q-card>
</q-dialog>
Expand Down Expand Up @@ -125,6 +148,9 @@ export default defineComponent({
},
computed: {
...mapState(useProjectStore, ['annotationFeatures']),
disableBtn() {
return this.form === '' || this.lemma === '';
},
},
mounted() {
this.sentenceBus.on('open:featuresDialog', ({ token, userId }) => {
Expand Down
3 changes: 3 additions & 0 deletions src/i18n/en-us/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,9 @@ export default {
metadata: 'Metadata of this sentence',
relation: ['Select a relation going from', 'to', 'current'],
tokenReplaceDial: ['Replacing', 'by', 'Changing tokens breaks the comparability of different annotations of the same sentence', 'Replacement'],
form: 'The form value must not be empty. If the form has no value, use the underscore',
lemma: 'The lemma value must not be empty. If the lemma has no value; use the underscore',
feat: 'Do not forget to fill the feature value',
},
constructicon: {
uploadBtn: 'Upload constructicon',
Expand Down
3 changes: 3 additions & 0 deletions src/i18n/fr-fra/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,9 @@ export default {
'Remplacement',
],
proposedMetadata: 'Les métadonnées proposées',
form: "La valeur de la forme ne doit pas être vide. Si la forme n'a pas une valeur utiliser le trait de soulignement.",
lemma: "La valeur du lemme ne doit pas être vide. Si le lemme n'a pas une valeur utiliser le trait de soulignement.",
feat: "N'oubliez pas d'introduire la valeur de cette feat",
},
constructicon: {
uploadBtn: 'Importer un constructicon',
Expand Down

0 comments on commit 4f6c947

Please sign in to comment.