@@ -42,7 +42,7 @@ export const mutations = {
4242 id : lastIndex + 1 ,
4343 name : payload ,
4444 color : niceColors [ lastIndex % niceColors . length ] ,
45- }
45+ } ;
4646 state . classes = [ ...state . classes , newClass ] ;
4747 if ( state . classes . length === 1 ) {
4848 state . currentClass = state . classes [ 0 ] ;
@@ -81,6 +81,10 @@ export const mutations = {
8181 state . currentIndex += 1 ;
8282 state . currentAnnotation = state . annotations [ state . currentIndex ] || { } ;
8383 } else {
84+ if ( state . currentIndex == state . inputSentences . length - 1 ) {
85+ // last sentence
86+ state . currentIndex += 1 ;
87+ }
8488 alert ( "You have completed all the sentences" ) ;
8589 }
8690 } ,
@@ -116,9 +120,10 @@ export const mutations = {
116120 LocalStorage . set ( "tags" , state . classes ) ;
117121 } ,
118122 loadAnnotations ( state , payload ) {
119- let isValid = typeof payload === "object" &&
120- "annotations" in payload &&
121- "classes" in payload ;
123+ let isValid =
124+ typeof payload === "object" &&
125+ "annotations" in payload &&
126+ "classes" in payload ;
122127
123128 if ( ! isValid ) {
124129 throw new Error ( "loadAnnotations: payload has invalid schema" ) ;
@@ -139,19 +144,22 @@ export const mutations = {
139144 for ( var i = 0 ; i < annotations . length ; i ++ ) {
140145 if ( annotations [ i ] == null ) continue ;
141146 let annotation = {
142- ' text' : annotations [ i ] [ 0 ] ,
143- ' entities' : annotations [ i ] [ 1 ] . entities ,
144- }
147+ text : annotations [ i ] [ 0 ] ,
148+ entities : annotations [ i ] [ 1 ] . entities ,
149+ } ;
145150 newAnnotations [ i ] = annotation ;
146151 }
147152 state . annotations = newAnnotations ;
148153 state . currentAnnotation = state . annotations [ state . currentIndex ] ;
149154
150- for ( let c of classes ) {
155+ for ( let c of classes ) {
151156 this . commit ( "addClass" , c ) ;
152157 }
153158 LocalStorage . set ( "tags" , state . classes ) ;
154159 } ,
160+ switchToPage ( state , payload ) {
161+ state . currentPage = payload ;
162+ } ,
155163} ;
156164
157165export const getters = { } ;
@@ -174,8 +182,9 @@ const actions = {
174182 } ,
175183} ;
176184
177- window . addEventListener ( 'beforeunload' , async ( event ) => {
178- event . returnValue = "Please make sure you export annotations before closing the file." ;
185+ window . addEventListener ( "beforeunload" , async ( event ) => {
186+ event . returnValue =
187+ "Please make sure you export annotations before closing the file." ;
179188} ) ;
180189
181190export default {
@@ -191,9 +200,10 @@ export default {
191200 annotationPrecision : "word" ,
192201 // current state
193202 currentAnnotation : { } ,
194- currentClass : tags && tags [ 0 ] || { } ,
203+ currentClass : ( tags && tags [ 0 ] ) || { } ,
195204 currentIndex : 0 ,
196205 currentSentence : "" ,
206+ currentPage : "start" ,
197207 } ;
198208 } ,
199209 getters,
0 commit comments