如何在段落中找到重复的单词 [英] how to find repeted words i n the paragraph

查看:110
本文介绍了如何在段落中找到重复的单词的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个段落,我们想找出重复出现多少次的单词.这给了
输出单词并且没有时间输出,如果它来一次.

''We have a Paragraph in which we want to find out the word which are repeat how many time.That''s give
output the word and no of time if it''s come more tha one times.

推荐答案

由于这听起来很像作业,所以我不会给你任何代码.
话虽如此,这并不困难,只需按照以下步骤进行操作,并进行测试以确保它在每个步骤之后都可以正常工作:
1)使用空格和标点符号将您的段落分成单独的单词.丢弃所有此类字符,并将其全部转换为小写.
Since this sounds a lot like homework, I won''t give you any code.
Having said that, it isn''t that difficult, just follow the steps, and test to ensure it works after each step:
1) Break your paragraph into separate words, using space and punctuation. Discard all such characters, and convert it all to lower case.
"The quick, brown fox jumps. The dog did not!"

成为

the
quick
brown
fox
jumps
the
dog
did
not


2)将您的单词按字母顺序排序:


2) Sort your words into alphabetical order:

brown
did
dog
fox
jumps
not
quick
the
the


3)现在比较相邻的单词:如果它们相同,则将其加一.


3) Now compare adjacent words: if they are the same, add one to the count.


这篇关于如何在段落中找到重复的单词的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆