JAVA算法问题,请cs高手帮忙最近在做cs3214 project, 编forum时有一个过滤器的问题不能解决, 请大侠们帮忙,万分感激。
requirement: E-moderator: Vulgar words or phrases are automatically replaced with hexes (‘###’). Strictly bans any occurrence of words/phrases that appear in the banned-words list, even if users deliberately join them together with other
words/punctuation to try and escape the ban.
就是说,不论是"shit", "s h i t" 还是"s^h#i*t", 都会被变成相对应的"####", "# # # #", or "#^###*#".
自己想来想去也找不到好算法,就靠各位高手们帮忙啦。如果能提供一些相关code最耗,不管怎样,小弟先谢过了。
hope this works
i think u can try the following approach, store the words into a vector,
(or a trie, if program efficienty is impt). and the just use the same method
the merge step from merge sort.
In fact, i doubt if your approach is really work. For exmaple:
if u meet two word shioth, and shiito, will u filter them or not? they are
'legal' words from dictionary.
(or a trie, if program efficienty is impt). and the just use the same method
the merge step from merge sort.
In fact, i doubt if your approach is really work. For exmaple:
if u meet two word shioth, and shiito, will u filter them or not? they are
'legal' words from dictionary.