public static int getPosition ( Term subTerm , Term term ) { int startingIndex = - 1 ; int j = 0 ; for ( int i = 0 ; i < term . getWords ( ) . size ( ) ; i ++ ) { if ( term . getWords ( ) . get ( i ) . equals ( subTerm . getWords ( ) . get ( j ) ) ) { j ++ ; if ( startingIndex == - 1 ) startingIndex = i ; } else { startingIndex = - 1 ; j = 0 ; } if ( j == subTerm . getWords ( ) . size ( ) ) return startingIndex ; } return - 1 ; }
Finds the index of appearance of a term s sub - term .