synyi / poplar

A web-based annotation tool for natural language processing (NLP)
https://synyi.github.io/poplar/
GNU General Public License v3.0
519 stars 138 forks source link

似乎并没有提供对labelcategory和Connectioncategory的增删改查操作? #143

Open VelikayaScarlet opened 10 months ago

VelikayaScarlet commented 10 months ago

vue.esm.js:591 [Vue warn]: Error in event handler for "click": "TypeError: Cannot read properties of undefined (reading 'trim')"

found in

--->

at src\components\Demo.vue at src\App.vue warn @ vue.esm.js:591 logError @ vue.esm.js:1737 globalHandleError @ vue.esm.js:1732 handleError @ vue.esm.js:1721 Vue.$emit @ vue.esm.js:2540 click @ vuetify.js:1363 invoker @ vue.esm.js:2027 fn._withTask.fn._withTask @ vue.esm.js:1826 vue.esm.js:1741 TypeError: Cannot read properties of undefined (reading 'trim') at t.construct (index.js:16:1) at t.set [as json] (index.js:16:1) at VueComponent.addLabel (Demo.vue:329:1) at VueComponent.invoker (vue.esm.js:2027:1) at Vue.$emit (vue.esm.js:2538:1) at VueComponent.click (vuetify.js:1363:1) at invoker (vue.esm.js:2027:1) at fn._withTask.fn._withTask (vue.esm.js:1826:1) logError @ vue.esm.js:1741 globalHandleError @ vue.esm.js:1732 handleError @ vue.esm.js:1721 Vue.$emit @ vue.esm.js:2540 click @ vuetify.js:1363 invoker @ vue.esm.js:2027 fn._withTask.fn._withTask @ vue.esm.js:1826
VelikayaScarlet commented 10 months ago

已解决 addLabel: function() { let jsonData = JSON.stringify(this.annotator.store.json, null, 2); let list = JSON.parse(jsonData); const newLabelCategory = { id: list.labelCategories.length, text: this.addLabelText, color: this.getRandomColor(), borderColor: this.getRandomColor() }; this.annotator.store.labelCategoryRepo.add(newLabelCategory) this.getCode() },

VelikayaScarlet commented 10 months ago
        addLabel: function() {
          let newID = -1;
          for (let [_, category] of this.annotator.store.labelCategoryRepo) {
              newID = category["id"]+1
          }
          const newLabelCategory = {
            id: newID, 
            text: this.addLabelText,
            color: this.getRandomColor(),
            borderColor: this.getRandomColor()
          };
          this.annotator.store.labelCategoryRepo.add(newLabelCategory)
          console.log(this.labelCategories);
          this.getCode()
        },