protected IWord getNextDatetimeWord ( IWord word , int entityIdx ) throws IOException { IWord dWord = super . next ( ) ; if ( dWord == null ) { return null ; } String [ ] entity = dWord . getEntity ( ) ; if ( entity == null ) { eWordPool . add ( dWord ) ; return null ; } int eIdx = 0 ; if ( ( eIdx = ArrayUtil . startsWith ( "datetime.h" , entity ) ) > - 1 ) { // do nothing here } else if ( ( eIdx = ArrayUtil . startsWith ( "time.a" , entity ) ) > - 1 || ( eIdx = ArrayUtil . startsWith ( Entity . E_DATETIME_P , entity ) ) > - 1 ) { /* * @Note: added at 2017/04/01 * 1, A word start with time.h or datetime.h could be merged * 2, if the new time merged word could not be merged with the origin word * and we should put the dWord to the first of the eWordPool cuz #getNextTimeMergedWord * may append some IWord to the end of eWordPool */ IWord mWord = getNextTimeMergedWord ( dWord , eIdx ) ; if ( mWord == null ) { eWordPool . addFirst ( dWord ) ; return null ; } String mEntity = mWord . getEntity ( 0 ) ; if ( ! ( mEntity . contains ( ".h" ) || mEntity . contains ( ".a" ) ) ) { eWordPool . addFirst ( mWord ) ; return null ; } eIdx = 0 ; dWord = mWord ; entity = dWord . getEntity ( ) ; } else { eWordPool . add ( dWord ) ; return null ; } buffer . clear ( ) . append ( word . getValue ( ) ) . append ( ' ' ) . append ( dWord . getValue ( ) ) ; dWord = new Word ( buffer . toString ( ) , IWord . T_BASIC_LATIN ) ; dWord . setPosition ( word . getPosition ( ) ) ; dWord . setPartSpeech ( IWord . TIME_POSPEECH ) ; //re-define the entity //int sIdx = entity.indexOf('.') + 1; // int sIdx = entity[eIdx].charAt(0) == 't' ? 5 : 9; int sIdx = 9 ; // datetime buffer . clear ( ) . append ( word . getEntity ( 0 ) ) . append ( entity [ eIdx ] . substring ( sIdx ) ) ; dWord . addEntity ( buffer . toString ( ) ) ; return dWord ; }
get and return the next date - time word