How to split sentence?
显示 更早的评论
cover_str = 'Great things in business done by one person. They done by a team of people.'
I want to split the above string into two sentences like
s1='Great things in business done by one person'.
s2='They done by a team of people'.
How can i do the above process in Matlab.
With regards.
采纳的回答
s = strsplit(cover_str,'.')
9 个评论
Thanks sir.
Sir how can i store these sentence into two different varibles for further process.
Already they are in two different variables. S{1}, S{2}
Note that there can be multiple delimiters of sentences, depending on the language. These are the ones I could think of for English:
delim={'.','...','?','!','!,','!?','?!?','!?!'};
The latter four are debatable, but you probably get the idea. You could even consider adding obscure ones like the interobang (‽, see disp(char(8253)) to view the symbol in Matlab)
Especially the ellipsis is tricky: it is often redered as three dots (as I did above), or as the ellipsis character … (char 8230).
That command results in the cell array s with three elments because the last character in cover_str is the delimiter. The third element is empty.
>> strsplit(cover_str,'.').'
ans =
3×1 cell array
{'Great things in business done by one person'}
{' They done by a team of people' }
{0×0 char }
Also, you may want to consider just using split, though split doesn't seem to have quite as much functionality as strsplit.
>> split(string(cover_str),'.')
ans =
3×1 string array
"Great things in business done by one person"
" They done by a team of people"
""
Thank you very much sir..
You should also be careful if you have any decimal values in your sentences that use the period as decimal indicator. But that all depends on how robust you need this splitter to be.
Thank you sir..
But problem is that I am not able to find maximum occurrence of vowels in the split string. Please help
With regards
Read about strfind.
Ok Sir..Thanks
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Characters and Strings 的更多信息
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!选择网站
选择网站以获取翻译的可用内容,以及查看当地活动和优惠。根据您的位置,我们建议您选择:。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 MathWorks 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
- América Latina (Español)
- Canada (English)
- United States (English)
欧洲
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
