I am dealing with an algorithm approach to finding keywords into my string. I have a HashSet contains almost 1 million keys in it and I want to replace all of these keys with blank into my sentences. My problem is this, when i have 1000 sentences with 10 word in it, it will become 10.000 words totally.
What is the best approach to search keywords into sentences here?
Set<String> keywords;//1.000.000 entry
for(int i =0;i<textModel.length;i++){//1.000 entry almost
String[] splitted = textModel[i].getText().split(" ");
for (int j = 0; j < splitted.length; j++) {
if(keywords.contains(splitted[j]){//?
splitted[j] = "";// ??
}
}
}
Is this approach OK? or should i use an text search algorithm for it?