java 判断文章的重复率_java题【续写下面的程序】要求找出文章中重复率最高的前五个单词(最好把过程写全,不调用其他方法)...

packagejavaapplication15;publicclassJavaApplication15{publicstaticvoidmain(String[]args){Stringarticle="Sendersandreceiversareofcoursevitalincommunication.Inface-to-facec...

package javaapplication15;

public class JavaApplication15 {

public static void main(String[] args) {

String article = "Senders and receivers are of course vital in communication. In face-to-face communication the roles of the sender and receiver are not distinct as both parties communicate with each other, even if in very subtle ways such as through eye-contact (or lack of) and general body language. There are many other subtle ways that we communicate (perhaps even unintentionally) with others, for example the tone of our voice can give clues to our mood or emotional state, whilst hand signals or gestures can add to a spoken message.";

String regex = "[\\p{Punct}\\s]{1,}";

String s[] = article.split(regex);

System.out.println("单词总数:" + s.length);

int i, j, max = 1;

for (i = 0; i < s.length; i++) {

s[i] = s[i].toLowerCase();//所有大写转为小写

}

下面就要检测单词的重复次数并且输出重复最多的前五个单词(最好不要用map方法)

展开

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值