src/main/java/chlx/hashing/shingles/SimpleWordBasedShingling.java
@Override
	@NotNull
	public IntOpenHashSet toShingleSet(@NotNull String s, int startIndex, int endIndex) {
		if (startIndex < 0) {
			throw new IllegalArgumentException("contentStart can't be smaller than 0");
		}

		IntOpenHashSet ret = new IntOpenHashSet();
		Arrays.fill(track, 0);
		int current = 0;

		for (int charIndex = startIndex; charIndex < endIndex; ++charIndex) {
			char ch = s.charAt(charIndex);
			if (STOP_WORD_SYMBOL_SET.contains(ch)) {
				if (track[current] != 0) {
					current = (current + 1) % nGram;
					if (track[current] != 0) {
						ret.add(track[current]);
						track[current] = 0;
					}
					for (int i = 0; i < nGram; ++i) {
						track[i] = track[i] != 0 ? increaseHash(track[i], SPACE) : track[i];
					}
				}
			} else {
				track[current] = increaseHash(track[current], ch);
				int i = (current + 1) % nGram;
				while (i != current) {
					if (track[i] != 0) {
						track[i] = track[i] != 0 ? increaseHash(track[i], ch) : track[i];
					}
					i = (i + 1) % nGram;
				}
			}
		}

		if (track[current] != 0) {
			current = (current + 1) % nGram;
			if (track[current] != 0) {
				ret.add(track[current]);
			}
		}

		return ret;
	}
/**
	 * Shingles that equal to '0' will not be returned
	 */
Shingles that equal to '0' will not be returned
Shingles that equal to ' 0 ' will not be returned
@Override
	@NotNull
	public IntOpenHashSet toShingleSet(@NotNull String s, int startIndex, int endIndex) {
		if (startIndex < 0) {
			throw new IllegalArgumentException("contentStart can't be smaller than 0");
		}
		IntOpenHashSet ret = new IntOpenHashSet();
		Arrays.fill(track, 0);
		int current = 0;
		for (int charIndex = startIndex; charIndex < endIndex; ++charIndex) {
			char ch = s.charAt(charIndex);
			if (STOP_WORD_SYMBOL_SET.contains(ch)) {
				if (track[current] != 0) {
					current = (current + 1) % nGram;
					if (track[current] != 0) {
						ret.add(track[current]);
						track[current] = 0;
					}
					for (int i = 0; i < nGram; ++i) {
						track[i] = track[i] != 0 ? increaseHash(track[i], SPACE) : track[i];
					}
				}
			} else {
				track[current] = increaseHash(track[current], ch);
				int i = (current + 1) % nGram;
				while (i != current) {
					if (track[i] != 0) {
						track[i] = track[i] != 0 ? increaseHash(track[i], ch) : track[i];
					}
					i = (i + 1) % nGram;
				}
			}
		}
		if (track[current] != 0) {
			current = (current + 1) % nGram;
			if (track[current] != 0) {
				ret.add(track[current]);
			}
		}
		return ret;
	}
@ Override @ NotNull public IntOpenHashSet toShingleSet ( @ NotNull String s , int startIndex , int endIndex ) { if ( startIndex < 0 ) { throw new IllegalArgumentException ( "contentStart can't be smaller than 0" ) ; } IntOpenHashSet ret = new IntOpenHashSet ( ) ; Arrays . fill ( track , 0 ) ; int current = 0 ; for ( int charIndex = startIndex ; charIndex < endIndex ; ++ charIndex ) { char ch = s . charAt ( charIndex ) ; if ( STOP_WORD_SYMBOL_SET . contains ( ch ) ) { if ( track [ current ] != 0 ) { current = ( current + 1 ) % nGram ; if ( track [ current ] != 0 ) { ret . add ( track [ current ] ) ; track [ current ] = 0 ; } for ( int i = 0 ; i < nGram ; ++ i ) { track [ i ] = track [ i ] != 0 ? increaseHash ( track [ i ] , SPACE ) : track [ i ] ; } } } else { track [ current ] = increaseHash ( track [ current ] , ch ) ; int i = ( current + 1 ) % nGram ; while ( i != current ) { if ( track [ i ] != 0 ) { track [ i ] = track [ i ] != 0 ? increaseHash ( track [ i ] , ch ) : track [ i ] ; } i = ( i + 1 ) % nGram ; } } } if ( track [ current ] != 0 ) { current = ( current + 1 ) % nGram ; if ( track [ current ] != 0 ) { ret . add ( track [ current ] ) ; } } return ret ; }
Shingles that equal to '0' will not be returned
Shingles that equal to ' 0 ' will not be returned