use*_*063 4 matlab text-processing stop-words
我的查询是停用词string = 'Alligator in water'在哪里in.如何删除它以便获得stop_remove = 'Alligator water'输出.我试过它,ismember但它返回匹配单词的整数值,我想得到剩余的单词作为输出.
in 只是一个例子,我想删除所有可能的停用词.
比Luis Mendo的解决方案更优雅的方式是使用regexprep它完全符合您的要求
>> result = regexprep( 'Alligator in water', 'in\s*', '' ); % replace with an empty string
result =
Alligator water
Run Code Online (Sandbox Code Playgroud)
如果你有几个停用词,你可以简单地将它们添加到模式中(在这个例子中我考虑'in'并'near'作为停用词):
>> result = regexprep( 'Alligator in water near land', {'in\s*','near\s*'}, '' )
result =
Alligator water land
Run Code Online (Sandbox Code Playgroud)