Imagine you want a WordCloud
but need to keep phrases such as "New York" or "Rio de Janeiro" or "tongue-in-cheek". Lets define a simple function:
keep[text_, list_] := StringCases[text, list]~Join~TextWords[DeleteStopwords[StringDelete[text, list]]]
It is important where in the code to place DeleteStopwords
not to loose them in your whitelisted phrases. Now let's check the effect on Wikipedia article about the famous statue Christ the Redeemer. Our white list is obvious:
list = {"rio de janeiro", "christ the redeemer"};
Import text:
text = ToLowerCase[Import["https://en.wikipedia.org/wiki/Christ_the_Redeemer_(statue)"]];
and see the result compared to the one without whitelisting:
WordCloud[keep[text, list], WordOrientation -> {{-?/4, ?/4}}]
WordCloud[DeleteStopwords[text], WordOrientation -> {{-?/4, ?/4}}]