/** * Generates key for the given {@link DocumentWrapper} * @param level influences the keyLength, the keyLength is a multiplication of the level and {@link #KEY_PART_LENGTH} */ @Override public String generateKey(DocumentProtos.DocumentMetadata doc) { String docKey = DocumentWrapperUtils.getMainTitle(doc); docKey = StringTools.normalize(docKey); docKey = StringTools.removeStopWords(docKey); docKey = docKey.replaceAll("\\s", ""); StringBuilder oddCharsSB = new StringBuilder(); for (int i=0; i < docKey.length(); i += 2) { oddCharsSB.append(docKey.charAt(i)); } docKey = oddCharsSB.toString(); int keyLength = KEY_PART_LENGTH; if (docKey.length() > keyLength) { docKey = docKey.substring(0, keyLength); } return docKey; } }
result = removeStopWords(result); result = result.toLowerCase(); result = result.trim().replaceAll(" +", " ");