Skip to content

Commit

Permalink
work on #78
Browse files Browse the repository at this point in the history
  • Loading branch information
telion2 committed Mar 15, 2018
1 parent 18f8dbf commit 870b558
Show file tree
Hide file tree
Showing 8 changed files with 140 additions and 45 deletions.
12 changes: 9 additions & 3 deletions views/analysis.vue
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
v-bind:style="{left: columnsizetoolbarpos+ '%'}"
v-on:emitanalighter="getAnalighter"
v-on:emitnotes="getNotes"
v-on:changemarkermode="changeMarkerMode($event)"
v-on:updateclassestomark="updateclassestomark($event)"
v-on:changenotemode="changeNoteMode($event)">
</component>
</div>
Expand Down Expand Up @@ -78,7 +78,6 @@
v-on:startselection="selectText($event,0)"
v-on:endselection="selectText($event,1)"
v-on:jumpmarktext="selectText2($event)"
v-on:togglesemanticlass="changeMarkerMode($event)"
v-on:starthover="starthover($event)"
v-on:endhover="endhover($event)"
v-on:updateclassestomark="updateclassestomark($event)">
Expand Down Expand Up @@ -130,7 +129,8 @@
LOCATION: false,
ORGANIZATION: false,
MISC: false,
POS: false
POS: false,
OTHER: false,
},
selectedtextindexes: {
start: -1,
Expand Down Expand Up @@ -182,6 +182,11 @@
img: true,
map: true,
information: true
},
OTHERS:{
img: true,
map: true,
information: true
}
}
}
Expand All @@ -195,6 +200,7 @@
this.contentcontrol.LOCATIONS[toToggle] = !this.contentcontrol.LOCATIONS[toToggle];
this.contentcontrol.ORGANIZATIONS[toToggle] = !this.contentcontrol.ORGANIZATIONS[toToggle];
this.contentcontrol.MISCS[toToggle] = !this.contentcontrol.MISCS[toToggle];
this.contentcontrol.OTHERS[toToggle] = !this.contentcontrol.OTHERS[toToggle];
this.contentcontrol.PERSONS['map'] = false;
},
setTokens: function (newTokens) {
Expand Down
18 changes: 12 additions & 6 deletions views/components/analysis/analighter.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
v-bind:hoverdata="hoverdata"
v-bind:wordtomarkonhoverdata="wordtomarkonhoverdata"
v-bind:researchdatatoedit="researchdatatoedit"
v-on:togglesemanticlass="togglesemanticlass($event)"
v-bind:researchdatatoupdate="researchdatatoupdate"
v-on:updateclassestomark="updateclassestomark($event)"
v-on:endhover="endhover($event)"
v-on:starthover="starthover($event)"
v-on:editresearch="editresearch($event)"
Expand Down Expand Up @@ -58,12 +59,13 @@
data: function () {
return {
researchdatatoedit: {},
showmode: 'entitiesview'
researchdatatoupdate: {},
showmode: 'entitiesview',
}
},
methods: {
togglesemanticlass: function (newClassesToMark) {
this.$emit('togglesemanticlass', newClassesToMark);
updateclassestomark: function (newClassesToMark) {
this.$emit('updateclassestomark', newClassesToMark);
},
endhover: function (event) {
this.$emit('endhover', event);
Expand All @@ -74,13 +76,17 @@
editresearch: function (researchData) {
this.classestomark.POS = true;
this.showmode = 'correction';
this.researchdatatoedit = JSON.parse(JSON.stringify(researchData));
this.researchdatatoupdate = null;
this.$emit('updateclassestomark', this.classestomark);
},
selectedresearch: function (researchData) {
this.classestomark.POS = false;
this.researchdatatoedit = null;
this.showmode = 'entitiesview';
this.researchdatatoedit = researchData;
this.$emit('updateclassestomark', this.classestomark);
this.researchdatatoupdate = JSON.parse(JSON.stringify(researchData));
console.log('finished Edit: ' + JSON.stringify(this.researchdatatoupdate));
this.updateclassestomark(this.classestomark);
}
},
components: {
Expand Down
56 changes: 43 additions & 13 deletions views/components/analysis/correction.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<template>
<div>
<div v-if="selectedtokens.length !== 0" class="mdl-grid">
<p class="mdl-cell mdl-cell--4-col" v-bind:class="semclassofselected">{{selectedtokens[0].content}}</p>
<p class="mdl-cell mdl-cell--6-col">Current Class: {{selectedtokens[0].semanticClass}}</p>
<div v-if="changing" class="mdl-grid">
<p class="mdl-cell mdl-cell--4-col" v-bind:class="currentClass">{{contentToChange}}</p>
<p class="mdl-cell mdl-cell--6-col">Current Class: {{currentClass}}</p>
<div>
<p class="mdl-cell mdl-cell--6-col">Make a selection: </p>
<button v-bind:class="{PERSON: true}"
Expand Down Expand Up @@ -32,7 +32,7 @@
</button>
</div>
</div>
<div v-if="selectedtokens.length === 0" class="mdl-grid">
<div v-else class="mdl-grid">
<p class="mdl-cell mdl-cell--12-col"> Select a word to correct its semantic class. </p>
<p class="mdl-cell mdl-cell--12-col"><span v-bind:class="{POS:true}">Suggested</span> words are the most
likely ones not to be classified. </p>
Expand Down Expand Up @@ -85,9 +85,7 @@
},
data: function () {
return {
showNewClasses: false,
index: 0,
suggestions: false
}
Expand All @@ -96,23 +94,55 @@
watch: {},
computed: {
selectedtokens: function () {
if(this.selectedindexes.start > -1 && this.selectedindexes.end > -1){
this.researchdatatoedit = null;
}
return this.gettokensofselectedtext(this.tokens, this.selectedindexes);
},
semclassofselected: function () {
let tokenClass = {};
tokenClass[this.selectedtokens[0].semanticClass] = true;
return tokenClass;
// let tokenClass = {};
// tokenClass[this.selectedtokens[0].semanticClass] = true;
// return tokenClass;
},
changing:function () {
let toChange = this.selectedtokens.length > 0 || this.researchdatatoedit !== null;
console.log('Changing: ' + toChange);
return toChange;
},
contentToChange:function () {
if(this.changing){
if(this.selectedtokens.length > 0){
let content = '';
for(let i = 0; i < this.selectedtokens.length; i++){
content = content + ' ' + this.selectedtokens[i].content;
}
return content;
} else{
return this.researchdatatoedit.sourcequery.querys[0];
}
}
},
currentClass:function () {
if(this.changing){
if(this.selectedtokens.length === 1){
return this.selectedtokens[0].semanticClass;
} else if(this.researchdatatoedit !== null){
return this.researchdatatoedit.sourcequery.source[0].semanticClass;
} else {
return 'To many words with different semantic classes.'
}
}
}
},
methods: {
saveresult:function (researchdata) {
saveresult: function (researchdata) {
this.$emit('selectresearch', researchdata);
},
changeClass: function (newClass) {
//console.log(this.selectedtokens[0].content + " with class " + this.selectedtokens[0].semanticClass+ " is changed to " + newClass);
this.selectedtokens[0].semanticClass = newClass;
let socket = io(this.serverip + ':8080');
socket.emit('changeClass', this.selectedtokens[0], this.docid);
// this.selectedtokens[0].semanticClass = newClass;
// let socket = io(this.serverip + ':8080');
// socket.emit('changeClass', this.selectedtokens[0], this.docid);
},
toggleSuggestions: function () {
this.suggestions = !this.suggestions;
Expand Down
66 changes: 59 additions & 7 deletions views/components/analysis/entitiesview.vue
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,39 @@
v-on:saveresult="saveResult($event)"
v-on:editresearch="editresearch($event)">
</component>
<div class="semClassFormate OTHER"
ref="miscresultsparent"
v-on:click="togglesemanticlass('OTHER')">
<button class="mdl-cell mdl-cell--1-col mdl-button mdl-js-button mdl-js-ripple-effect mdl-button--icon deleteSpaces snapbtn">
<i v-if="classestomark.OTHER"
class="material-icons snapbtn">keyboard_arrow_down</i>
<i v-else class="material-icons snapbtn">keyboard_arrow_right</i>
</button>
<button class="mdl-cell mdl-cell--10-col mdl-button mdl-js-button mdl-js-ripple-effect deleteSpaces snapbtn">
<b class="mdc-button snapbtn">OTHER ({{numberOfOTHER}})</b>
</button>
<button class="mdl-cell mdl-cell--1-col mdl-button mdl-js-button mdl-js-ripple-effect mdl-button--icon deleteSpaces"
v-on:click="addresearch">
<i class="material-icons">add_circle</i>
</button>
</div>
<component is="researchresult"
ref="miscresults"
v-if="classestomark.OTHER"
v-for="(researchresult,index5) in OTHER"
v-bind:index="index5"
v-bind:serverip="serverip"
v-bind:researchdata="researchresult"
v-bind:key="index5+ PERSON.length + LOCATION.length + ORGANIZATION.length + MISC.length"
v-bind:mapkey="index5+ PERSON.length+ LOCATION.length+ ORGANIZATION.length+ MISC.length"
v-bind:docid="docid"
v-bind:viewing="true"
v-bind:contentcontrol="contentcontrol.OTHERS"
v-bind:wordtomarkonhoverdata="wordtomarkonhoverdata"
v-on:starthover="starthover($event)"
v-on:saveresult="saveResult($event)"
v-on:editresearch="editresearch($event)">
</component>
</div>

</template>
Expand Down Expand Up @@ -165,20 +198,21 @@
contentcontrol: {type: Object, default: null},
hoverdata: {type: Object, default: null},
selectedindexes: {type: Object, default: null},
researchdatatoupdate: {type: Object, default: null},
},
data: function () {
return {
PERSON: [],
LOCATION: [],
ORGANIZATION: [],
MISC: [],
OTHER: [],
researchresults: [],
sourcequery: [],
}
},
methods: {
addresearch:function () {
addresearch: function () {
this.$emit('editresearch');
},
editresearch: function (researchData) {
Expand Down Expand Up @@ -266,7 +300,7 @@
},
togglesemanticlass: function (semClass) {
this.classestomark[semClass] = !this.classestomark[semClass];
this.$emit('togglesemanticlass', this.classestomark);
this.$emit('updateclassestomark', this.classestomark);
},
saveResults: function () {
//console.log('TODO: Trying to save but not implemented.');
Expand Down Expand Up @@ -301,6 +335,13 @@
return '';
}
},
numberOfOTHER: function () {
if (typeof this['OTHER'] !== 'undefined') {
return this['OTHER'].length;
} else {
return '';
}
},
},
mounted() {
if (this.tokenstoshow.length === 0)
Expand All @@ -311,6 +352,17 @@
this.researchTokensOfClass('MISC', 3);
},
watch: {
researchdatatoupdate: {
handler: function (newresearchdatatoupdate) {
if (newresearchdatatoupdate !== null) {
if (newresearchdatatoupdate.sourcequery !== undefined) {
console.log('Adding new result to ' + newresearchdatatoupdate.sourcequery.source[0].semanticClass);
this[newresearchdatatoupdate.sourcequery.source[0].semanticClass].push(newresearchdatatoupdate);
}
}
}, deep: true,
immediate: true
},
tokenstoshow: function (value) {
this.researchTokensOfClass('PERSON', 0);
this.researchTokensOfClass('LOCATION', 1);
Expand All @@ -325,7 +377,7 @@
// console.log("entitiesview handler hoverdata: " + JSON.stringify(hoverdata));
// console.log("entitiesview handler children: " + JSON.stringify(this.$refs.personresults[0].researchdata));
if (hoverdata.hoverstarted == "research") {
if (hoverdata.hoverstarted === "research") {
return;
}
Expand Down Expand Up @@ -357,7 +409,7 @@
for (let i = 0; i < this.$refs["locationresults"].length; i++) {
let refElement = this.$refs.locationresults[i]
if (refElement.researchdata.sourcequery.wordids.indexOf(newwordid) > -1) {
if (hoverdata.hoverstarted == "text")
if (hoverdata.hoverstarted === "text")
refElement.$el.scrollIntoView();
bb = refElement.$el.getBoundingClientRect();
Expand All @@ -372,7 +424,7 @@
for (let i = 0; i < this.$refs["organisazionresults"].length; i++) {
let refElement = this.$refs.organisazionresults[i]
if (refElement.researchdata.sourcequery.wordids.indexOf(newwordid) > -1) {
if (hoverdata.hoverstarted == "text")
if (hoverdata.hoverstarted === "text")
refElement.$el.scrollIntoView();
bb = refElement.$el.getBoundingClientRect();
Expand All @@ -387,7 +439,7 @@
for (let i = 0; i < this.$refs["miscresults"].length; i++) {
let refElement = this.$refs.miscresults[i]
if (refElement.researchdata.sourcequery.wordids.indexOf(newwordid) > -1) {
if (hoverdata.hoverstarted == "text")
if (hoverdata.hoverstarted === "text")
refElement.$el.scrollIntoView();
bb = refElement.$el.getBoundingClientRect();
Expand Down
13 changes: 8 additions & 5 deletions views/components/analysis/research.vue
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,11 @@
//this.rerankWithKeywords(response);
//this.getMapCoordinates();
let data = response.itemListElement;
if (this.researchdatatoedit.sourcequery !== undefined && this.researchdatatoedit.sourcequery !== null) {
for (let i = 0; i < data.length; i++) {
data[i]["sourcequery"] = this.researchdatatoedit.sourcequery;
if (this.researchdatatoedit !== null) {
if (this.researchdatatoedit.sourcequery !== undefined && this.researchdatatoedit.sourcequery !== null) {
for (let i = 0; i < data.length; i++) {
data[i]["sourcequery"] = this.researchdatatoedit.sourcequery;
}
}
} else {
let wordids = [];
Expand Down Expand Up @@ -171,7 +173,8 @@
//console.log('Looking for more Info about: ' + this.selectedtext);
this.searchGoogle(this.selectedtext, 10);
}
}, deep: true
}, deep: true,
immediate: true
},
selectedindexes: {
handler: function (newSelectedIndexes) {
Expand All @@ -181,7 +184,7 @@
this.researchedtokens = this.gettokensofselectedtext(this.tokens, newSelectedIndexes);
this.selectedtext = this.generateText(this.researchedtokens);
console.log('Looking for more Info about: ' + this.selectedtext);
this.searchGoogle(this.selectedtext);
this.searchGoogle(this.selectedtext, 10);
}
},
deep: true
Expand Down
1 change: 0 additions & 1 deletion views/components/analysis/researchresult.vue
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@
},
saveResult: function () {
this.$emit('saveresult', this.researchdata);
console.log('Save research Changes.'+ JSON.stringify(this.researchdata));
},
showSource: function () {
try {
Expand Down
Loading

0 comments on commit 870b558

Please sign in to comment.