Scala案例:全文单词统计

 2.txt内容如下

Thank you very much.Well I want to thank you all very much this is great, these are our friends, we have thousands of friends in this incredible movement.This was a movement like no nobody's ever seen before, and frankly this was I believe the greatest political movement of all time.There's never been anything like this in this country, and maybe beyond and now it's going to reach a new level of importance, because we're going to help our country heal, we're going to help our country heal, we have a country that needs help and it needs help very badly, we're going to fix our borders, we're going to fix everything about our country, and we made history for a reason tonight, and the reason is going to be just that.We overcame obstacles that nobody thought possible, and it is now clear that we've achieved the most incredible political thing, look what happened is this crazy?But it's a political victory that our country has never seen before nothing like this.I want to thank the American people for the extraordinary honor of being elected your 47th president and your 45th president.And every citizen I will fight for you for your family and your future every single s day.I will be fighting for you, and with every breath in my body.I will not rest until we have delivered the strong safe and prosperous America that our children deserve, and that you deserve.This will truly be the Golden Age of America that's what we have to have.This is a magnificent victory for the American people that will allow us to make America great again.And in addition to having won the battleground states of North Carolina, I love these places.Georgia Pennsylvania and Wisconsin we are now winning in Michigan Arizona Nevada and Alaska, which would result in US carrying at least 315 electoral votes, but as much easier doing what the networks did or whoever called it, because there was no other path.There was no other path to victory.We also have won the popular vote that was great. Thank you very much thank you.Winning the popular vote was very nice very nice, I will tell you.It's a great a great feeling of love we have a great feeling of love in this very large room with unbelievable people, standing by my side.These people have been incredible they've made the journey with me and we're going to make you very happy, we're going to make you very proud of your vote.I hope that you're going to be looking back someday, and say that was one of the truly important moments of my life, when I voted for this group of people beyond the president, this group of great people.America has given us an unprecedented and powerful mandate.We have taken back control of the Senate. That's great And the Senate races in Montana Nevada Texas Ohio Michigan Wisconsin, the great Commonwealth of Pennsylvania we all won by the MAGA movement they helped so much.And in those cases every one of them we worked with the Senators.They were tough races and I mean the number of victories in the Senate was absolutely incredible, and we did tell rallies we did tell rallies, with each one of them, and sometimes we did two or three for and it was amazing to look at all of those victories, nobody expected that nobody.So I just wanted to thank you very much for that and we have.You have some great senators and some great new senators, and it also looks like we'll be keeping control of the House of Representatives, and I want to thank Mike Johnson, I think he's doing a terrific job terrific job.I want to also thank my beautiful wife Melania first lady, who has the number one bestselling book in the country can you believe that?Now she's done a great job, works very hard, works very hard to help people, so I just want to thank her, but I want to thank my whole family, my amazing children and they are amazing children.Now we all thank our children are, everybody here thinks their children are amazing but that's a good thing when you think they are, but Don, Eric, Ivanka, Tiffany, Baron, Lura, Jared, Kimberly, Michael, thank you all what a help.

import java.io.PrintWriter
import scala.collection.mutable
import scala.io.Source
object t20 {def main(args: Array[String]): Unit = {//1.读入文件val content=Source.fromFile("C:\\Users\\Administrator\\Desktop\\2.txt").mkStringprintln(content)//2.拆分字符串 --> 单词数组
//    val rs=content.split(" ")   //正则表达式
//    \\正则
//    W:表示非字符(,空格 ?...)
//    W+:多个非字符val rs=content.split("\\W+")println("-"*40)rs.foreach(println)//3.统计出现的频率val wordsMap=mutable.Map[String,Int]()rs.foreach(w=>{val word=w.toLowerCase()//全小写//是否出现if(wordsMap.contains(word)){wordsMap(word)+=1}else{wordsMap(word)=1}})//4.根据出现的次数从高到低排序// Map不能直接排序,需要转成有序的集合val orderlist=wordsMap.toList.sortWith((a,b)=>a._2>b._2)//5.保存结果,涉及写入文件val writer=new PrintWriter("output.txt")for(e<-orderlist){println(e._1,e._2)//打印到屏幕writer.println(s"${e._1} : ${e._2}次")}writer.close()}
}

 

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/pingmian/61376.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

【STK学习】part2-星座-目标可见性与覆盖性分析

【Satellite Tool Kit】学习并深入了解卫星/星座生成、可见性分析、覆盖性分析等知识&#xff0c;并基于STK软件实现对应数据的导出&#xff0c;以用于算法的约束输入。 文章目录 一、学习目标二、学习内容2.1 星地可见性分析2.1.1 单星单地2.1.2 单星多地2.1.3 多星单地 2.2 星…

金融数据中心容灾“大咖说” | 美创科技赋能“灾备一体化”建设

中国人民银行发布的《金融数据中心容灾建设指引》&#xff08;JR/T 0264—2024&#xff09;已于2024年7月29日正式实施。这一金融行业标准对金融数据中心容灾建设中的“组织保障、需求分析、体系规划、建设要求、运维管理”进行了规范和指导。面对不断增加的各类网络、业务、应…

《第十部分》1.STM32之通信接口《精讲》之IIC通信---介绍

经过近一周的USART学习&#xff0c;我深刻体会到通信对单片机的重要性。它就像人类的手脚和大脑&#xff0c;只有掌握了通信技术&#xff0c;单片机才能与外界交互&#xff0c;展现出丰富多彩的功能&#xff0c;变得更加强大和实用。 单片机最基础的“语言”是二进制。可惜&am…

Vue通过file控件上传文件到Node服务器

功能&#xff1a; 1.多文件同时上传、2.拖动上传、3.实时上传进度条、4.中断上传和删除文件、5.原生file控件的美化 搁置的功能: 上传文件夹、大文件切片上传、以及其他限制条件未处理 Node服务器的前置准备: 新建文件夹: file_upload_serve初始化npm: npm …

如何使用 Docker Compose 安装 WireGuard UI

简介 wireguard是什么&#xff1f;维基百科是这样描述的&#xff1a; WireGuard是一种实现加密虚拟专用网络(VPN) 的通信协议和免费开源软件&#xff0c;其设计目标是易于使用&#xff0c;高速性能和低攻击面。它旨在比IPsec和OpenVPN这两种常见的隧道协议具有更好的性能和更…

IM项目-----客户端网络通讯流程

文章目录 前言数据中心类数据持久化网络通信类http客户端websocket客户端 前言 对即时通信系统客户端部分的网络通讯流程的总结。 数据中心类 通过model/datacenter.h 中的DataCenter 类来管理所有客⼾端需要的数据.这是⼀个单例类. 这里管理一份数据有两个作用&#xff0c;1…

软件测试—— Selenium 常用函数(一)

前一篇文章&#xff1a;软件测试 —— 自动化基础-CSDN博客 目录 前言 一、窗口 1.屏幕截图 2.切换窗口 3.窗口设置大小 4.关闭窗口 二、等待 1.等待意义 2.强制等待 3.隐式等待 4.显式等待 总结 前言 在前一篇文章中&#xff0c;我们介绍了自动化的一些基础知识&a…

WebSocket详解、WebSocket入门案例

目录 1.1 WebSocket介绍 http协议&#xff1a; webSocket协议&#xff1a; 1.2WebSocket协议&#xff1a; 1.3客户端&#xff08;浏览器&#xff09;实现 1.3.2 WebSocket对象的相关事宜&#xff1a; 1.3.3 WebSOcket方法 1.4 服务端实现 服务端如何接收客户端发送的请…

【图像分割】SegFormer: Simple and Efficient Design for Semantic Segmentation with Transformers

SegFormer: Simple and Efficient Design for Semantic Segmentation with Transformers 论文链接&#xff1a;http://arxiv.org/abs/2105.15203 代码链接&#xff1a;https://github.com/NVlabs/SegFormer 一、摘要 文中提出了SegFormer&#xff0c;一个简单、高效且强大的…

Linux修改/etc/hosts不起作用(ping: xxx: Name or service not known)的解决方法——开启NSCD

​ 问题描述 起因是我在实验室云资源池的一台虚拟机&#xff08;CentOS 8.5&#xff09;上的/etc/hosts文件中为Fabric网络节点的域名指定了IP&#xff1a; IP可以ping通&#xff0c;但是ping域名时提示ping: xxx: Name or service not known。 问题本身应该是Linux通用的&a…

OpenTelemetry 赋能DevOps流程的可观测性革命

原作者&#xff1a;天颇 原出处&#xff1a;微信公众号 乘云数字DATABUFF 原文地址&#xff1a;https://mp.weixin.qq.com/s/D_f31EBtLu7Rr0gahuF-bw 引言 在当今快节奏的软件开发和运维环境中&#xff0c;DevOps 已经成为主流&#xff0c;它通过整合开发和运维流程&#xff0…

windows 和 linux检查操作系统基本信息

windows检查操作系统基本信息 systeminfolinux检查操作系统基本信息 获取系统位数 getconf LONG_BIT查询操作系统release信息 lsb_release -a查询系统信息 cat /etc/issue查询系统名称 uname -a

使用SaaS化的Aurora应用快速搭建私人ChatGPT助手

使用SaaS化的Aurora应用快速搭建私人ChatGPT助手 简介&#xff1a; Aurora是一个带UI且免费的GPT私人聊天助手&#xff0c;可切换GPT-3.5&#xff0c;4&#xff0c;4o等常用版本。用户可通过部署Aurora&#xff0c;快速打造自己专属的AI助手。阿里云计算巢已将Aurora打包为SaaS…

ASFSSA-VMD多策略改进的麻雀搜索算法优化变分模态分解

ASFSSA-VMD多策略改进的麻雀搜索算法优化变分模态分解 目录 ASFSSA-VMD多策略改进的麻雀搜索算法优化变分模态分解效果分析基本介绍程序设计参考资料效果分析 基本介绍 (创新独家)ASFSSA-VMD多策略改进的麻雀搜索算法优化变分模 态分解ASFSSA-VMD:优化VMD分解层数K和惩罚因子a…

Unity脚本基础规则

Unity脚本基础规则 如何在Unity中创建一个脚本文件&#xff1f; 在Project窗口中的Assets目录下&#xff0c;选择合适的文件夹&#xff0c;右键&#xff0c;选择第一个Create&#xff0c;在新出现的一栏中选择C# Script&#xff0c;此时文件夹内会出现C#脚本图标&#xff0c;…

【新华妙笔-注册/登录安全分析报告-无验证方式导致安全隐患】

前言 由于网站注册入口容易被黑客攻击&#xff0c;存在如下安全问题&#xff1a; 1. 暴力破解密码&#xff0c;造成用户信息泄露 2. 短信盗刷的安全问题&#xff0c;影响业务及导致用户投诉 3. 带来经济损失&#xff0c;尤其是后付费客户&#xff0c;风险巨大&#xff0c;造…

使用vscode+expo+Android夜神模拟器运行react-native项目

1.进入夜神模拟器安装路径下的bin目录 2.输入命令&#xff0c;连接Android Studio 启动夜神模拟器后&#xff0c; 打开安装目录的bin文件夹执行下面的命令&#xff0c;只需执行一次&#xff09; nox_adb.exe connect 127.0.0.1:62001adb connect 127.0.0.1:62001 3.运行项目…

Linux进阶:软件安装、网络操作、端口、进程等

软件安装 yum 和 apt 均需要root权限 CentOS系统使用&#xff1a; yum [install remove search] [-y] 软件名称 install 安装remove 卸载search 搜索-y&#xff0c;自动确认 Ubuntu系统使用 apt [install remove search] [-y] 软件名称 install 安装remove 卸载search 搜索-y&…

linux先创建文件夹后指定创建文件夹用户

1、创建文件夹&#xff0c;然后创建用户并指定用户目录&#xff0c;然后修改目录所有权给该目录 # 创建 /home/test 目录 mkdir /home/test # 设置权限&#xff08;确保有适当的读写权限&#xff09; chown root:root /home/test chmod 700 /home/test # 创建 xl 用户并指定家…

记录下,用油猴Tampermonkey监听所有请求,绕过seesion

油猴Tampermonkey监听所有请求&#xff0c;绕过seesion 前因后果脚本编写 前因后果 原因是要白嫖一个网站的接口&#xff0c;这个接口的页面入口被隐藏掉了&#xff0c;不能通过页面调用&#xff0c;幸好之前有想过逆向破解通过账号密码模拟登录后拿到token&#xff0c;请求该…