Skip to content

Commit

Permalink
work on #134, added a global store for variables and functions.
Browse files Browse the repository at this point in the history
  • Loading branch information
telion2 committed Jul 24, 2018
1 parent d9d28ad commit bd4bee0
Show file tree
Hide file tree
Showing 10 changed files with 183 additions and 95 deletions.
150 changes: 95 additions & 55 deletions views/analysis.vue
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
<component
is="toolbar"
v-bind:tokens="vueTokens"
v-bind:selectedtextindexes="selectedtextindexes"
v-bind:classestomark="classesToMark"
v-bind:style="{left: columnsizetoolbarpos+ '%'}"
v-on:emitanalighter="getAnalighter"
Expand Down Expand Up @@ -83,8 +82,8 @@
v-on:movetoolbar="movetoolbar($event)"
v-on:hoverchain="hoverChain($event)"
v-on:startselection="selectText($event,0)"
v-on:hoverduringselection="selectText($event,1)"
v-on:endselection="selectText($event,2)"
v-on:hoverduringselection="selectText3($event,1)"
v-on:endselection="selectText3($event,2)"
v-on:jumpmarktext="selectText2($event)"
v-on:starthover="starthover($event)"
v-on:endhover="endhover($event)"
Expand All @@ -104,6 +103,7 @@
v-bind:offsetend="offsetend"
v-bind:semanticclass="semanticclass">
</component>
<component is="store"></component>
</div>
</template>
<script>
Expand All @@ -119,14 +119,14 @@
import variablehelper from './components/global/variablehelper.vue';
import textfeatureviewport from './components/analysis/textfeatureviewport.vue';
import linetohover from './components/analysis/linetohover.vue';
import store from './components/analysis/globalstore.vue';
export default {
data: function () {
return {
moreData: null,
displayloading: true,
hoverdata: {},
lineddata:{},
lineddata: {},
wordtomarkonhoverdata: {},
offsetstart: null,
offsetend: null,
Expand Down Expand Up @@ -245,43 +245,6 @@
setTokens: function (newTokens) {
this.tokens = newTokens;
},
hoverChain: function (chain) {
let represantativeFound = false;
if (chain !== -1) {
let temphoveredChain = [];
let mentionID = -2;
for (let i = 0; i < this.coref.length; i++) {
//Representative
if (this.coref[i].startIndex <= chain && this.coref[i].endIndex >= chain) {
if (this.coref[i].representative === -1) {
mentionID = this.coref[i].mentionID;
} else {
mentionID = this.coref[i].representative;
}
temphoveredChain.push({
start: this.coref[i].startIndex,
end: this.coref[i].endIndex,
});
break;
}
}
if (mentionID !== -2) {
for (let i = 0; i < this.coref.length; i++) {
if (this.coref[i].mentionID === mentionID || this.coref[i].representative === mentionID) {
temphoveredChain.push({
start: this.coref[i].startIndex,
end: this.coref[i].endIndex,
});
}
}
} else {
console.log('WARNING: could not match a corefmention to the hovered word');
}
this.hoveredChain = temphoveredChain;
} else {
this.hoveredChain = null;
}
},
movetoolbar: function (columnindex) {
if (this.columnindexoflasthover === columnindex)
return;
Expand All @@ -290,29 +253,33 @@
this.currentpage = this.columnindexoflasthover + this.tokenssplittedindextoshow + 1;
},
getAnalighter: function () {
this.analysisMode = 'analighter';
},
getNotes: function () {
this.removehoverline([]);
this.analysisMode = 'notes';
},
selectText: function (index, modus) {
//Start Selection
if (modus === 0) {
this.selectedtextindexes = {
start: index,
hover: index,
end: -1,
done: false
};
} else if (modus === 1) {
}
//Hover During Selection
else if (modus === 1) {
this.selectedtextindexes = {
start: this.selectedtextindexes.start,
hover: index,
end: -1,
done: false
};
} else if (modus === 2) {
}
//End Selection
else if (modus === 2) {
let start = this.selectedtextindexes.start;
let end = index;
if (start > end) {
Expand All @@ -331,21 +298,38 @@
selectText2: function (newSelectedIndexes) {
this.selectedtextindexes = newSelectedIndexes;
},
selectText3: function (selectiondata, modus) {
if(typeof selectiondata === 'number'){
this.selectText(selectiondata, modus);
return;
}
this.selectText(selectiondata.token.textIndex, modus);
if (modus === 2) {
//Check if Entity -> prepare highlight entity & drawline
if (this[selectiondata.token.semanticClass] !== undefined && this[selectiondata.token.semanticClass]) {
this.drawline(selectiondata);
}
//Check if Mention of a coref Chain -> prepare highlight chain
//TODO: Refactor hoverChain in general on analysis to sth like getChain
//this.hoverChain(index);
//Case of one Word is already done by this.selectText
}
},
changeNoteMode: function (newNoteModes) {
this.notemodes = newNoteModes;
},
setColumnSize2: function () {
this.columnsize2 = 100.0 / this.numberofcolumns;
this.showTokens();
},
showTokens: function () {
if (this.numberofcolumns === 1) {
this.tokenstoshow = this.tokenssplitted;
} else {
let end = this.tokenssplittedindextoshow + this.numberofcolumns;
this.tokenstoshow = this.tokenssplitted.slice(this.tokenssplittedindextoshow, end);
}
},
changeScope: function (direction) {
Expand Down Expand Up @@ -465,7 +449,56 @@
this.setColumnSize2();
}
},
drawline: function(event){
hoverChain: function (chain) {
/* Given an Index of a Word which represents a coref Mention,
this method should find that word in the coref object (list)
and all the other mentions in that chain and add them to
a new object list that represents all the mentions that should be hovered,
aka highlighted.
*/
let represantativeFound = false;
if (chain !== -1) {
let temphoveredChain = [];
let mentionID = -2;
//Looking for Chain in corefInformation package
for (let i = 0; i < this.coref.length; i++) {
// When hovered Chain found...
if (this.coref[i].startIndex <= chain && this.coref[i].endIndex >= chain) {
//Representative or Relative...
if (this.coref[i].representative === -1) {
mentionID = this.coref[i].mentionID;
} else {
mentionID = this.coref[i].representative;
}
//preparing hoveredChain Object, adding start & end Index
temphoveredChain.push({
start: this.coref[i].startIndex,
end: this.coref[i].endIndex,
});
break;
}
}
// if a coref Mention was found...
if (mentionID !== -2) {
// find all other Mentions in the Chain...
for (let i = 0; i < this.coref.length; i++) {
if (this.coref[i].mentionID === mentionID || this.coref[i].representative === mentionID) {
// ...and add the Indexes to the hoveredChain
temphoveredChain.push({
start: this.coref[i].startIndex,
end: this.coref[i].endIndex,
});
}
}
} else {
console.log('WARNING: could not match a corefmention to the hovered word');
}
this.hoveredChain = temphoveredChain;
} else {
this.hoveredChain = null;
}
},
drawline: function (event) {
//DELETE OLD LINE
if (event.hoverended === "research") {
this.wordtomarkonhoverdata = {
Expand All @@ -478,8 +511,10 @@
} else if (event.hoverended === "text") {
this.offsetstart = event.offsetstart;
}
//DRAW NEW LINE:
//If the startpoint of old line = startpoint of the new line and...
if (this.lineddata.hoverstarted === event.hoverstarted) {
// the hover started from hovering over text and the new line is the same
// or from research entity respectivly -> do nothing
if ((event.hoverstarted === "text"
&& this.lineddata.offsetstart !== null && this.lineddata.offsetstart.x === event.offsetstart.x
&& this.lineddata.offsetstart.y === event.offsetstart.y) ||
Expand All @@ -489,16 +524,19 @@
return;
}
}
//OTHER STUFF?
//DRAW NEW LINE:
//prepare control Objects for view (semanticClass, data for creating lines
this.lineddata = event;
let classofcolor = event.semanticClass + "_strong";
this.semanticclass = {};
this.semanticclass[classofcolor] = true;
//if hover started from text the remaining words of the entity are easy to find
// -> only start offset is needed
if (event.hoverstarted === "text") {
this.offsetstart = event.offsetstart;
} else if (event.hoverstarted === "research") {
// if it started from a researchentity we need to find it later and prepare for that
this.wordtomarkonhoverdata = {
textindexes: event.wordtomarkonhover,
hoverstarted: "research",
Expand All @@ -507,6 +545,7 @@
};
this.offsetend = event.offsetend;
}
//Redundancy ?
},
starthover: function (event) {
if (this.hoverdata.hoverstarted === event.hoverstarted) {
Expand Down Expand Up @@ -637,9 +676,9 @@
watch: {
preparedEntities: {
handler: function (newpreparedEntities) {
console.log('checking: newpreparedEntities ' + newpreparedEntities + '===?' + this.researchedEntities.length);
if (newpreparedEntities === this.researchedEntities.length-1) {
console.log('got here:');
//console.log('checking: newpreparedEntities ' + newpreparedEntities + '===?' + this.researchedEntities.length);
if (newpreparedEntities === this.researchedEntities.length - 1) {
//console.log('got here:');
this.researchedallentities = true;
this.resize();
}
Expand Down Expand Up @@ -726,7 +765,8 @@
variablehelper,
textfeatureviewport,
textviewcontrol,
linetohover
linetohover,
store
}
}
</script>
6 changes: 4 additions & 2 deletions views/components/analysis/analighter.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,13 @@
v-on:switchtoentities="switchtoentities()">
</component>
</keep-alive>
<component is="store"></component>
</div>
</template>
<script>
import correction from './components/analysis/correction.vue';
import entitiesview from './components/analysis/entitiesview.vue';
import store from './components/analysis/globalstore.vue';
export default {
props: {
Expand Down Expand Up @@ -116,7 +117,8 @@
},
components: {
correction,
entitiesview
entitiesview,
store
}
}
</script>
5 changes: 3 additions & 2 deletions views/components/analysis/correction.vue
Original file line number Diff line number Diff line change
Expand Up @@ -111,14 +111,14 @@
style="padding:0.4em;">
Select a class first in order to add futher information to the selected word.
<p>

<component is="store"></component>
</div>

</template>
<script>
import getselectedtext from './mixins/analysis/gettokensofselectedtext.js';
import research from './components/analysis/research.vue';
import store from './components/analysis/globalstore.vue';
export default {
mixins: [getselectedtext],
props: {
Expand Down Expand Up @@ -217,6 +217,7 @@
},
components: {
research,
store
}
}
</script>
9 changes: 6 additions & 3 deletions views/components/analysis/entitiesview.vue
Original file line number Diff line number Diff line change
Expand Up @@ -190,12 +190,13 @@
v-on:saveresult="saveresult($event)"
v-on:editresearch="editresearch($event)">
</component>
<component is="store"></component>
</div>
</template>
<script>
import filtertokenwithclass from './mixins/analysis/filtertoken.js';
import researchresult from './components/analysis/researchresult.vue';
import store from './components/analysis/globalstore.vue';
export default {
mixins: [filtertokenwithclass],
props: {
Expand Down Expand Up @@ -420,19 +421,19 @@
handler: function (hoverdata) {
if (hoverdata === 'undefined') {
console.log("WARNING: entitiesview vue hover data undefined");
//return;?
}
if (hoverdata.hoverstarted === "research") {
return;
}
if (this.columnindex !== hoverdata.columnindex) {
return;
}
let wordtomarkonhoverDUMMY = [];
let newwordid = hoverdata.startword.textIndex;
let bb = null;
//For each semanticClass, scroll the entity into the view if it is not in the view of the user
if (hoverdata.semanticClass === 'PERSON') {
if (typeof this.$refs["personresults"] !== 'undefined' && this.$refs["personresults"].length > 0) {
for (let i = 0; i < this.$refs["personresults"].length; i++) {
Expand Down Expand Up @@ -530,6 +531,7 @@
bb = el.getBoundingClientRect();
}
}
//Reset hover because of changed positions aka renew the line.
let data = {hoverended: "research", offsetend: bb, wordtomarkonhover: wordtomarkonhoverDUMMY};
this.$emit('endhover', data);
}
Expand All @@ -539,6 +541,7 @@
},
components: {
researchresult,
store
}
}
</script>
Loading

0 comments on commit bd4bee0

Please sign in to comment.