Created
October 11, 2017 03:55
-
-
Save kimtrien/f7a100a14508bace785d6469d9150cdf to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static List<String> findNotMatching(String sourceStr, String anotherStr){ | |
String new_souce = sourceStr.replaceAll("[^a-zA-Z ]", "").toLowerCase(); | |
anotherStr = anotherStr.replaceAll("[^a-zA-Z ]", "").toLowerCase(); | |
StringTokenizer at = new StringTokenizer(new_souce, " "); | |
StringTokenizer bt = null; | |
int i = 0, token_count = 0; | |
String token = null; | |
boolean flag = false; | |
List<String> missingWords = new ArrayList<String>(); | |
while (at.hasMoreTokens()) { | |
token = at.nextToken(); | |
bt = new StringTokenizer(anotherStr, " "); | |
token_count = bt.countTokens(); | |
while (i < token_count) { | |
String s = bt.nextToken(); | |
if (token.equals(s)) { | |
flag = true; | |
break; | |
} else { | |
flag = false; | |
} | |
i++; | |
} | |
i = 0; | |
if (flag == false) { | |
missingWords.add(token); | |
} | |
} | |
return missingWords; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment