Browse Source

Update progress

pull/10/head
Hironsan 6 years ago
parent
commit
d3efe63078
8 changed files with 32 additions and 26 deletions
  1. BIN
      app/db.sqlite3
  2. 4
      app/server/static/bundle/document_classification.js
  3. 4
      app/server/static/bundle/seq2seq.js
  4. 4
      app/server/static/bundle/sequence_labeling.js
  5. 3
      app/server/static/js/document_classification.js
  6. 25
      app/server/static/js/mixin.js
  7. 1
      app/server/static/js/seq2seq.js
  8. 17
      app/server/static/js/sequence_labeling.js

BIN
app/db.sqlite3

4
app/server/static/bundle/document_classification.js

@ -161,7 +161,7 @@ eval("var g;\n\n// This works in non-strict mode\ng = (function() {\n\treturn th
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var vue__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! vue */ \"./node_modules/vue/dist/vue.esm.js\");\n/* harmony import */ var _mixin_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./mixin.js */ \"./static/js/mixin.js\");\n/* harmony import */ var _http_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./http.js */ \"./static/js/http.js\");\n\nvue__WEBPACK_IMPORTED_MODULE_0__[\"default\"].use(__webpack_require__(/*! vue-shortkey */ \"./node_modules/vue-shortkey/dist/index.js\"), { prevent: ['input', 'textarea'] });\n\n\n\nvar vm = new vue__WEBPACK_IMPORTED_MODULE_0__[\"default\"]({\n el: '#mail-app',\n delimiters: ['[[', ']]'],\n mixins: [_mixin_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"]],\n\n methods: {\n addLabel: async function (label_id) {\n for (var i = 0; i < this.items[this.cur]['labels'].length; i++) {\n var item = this.items[this.cur]['labels'][i];\n if (label_id == item.label.id) {\n this.deleteLabel(i);\n return;\n }\n }\n\n var payload = {\n 'label_id': label_id\n };\n\n var doc_id = this.items[this.cur].id;\n await _http_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].post(`docs/${doc_id}/annotations/`, payload).then(response => {\n this.items[this.cur]['labels'].push(response.data);\n });\n this.updateProgress();\n }\n }\n});\n\n//# sourceURL=webpack:///./static/js/document_classification.js?");
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var vue__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! vue */ \"./node_modules/vue/dist/vue.esm.js\");\n/* harmony import */ var _mixin_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./mixin.js */ \"./static/js/mixin.js\");\n/* harmony import */ var _http_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./http.js */ \"./static/js/http.js\");\n\nvue__WEBPACK_IMPORTED_MODULE_0__[\"default\"].use(__webpack_require__(/*! vue-shortkey */ \"./node_modules/vue-shortkey/dist/index.js\"), { prevent: ['input', 'textarea'] });\n\n\n\nvar vm = new vue__WEBPACK_IMPORTED_MODULE_0__[\"default\"]({\n el: '#mail-app',\n delimiters: ['[[', ']]'],\n mixins: [_mixin_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"]],\n\n methods: {\n addLabel: async function (label_id) {\n for (var i = 0; i < this.items[this.cur]['labels'].length; i++) {\n var item = this.items[this.cur]['labels'][i];\n if (label_id == item.label.id) {\n this.deleteLabel(i);\n return;\n }\n }\n\n var payload = {\n 'label_id': label_id\n };\n\n var doc_id = this.items[this.cur].id;\n await _http_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].post(`docs/${doc_id}/annotations/`, payload).then(response => {\n this.items[this.cur]['labels'].push(response.data);\n })\n }\n }\n});\n\n//# sourceURL=webpack:///./static/js/document_classification.js?");
/***/ }),
@ -185,7 +185,7 @@ eval("__webpack_require__.r(__webpack_exports__);\naxios.defaults.xsrfCookieName
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var _http_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./http.js */ \"./static/js/http.js\");\n\n\nvar annotationMixin = {\n data: function () {\n return {\n cur: 0,\n items: [{\n id: null,\n text: '',\n labels: []\n }],\n labels: [],\n guideline: 'Here is the Annotation Guideline Text',\n total: 0,\n remaining: 0,\n searchQuery: '',\n url: '',\n picked: 'all',\n }\n },\n methods: {\n nextPage: async function () {\n this.cur += 1;\n if (this.cur == this.items.length) {\n if (this.next) {\n this.url = this.next;\n await this.search();\n this.cur = 0;\n } else {\n this.cur = this.items.length - 1;\n }\n }\n this.showMessage(this.cur);\n },\n prevPage: async function () {\n this.cur -= 1;\n if (this.cur == -1) {\n if (this.prev) {\n this.url = this.prev;\n await this.search();\n this.cur = this.items.length - 1;\n } else {\n this.cur = 0;\n }\n }\n this.showMessage(this.cur);\n },\n search: async function () {\n await _http_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].get(this.url).then(response => {\n this.items = response.data['results'];\n this.next = response.data['next'];\n this.prev = response.data['previous'];\n })\n },\n showMessage: function (index) {\n this.cur = index;\n },\n getState: function () {\n if (this.picked == 'all') {\n return ''\n } else if (this.picked == 'active') {\n return 'true'\n } else {\n return 'false'\n }\n },\n submit: async function () {\n var state = this.getState();\n this.url = `docs/?q=${this.searchQuery}&is_checked=${state}`;\n await this.search();\n this.cur = 0;\n },\n updateProgress: function () {\n _http_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].get('progress').then(response => {\n this.total = response.data['total'];\n this.remaining = response.data['remaining'];\n })\n },\n deleteLabel: async function (index) {\n var doc_id = this.items[this.cur].id;\n var annotation_id = this.items[this.cur]['labels'][index].id;\n _http_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].delete(`docs/${doc_id}/annotations/${annotation_id}`).then(response => {\n this.items[this.cur]['labels'].splice(index, 1)\n });\n this.updateProgress();\n }\n },\n watch: {\n picked: function (){\n this.submit();\n }\n },\n created: function () {\n _http_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].get('labels').then(response => {\n this.labels = response.data\n });\n this.updateProgress();\n this.submit();\n },\n computed: {\n achievement: function () {\n var done = this.total - this.remaining;\n var percentage = Math.round(done / this.total * 100);\n return this.total > 0 ? percentage : 0;\n },\n progressColor: function () {\n if (this.achievement < 30) {\n return 'is-danger'\n } else if (this.achievement < 70) {\n return 'is-warning'\n } else {\n return 'is-primary'\n }\n }\n }\n};\n\n/* harmony default export */ __webpack_exports__[\"default\"] = (annotationMixin);\n\n//# sourceURL=webpack:///./static/js/mixin.js?");
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var _http_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./http.js */ \"./static/js/http.js\");\n\n\nvar annotationMixin = {\n data: function () {\n return {\n cur: 0,\n items: [{\n id: null,\n text: '',\n labels: []\n }],\n labels: [],\n guideline: 'Here is the Annotation Guideline Text',\n total: 0,\n remaining: 0,\n searchQuery: '',\n url: '',\n picked: 'all',\n }\n },\n methods: {\n nextPage: async function () {\n this.cur += 1;\n if (this.cur == this.items.length) {\n if (this.next) {\n this.url = this.next;\n await this.search();\n this.cur = 0;\n } else {\n this.cur = this.items.length - 1;\n }\n }\n this.showMessage(this.cur);\n },\n prevPage: async function () {\n this.cur -= 1;\n if (this.cur == -1) {\n if (this.prev) {\n this.url = this.prev;\n await this.search();\n this.cur = this.items.length - 1;\n } else {\n this.cur = 0;\n }\n }\n this.showMessage(this.cur);\n },\n search: async function () {\n await _http_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].get(this.url).then(response => {\n this.items = response.data['results'];\n this.next = response.data['next'];\n this.prev = response.data['previous'];\n })\n },\n showMessage: function (index) {\n this.cur = index;\n },\n getState: function () {\n if (this.picked == 'all') {\n return ''\n } else if (this.picked == 'active') {\n return 'true'\n } else {\n return 'false'\n }\n },\n submit: async function () {\n var state = this.getState();\n this.url = `docs/?q=${this.searchQuery}&is_checked=${state}`;\n await this.search();\n this.cur = 0;\n },\n deleteLabel: async function (index) {\n var doc_id = this.items[this.cur].id;\n var annotation_id = this.items[this.cur]['labels'][index].id;\n _http_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].delete(`docs/${doc_id}/annotations/${annotation_id}`).then(response => {\n this.items[this.cur]['labels'].splice(index, 1)\n })\n },\n\n removeLabel: function (label) {\n var doc_id = this.items[this.cur].id;\n _http_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].delete(`docs/${doc_id}/annotations/${label.id}`).then(response => {\n var index = this.items[this.cur]['labels'].indexOf(label)\n this.items[this.cur]['labels'].splice(index, 1)\n })\n }\n },\n watch: {\n picked: function (){\n this.submit();\n },\n items: function () {\n // fetch progress info.\n _http_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].get('progress').then(response => {\n this.total = response.data['total'];\n this.remaining = response.data['remaining'];\n })\n }\n },\n created: function () {\n _http_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].get('labels').then(response => {\n this.labels = response.data\n });\n this.submit();\n },\n computed: {\n achievement: function () {\n var done = this.total - this.remaining;\n var percentage = Math.round(done / this.total * 100);\n return this.total > 0 ? percentage : 0;\n },\n progressColor: function () {\n if (this.achievement < 30) {\n return 'is-danger'\n } else if (this.achievement < 70) {\n return 'is-warning'\n } else {\n return 'is-primary'\n }\n }\n }\n};\n\n/* harmony default export */ __webpack_exports__[\"default\"] = (annotationMixin);\n\n//# sourceURL=webpack:///./static/js/mixin.js?");
/***/ })

4
app/server/static/bundle/seq2seq.js

@ -173,7 +173,7 @@ eval("__webpack_require__.r(__webpack_exports__);\naxios.defaults.xsrfCookieName
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var _http_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./http.js */ \"./static/js/http.js\");\n\n\nvar annotationMixin = {\n data: function () {\n return {\n cur: 0,\n items: [{\n id: null,\n text: '',\n labels: []\n }],\n labels: [],\n guideline: 'Here is the Annotation Guideline Text',\n total: 0,\n remaining: 0,\n searchQuery: '',\n url: '',\n picked: 'all',\n }\n },\n methods: {\n nextPage: async function () {\n this.cur += 1;\n if (this.cur == this.items.length) {\n if (this.next) {\n this.url = this.next;\n await this.search();\n this.cur = 0;\n } else {\n this.cur = this.items.length - 1;\n }\n }\n this.showMessage(this.cur);\n },\n prevPage: async function () {\n this.cur -= 1;\n if (this.cur == -1) {\n if (this.prev) {\n this.url = this.prev;\n await this.search();\n this.cur = this.items.length - 1;\n } else {\n this.cur = 0;\n }\n }\n this.showMessage(this.cur);\n },\n search: async function () {\n await _http_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].get(this.url).then(response => {\n this.items = response.data['results'];\n this.next = response.data['next'];\n this.prev = response.data['previous'];\n })\n },\n showMessage: function (index) {\n this.cur = index;\n },\n getState: function () {\n if (this.picked == 'all') {\n return ''\n } else if (this.picked == 'active') {\n return 'true'\n } else {\n return 'false'\n }\n },\n submit: async function () {\n var state = this.getState();\n this.url = `docs/?q=${this.searchQuery}&is_checked=${state}`;\n await this.search();\n this.cur = 0;\n },\n updateProgress: function () {\n _http_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].get('progress').then(response => {\n this.total = response.data['total'];\n this.remaining = response.data['remaining'];\n })\n },\n deleteLabel: async function (index) {\n var doc_id = this.items[this.cur].id;\n var annotation_id = this.items[this.cur]['labels'][index].id;\n _http_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].delete(`docs/${doc_id}/annotations/${annotation_id}`).then(response => {\n this.items[this.cur]['labels'].splice(index, 1)\n });\n this.updateProgress();\n }\n },\n watch: {\n picked: function (){\n this.submit();\n }\n },\n created: function () {\n _http_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].get('labels').then(response => {\n this.labels = response.data\n });\n this.updateProgress();\n this.submit();\n },\n computed: {\n achievement: function () {\n var done = this.total - this.remaining;\n var percentage = Math.round(done / this.total * 100);\n return this.total > 0 ? percentage : 0;\n },\n progressColor: function () {\n if (this.achievement < 30) {\n return 'is-danger'\n } else if (this.achievement < 70) {\n return 'is-warning'\n } else {\n return 'is-primary'\n }\n }\n }\n};\n\n/* harmony default export */ __webpack_exports__[\"default\"] = (annotationMixin);\n\n//# sourceURL=webpack:///./static/js/mixin.js?");
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var _http_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./http.js */ \"./static/js/http.js\");\n\n\nvar annotationMixin = {\n data: function () {\n return {\n cur: 0,\n items: [{\n id: null,\n text: '',\n labels: []\n }],\n labels: [],\n guideline: 'Here is the Annotation Guideline Text',\n total: 0,\n remaining: 0,\n searchQuery: '',\n url: '',\n picked: 'all',\n }\n },\n methods: {\n nextPage: async function () {\n this.cur += 1;\n if (this.cur == this.items.length) {\n if (this.next) {\n this.url = this.next;\n await this.search();\n this.cur = 0;\n } else {\n this.cur = this.items.length - 1;\n }\n }\n this.showMessage(this.cur);\n },\n prevPage: async function () {\n this.cur -= 1;\n if (this.cur == -1) {\n if (this.prev) {\n this.url = this.prev;\n await this.search();\n this.cur = this.items.length - 1;\n } else {\n this.cur = 0;\n }\n }\n this.showMessage(this.cur);\n },\n search: async function () {\n await _http_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].get(this.url).then(response => {\n this.items = response.data['results'];\n this.next = response.data['next'];\n this.prev = response.data['previous'];\n })\n },\n showMessage: function (index) {\n this.cur = index;\n },\n getState: function () {\n if (this.picked == 'all') {\n return ''\n } else if (this.picked == 'active') {\n return 'true'\n } else {\n return 'false'\n }\n },\n submit: async function () {\n var state = this.getState();\n this.url = `docs/?q=${this.searchQuery}&is_checked=${state}`;\n await this.search();\n this.cur = 0;\n },\n deleteLabel: async function (index) {\n var doc_id = this.items[this.cur].id;\n var annotation_id = this.items[this.cur]['labels'][index].id;\n _http_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].delete(`docs/${doc_id}/annotations/${annotation_id}`).then(response => {\n this.items[this.cur]['labels'].splice(index, 1)\n })\n },\n\n removeLabel: function (label) {\n var doc_id = this.items[this.cur].id;\n _http_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].delete(`docs/${doc_id}/annotations/${label.id}`).then(response => {\n var index = this.items[this.cur]['labels'].indexOf(label)\n this.items[this.cur]['labels'].splice(index, 1)\n })\n }\n },\n watch: {\n picked: function (){\n this.submit();\n },\n items: function () {\n // fetch progress info.\n _http_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].get('progress').then(response => {\n this.total = response.data['total'];\n this.remaining = response.data['remaining'];\n })\n }\n },\n created: function () {\n _http_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].get('labels').then(response => {\n this.labels = response.data\n });\n this.submit();\n },\n computed: {\n achievement: function () {\n var done = this.total - this.remaining;\n var percentage = Math.round(done / this.total * 100);\n return this.total > 0 ? percentage : 0;\n },\n progressColor: function () {\n if (this.achievement < 30) {\n return 'is-danger'\n } else if (this.achievement < 70) {\n return 'is-warning'\n } else {\n return 'is-primary'\n }\n }\n }\n};\n\n/* harmony default export */ __webpack_exports__[\"default\"] = (annotationMixin);\n\n//# sourceURL=webpack:///./static/js/mixin.js?");
/***/ }),
@ -185,7 +185,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var _htt
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var vue__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! vue */ \"./node_modules/vue/dist/vue.esm.js\");\n/* harmony import */ var _mixin_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./mixin.js */ \"./static/js/mixin.js\");\n/* harmony import */ var _http_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./http.js */ \"./static/js/http.js\");\n\nvue__WEBPACK_IMPORTED_MODULE_0__[\"default\"].use(__webpack_require__(/*! vue-shortkey */ \"./node_modules/vue-shortkey/dist/index.js\"));\n\n\n\n\nvar vm = new vue__WEBPACK_IMPORTED_MODULE_0__[\"default\"]({\n el: '#mail-app',\n delimiters: ['[[', ']]'],\n data: {\n newTodo: '',\n editedTodo: null\n },\n mixins: [_mixin_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"]],\n directives: {\n 'todo-focus': function (el, binding) {\n if (binding.value) {\n el.focus()\n }\n }\n },\n methods: {\n addTodo: function () {\n var value = this.newTodo && this.newTodo.trim()\n if (!value) {\n return\n }\n\n var doc_id = this.items[this.cur].id;\n var payload = {text: value}\n _http_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].post(`docs/${doc_id}/annotations/`, payload).then(response => {\n this.items[this.cur]['labels'].push(response.data)\n })\n\n this.newTodo = ''\n },\n\n removeTodo: function (todo) {\n var doc_id = this.items[this.cur].id;\n _http_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].delete(`docs/${doc_id}/annotations/${todo.id}`).then(response => {\n this.items[this.cur]['labels'].splice(this.items[this.cur]['labels'].indexOf(todo), 1)\n });\n },\n\n editTodo: function (todo) {\n this.beforeEditCache = todo.text\n this.editedTodo = todo\n },\n\n doneEdit: function (todo) {\n if (!this.editedTodo) {\n return\n }\n this.editedTodo = null\n todo.text = todo.text.trim()\n if (!todo.text) {\n this.removeTodo(todo)\n }\n var doc_id = this.items[this.cur].id;\n _http_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].put(`docs/${doc_id}/annotations/${todo.id}`, todo).then(response => {\n console.log(response)\n });\n },\n\n cancelEdit: function (todo) {\n this.editedTodo = null\n todo.text = this.beforeEditCache\n }\n },\n created: function () {\n this.updateProgress();\n this.submit();\n }\n});\n\n//# sourceURL=webpack:///./static/js/seq2seq.js?");
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var vue__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! vue */ \"./node_modules/vue/dist/vue.esm.js\");\n/* harmony import */ var _mixin_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./mixin.js */ \"./static/js/mixin.js\");\n/* harmony import */ var _http_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./http.js */ \"./static/js/http.js\");\n\nvue__WEBPACK_IMPORTED_MODULE_0__[\"default\"].use(__webpack_require__(/*! vue-shortkey */ \"./node_modules/vue-shortkey/dist/index.js\"));\n\n\n\n\nvar vm = new vue__WEBPACK_IMPORTED_MODULE_0__[\"default\"]({\n el: '#mail-app',\n delimiters: ['[[', ']]'],\n data: {\n newTodo: '',\n editedTodo: null\n },\n mixins: [_mixin_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"]],\n directives: {\n 'todo-focus': function (el, binding) {\n if (binding.value) {\n el.focus()\n }\n }\n },\n methods: {\n addTodo: function () {\n var value = this.newTodo && this.newTodo.trim()\n if (!value) {\n return\n }\n\n var doc_id = this.items[this.cur].id;\n var payload = {text: value}\n _http_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].post(`docs/${doc_id}/annotations/`, payload).then(response => {\n this.items[this.cur]['labels'].push(response.data)\n })\n\n this.newTodo = ''\n },\n\n removeTodo: function (todo) {\n var doc_id = this.items[this.cur].id;\n _http_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].delete(`docs/${doc_id}/annotations/${todo.id}`).then(response => {\n this.items[this.cur]['labels'].splice(this.items[this.cur]['labels'].indexOf(todo), 1)\n });\n },\n\n editTodo: function (todo) {\n this.beforeEditCache = todo.text\n this.editedTodo = todo\n },\n\n doneEdit: function (todo) {\n if (!this.editedTodo) {\n return\n }\n this.editedTodo = null\n todo.text = todo.text.trim()\n if (!todo.text) {\n this.removeTodo(todo)\n }\n var doc_id = this.items[this.cur].id;\n _http_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].put(`docs/${doc_id}/annotations/${todo.id}`, todo).then(response => {\n console.log(response)\n });\n },\n\n cancelEdit: function (todo) {\n this.editedTodo = null\n todo.text = this.beforeEditCache\n }\n },\n created: function () {\n this.submit();\n }\n});\n\n//# sourceURL=webpack:///./static/js/seq2seq.js?");
/***/ })

4
app/server/static/bundle/sequence_labeling.js
File diff suppressed because it is too large
View File

3
app/server/static/js/document_classification.js

@ -25,8 +25,7 @@ var vm = new Vue({
var doc_id = this.items[this.cur].id;
await HTTP.post(`docs/${doc_id}/annotations/`, payload).then(response => {
this.items[this.cur]['labels'].push(response.data);
});
this.updateProgress();
})
}
}
});

25
app/server/static/js/mixin.js

@ -70,31 +70,38 @@ var annotationMixin = {
await this.search();
this.cur = 0;
},
updateProgress: function () {
HTTP.get('progress').then(response => {
this.total = response.data['total'];
this.remaining = response.data['remaining'];
})
},
deleteLabel: async function (index) {
var doc_id = this.items[this.cur].id;
var annotation_id = this.items[this.cur]['labels'][index].id;
HTTP.delete(`docs/${doc_id}/annotations/${annotation_id}`).then(response => {
this.items[this.cur]['labels'].splice(index, 1)
});
this.updateProgress();
})
},
removeLabel: function (label) {
var doc_id = this.items[this.cur].id;
HTTP.delete(`docs/${doc_id}/annotations/${label.id}`).then(response => {
var index = this.items[this.cur]['labels'].indexOf(label)
this.items[this.cur]['labels'].splice(index, 1)
})
}
},
watch: {
picked: function (){
this.submit();
},
items: function () {
// fetch progress info.
HTTP.get('progress').then(response => {
this.total = response.data['total'];
this.remaining = response.data['remaining'];
})
}
},
created: function () {
HTTP.get('labels').then(response => {
this.labels = response.data
});
this.updateProgress();
this.submit();
},
computed: {

1
app/server/static/js/seq2seq.js

@ -68,7 +68,6 @@ var vm = new Vue({
}
},
created: function () {
this.updateProgress();
this.submit();
}
});

17
app/server/static/js/sequence_labeling.js

@ -5,7 +5,12 @@ import HTTP from './http.js';
Vue.component('annotator', {
template: '<div @click="setSelectedRange">\
<span v-for="r in chunks" v-bind:class="{tag: r.color}" v-bind:style="{ color: r.color, backgroundColor: r.background }">{{ r.word }}<button v-if="r.color" class="delete is-small" @click="deleteLabel(r.index)"></button></span>\
<span v-for="r in chunks"\
v-bind:class="{tag: r.color}"\
v-bind:style="{ color: r.color, backgroundColor: r.background }"\
>{{ r.word }}<button class="delete is-small"\
v-if="r.color"\
@click="deleteLabel(r.index)"></button></span>\
</div>',
props: {
'labels': Array, // [{id: Integer, color: String, text: String}]
@ -97,7 +102,7 @@ Vue.component('annotator', {
chunks: function () {
var res = [];
var left = 0;
var i = 0;
var index = 0;
for (let i in this.sortedEntityPositions) {
var e = this.sortedEntityPositions[i];
var text = this.text.slice(left, e['start_offset']);
@ -120,10 +125,7 @@ Vue.component('annotator', {
'word': text,
'color': '',
'background': ''
});
console.log(res);
console.log(this.labels);
console.log(this.entityPositions);
})
return res
}
@ -140,8 +142,7 @@ var vm = new Vue({
var doc_id = this.items[this.cur].id;
HTTP.post(`docs/${doc_id}/annotations/`, payload).then(response => {
this.items[this.cur]['labels'].push(response.data);
});
this.updateProgress()
})
}
}
});
Loading…
Cancel
Save