src/main/java/org/jboss/pressgang/ccms/model/utils/TopicUtilities.java
protected static Integer getMinHashInternal(final String cleanedXML, final Integer xor) {
        // now generate the minhashes
        String[] words = cleanedXML.replaceAll("\\p{Punct}", " ").split("\\s+");

        if (words.length == 0) {
            words = new String[] {""};
        }

        final List<String> shingles = new ArrayList<String>();

        if (words.length < SHINGLE_WORD_COUNT) {
            final StringBuilder shingle = new StringBuilder();
            for (int i = 0; i < words.length; ++i) {
                if (shingle.length() != 0) {
                    shingle.append(" ");
                }
                shingle.append(words[i]);
            }
            final int hash =  shingle.toString().hashCode();
            if (xor != null) {
                return hash ^ xor;
            } else {
                return hash;
            }
        } else {
            for (int i = 0; i < words.length - SHINGLE_WORD_COUNT + 1; ++i) {
                final StringBuilder shingle = new StringBuilder();
                for (int j = i; j < words.length && j < i + SHINGLE_WORD_COUNT; ++j) {
                    if (shingle.length() != 0) {
                        shingle.append(" ");
                    }
                    shingle.append(words[j]);
                }
                shingles.add(shingle.toString());
            }

            Integer minHash = null;
            for (final String string : shingles) {
                final int hash = string.hashCode();
                final int finalHash = xor != null ? hash ^ xor : hash;
                if (minHash == null || finalHash < minHash) {
                    minHash = finalHash;
                }
            }
            return minHash;
        }
    }
protected static Integer getMinHashInternal(final String cleanedXML, final Integer xor) {
        // now generate the minhashes
        String[] words = cleanedXML.replaceAll("\\p{Punct}", " ").split("\\s+");

        if (words.length == 0) {
            words = new String[] {""};
        }

        final List<String> shingles = new ArrayList<String>();

        if (words.length < SHINGLE_WORD_COUNT) {
            final StringBuilder shingle = new StringBuilder();
            for (int i = 0; i < words.length; ++i) {
                if (shingle.length() != 0) {
                    shingle.append(" ");
                }
                shingle.append(words[i]);
            }
            final int hash =  shingle.toString().hashCode();
            if (xor != null) {
                return hash ^ xor;
            } else {
                return hash;
            }
        } else {
            for (int i = 0; i < words.length - SHINGLE_WORD_COUNT + 1; ++i) {
                final StringBuilder shingle = new StringBuilder();
                for (int j = i; j < words.length && j < i + SHINGLE_WORD_COUNT; ++j) {
                    if (shingle.length() != 0) {
                        shingle.append(" ");
                    }
                    shingle.append(words[j]);
                }
                shingles.add(shingle.toString());
            }

            Integer minHash = null;
            for (final String string : shingles) {
                final int hash = string.hashCode();
                final int finalHash = xor != null ? hash ^ xor : hash;
                if (minHash == null || finalHash < minHash) {
                    minHash = finalHash;
                }
            }
            return minHash;
        }
    }
Returns the minimum hash of the sentences in an XML file.
@param cleanedXML The cleaned xml to analyse
@param xor the number to xor the hash against. Null if the standard hashCode() method should be used alone.
@return The minimum hash