diff --git a/063/.classpath b/063/.classpath
new file mode 100644
index 0000000000000000000000000000000000000000..97f72100ac9f2489ec137c679343a32d41834cc5
--- /dev/null
+++ b/063/.classpath
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
diff --git a/063/.gitignore b/063/.gitignore
new file mode 100644
index 0000000000000000000000000000000000000000..ae3c1726048cd06b9a143e0376ed46dd9b9a8d53
--- /dev/null
+++ b/063/.gitignore
@@ -0,0 +1 @@
+/bin/
diff --git a/063/.keep b/063/.keep
new file mode 100644
index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
diff --git a/063/.project b/063/.project
new file mode 100644
index 0000000000000000000000000000000000000000..e38873f6ed91c388b583eb0988fd5ccbae02d2a1
--- /dev/null
+++ b/063/.project
@@ -0,0 +1,17 @@
+
+
+ 201621123063
+
+
+
+
+
+ org.eclipse.jdt.core.javabuilder
+
+
+
+
+
+ org.eclipse.jdt.core.javanature
+
+
diff --git a/063/.settings/org.eclipse.core.resources.prefs b/063/.settings/org.eclipse.core.resources.prefs
new file mode 100644
index 0000000000000000000000000000000000000000..4824b8026319a8fb303971008a7d59a816d58bd6
--- /dev/null
+++ b/063/.settings/org.eclipse.core.resources.prefs
@@ -0,0 +1,2 @@
+eclipse.preferences.version=1
+encoding/=UTF-8
diff --git a/063/.settings/org.eclipse.jdt.core.prefs b/063/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 0000000000000000000000000000000000000000..3a21537071bf4118b9e1ee864cb4bc258aa48211
--- /dev/null
+++ b/063/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,11 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=1.8
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.8
diff --git a/063/1.txt b/063/1.txt
new file mode 100644
index 0000000000000000000000000000000000000000..36664e6d62fc63b18f5a1971febd6db231c6e3cb
--- /dev/null
+++ b/063/1.txt
@@ -0,0 +1,2 @@
+I love dasd
+dasd
\ No newline at end of file
diff --git a/063/2.txt b/063/2.txt
new file mode 100644
index 0000000000000000000000000000000000000000..3e71c3714f64ed4a689c18055d2ed512cf11a215
--- /dev/null
+++ b/063/2.txt
@@ -0,0 +1,13 @@
+A man may usually be known by the books he reads as well as by the company he keeps; for there is a companionship of books as well as of men; and one should always live in the best company, whether it be of books or of men.
+
+ A good book may be among the best of friends. It is the same today that it always was, and it will never change. It is the most patient and cheerful of companions. It does not turn its back upon us in times of adversity or distress. It always receives us with the same kindness; amusing and instructing us in youth, and comforting and consoling us in age.
+
+ Men often discover their affinity to each other by the mutual love they have for a book just as two persons sometimes discover a friend by the admiration which both entertain for a third. There is an old proverb, Love me, love my dog. But there is more wisdom in this: Love me, love my book. The book is a truer and higher bond of union. Men can think, feel, and sympathize with each other through their favorite author. They live in him together, and he in them.
+
+ A good book is often the best urn of a life enshrining the best that life could think out; for the world of a mans life is, for the most part, but the world of his thoughts. Thus the best books are treasuries of good words, the golden thoughts, which, remembered and cherished, become our constant companions and comforters.
+
+ Books possess an essence of immortality. They are by far the most lasting products of human effort. Temples and statues decay, but books survive. Time is of no account with great thoughts, which are as fresh today as when they first passed through their authors minds, ages ago. What was then said and thought still speaks to us as vividly as ever from the printed page. The only effect of time have been to sift out the bad products; for nothing in literature can long survive e but what is really good.
+
+ Books introduce us into the best society; they bring us into the presence of the greatest minds that have ever lived. We hear what they said and did; we see the as if they were really alive; we sympathize with them, enjoy with them, grieve with them; their experience becomes ours, and we feel as if we were in a measure actors with them in the scenes which they describe.
+
+ The great and good do not die, even in this world. Embalmed in books, their spirits walk abroad. The book is a living voice. It is an intellect to which on still listens.
\ No newline at end of file
diff --git a/063/bin/wCount/CountWordFrame.class b/063/bin/wCount/CountWordFrame.class
new file mode 100644
index 0000000000000000000000000000000000000000..30a57f8865ebc7962331e8a304eb2842a5e109e0
Binary files /dev/null and b/063/bin/wCount/CountWordFrame.class differ
diff --git a/063/bin/wCount/FileAdapter.class b/063/bin/wCount/FileAdapter.class
new file mode 100644
index 0000000000000000000000000000000000000000..3148e40a06c80d3218f2b06b8deb3dce2f06eb40
Binary files /dev/null and b/063/bin/wCount/FileAdapter.class differ
diff --git a/063/bin/wCount/Main.class b/063/bin/wCount/Main.class
new file mode 100644
index 0000000000000000000000000000000000000000..aac3451ac24ed8c6e3e6d04da4d8dfe703cae462
Binary files /dev/null and b/063/bin/wCount/Main.class differ
diff --git a/063/bin/wCount/MainFrame.class b/063/bin/wCount/MainFrame.class
new file mode 100644
index 0000000000000000000000000000000000000000..68c381c3437b4e51dd90e1bf5113ca265292dcf7
Binary files /dev/null and b/063/bin/wCount/MainFrame.class differ
diff --git a/063/bin/wCount/Word$1.class b/063/bin/wCount/Word$1.class
new file mode 100644
index 0000000000000000000000000000000000000000..375fe1e97b47938d57c9b2fd97e93d801c068a52
Binary files /dev/null and b/063/bin/wCount/Word$1.class differ
diff --git a/063/bin/wCount/Word.class b/063/bin/wCount/Word.class
new file mode 100644
index 0000000000000000000000000000000000000000..341fc7df79d7740c09804e04c9f513f9ff2b9cdb
Binary files /dev/null and b/063/bin/wCount/Word.class differ
diff --git a/063/result.txt b/063/result.txt
new file mode 100644
index 0000000000000000000000000000000000000000..bff850d6de81a06f260545424f1e5026aa3cc13d
--- /dev/null
+++ b/063/result.txt
@@ -0,0 +1,5 @@
+characters:17
+words:2
+lines:2
+[dasd]:2
+[love]:1
diff --git a/063/src/wCount/CountWordFrame.java b/063/src/wCount/CountWordFrame.java
new file mode 100644
index 0000000000000000000000000000000000000000..e6fc8f2b5ddbe93a5d4e8f409ad49988200a610e
--- /dev/null
+++ b/063/src/wCount/CountWordFrame.java
@@ -0,0 +1,101 @@
+package wCount;
+
+import java.awt.Dimension;
+import java.awt.Font;
+import java.awt.GridLayout;
+import java.awt.Toolkit;
+import java.io.IOException;
+import java.util.List;
+import java.util.Map;
+
+import javax.swing.JFrame;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+
+public class CountWordFrame extends JFrame{
+
+ private JLabel label1;
+ private JPanel jPanel;
+
+ public CountWordFrame(String fileText,int flag,int para) {
+
+ this.setTitle("词频统计byYelz");
+ this.setSize(800, 600);
+
+ Toolkit kit = Toolkit.getDefaultToolkit();
+ Dimension dimension = kit.getScreenSize();
+ Dimension size = this.getSize();
+ int x = (int) (dimension.getWidth() - size.getWidth()) / 2;
+ int y = (int) (dimension.getHeight() - size.getHeight()) / 2;
+ this.setLocation(x, y);
+
+ this.setLayout(new GridLayout(3, 1));
+
+ Word wd = new Word(fileText);
+
+ int charNum = wd.getCharNum();//字符数量
+ int lines = wd.getLines();//有效行
+ List> sortedWord;
+ int wordNum;
+ String s = "";
+ String strForFile = "";
+ if(flag ==0)
+ {
+ sortedWord=wd.getSortedWord();//得到排序后的存放单词和词频键值对的list
+ wordNum = sortedWord.size();
+ s += "characters:"+ charNum + "
words:" + wordNum + "
lines:" + lines + "
";
+ strForFile += "characters:"+ charNum + "\r\nwords:" + wordNum + "\r\nlines:" + lines + "\r\n";
+ int cnt = para;
+ if(sortedWord.size()>cnt)
+ {
+ for (int i = 0; i < cnt; i++)//输出词频最高前十单词
+ {
+ s += "["+sortedWord.get(i).getKey()+"]:"+sortedWord.get(i).getValue() + "
";
+ strForFile += "["+sortedWord.get(i).getKey()+"]:"+sortedWord.get(i).getValue() + "\r\n";
+ }
+ }
+ else
+ {
+ for (int i = 0; i < sortedWord.size(); i++)//输出词频最高的单词
+ {
+ s += "["+sortedWord.get(i).getKey()+"]:"+sortedWord.get(i).getValue() + "
";
+ strForFile += "["+sortedWord.get(i).getKey()+"]:"+sortedWord.get(i).getValue() + "\r\n";
+ }
+ }
+ }
+ else
+ {
+ sortedWord=wd.getLengthSortedWord(para);//得到排序后的存放单词和词频键值对的list
+ wordNum = sortedWord.size();
+ s = "characters:"+ charNum + "
words:" + wordNum + "
lines:" + lines + "
";
+ strForFile += "characters:"+ charNum + "\r\nwords:" + wordNum + "\r\nlines:" + lines + "\r\n";
+ for (int i = 0; i < sortedWord.size(); i++)//输出词频最高的单词
+ {
+ s += "["+sortedWord.get(i).getKey()+"]:"+sortedWord.get(i).getValue() + "
";
+ strForFile += "["+sortedWord.get(i).getKey()+"]:"+sortedWord.get(i).getValue() + "\r\n";
+ }
+ }
+
+ //结果写入result.txt文件
+ try {
+ FileAdapter fileAdapter = new FileAdapter();
+ fileAdapter.WriteToFile(strForFile);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+
+ jPanel = new JPanel();
+ label1 = new JLabel(""+s+"");
+ label1.setFont(new Font("宋体", 1, 25));
+ jPanel.add(label1);
+ this.add(jPanel);
+
+ this.setLayout(new GridLayout(1, 1));
+ this.setVisible(true);
+
+
+ }
+
+
+
+}
diff --git a/063/src/wCount/FileAdapter.java b/063/src/wCount/FileAdapter.java
new file mode 100644
index 0000000000000000000000000000000000000000..8265eccd5033e6db947815144891b79c6b292856
--- /dev/null
+++ b/063/src/wCount/FileAdapter.java
@@ -0,0 +1,34 @@
+package wCount;
+
+import java.io.*;
+
+public class FileAdapter { // 该类用于文件写入读取的处理
+
+ public String FileToString(File file) throws IOException { // 将文件转化为字符串
+ if (!file.exists() || file.isDirectory()) {
+ System.out.println("请输入正确文件名!");
+ throw new FileNotFoundException();
+ }
+ FileInputStream fis = new FileInputStream(file);
+ byte[] buf = new byte[1024];
+ StringBuffer sb = new StringBuffer();
+ while ((fis.read(buf)) != -1) {
+ sb.append(new String(buf));
+ buf = new byte[1024];// 重新生成,避免和上次读取的数据重复
+ }
+ fis.close();
+ return sb.toString();
+ }
+
+ public void WriteToFile(String str) throws IOException { // 将传入的字符串写入文件
+ File writename = new File("result.txt"); // 相对路径,如果没有则要建立一个新的文件
+ writename.createNewFile(); // 创建新文件
+ BufferedWriter out = new BufferedWriter(new FileWriter(writename));
+ out.write(str);
+
+ out.flush(); // 把缓存区内容压入文件
+ out.close(); // 关闭文件
+
+ }
+
+}
diff --git a/063/src/wCount/Main.java b/063/src/wCount/Main.java
new file mode 100644
index 0000000000000000000000000000000000000000..201a0a48bbba8d175f3a62f6fc49efc75a9a1154
--- /dev/null
+++ b/063/src/wCount/Main.java
@@ -0,0 +1,9 @@
+package wCount;
+
+public class Main {
+
+ public static void main(String[] args){
+ new MainFrame();
+ }
+
+}
diff --git a/063/src/wCount/MainFrame.java b/063/src/wCount/MainFrame.java
new file mode 100644
index 0000000000000000000000000000000000000000..d2be97979343d64d3bb09359c3db0c6be7f43273
--- /dev/null
+++ b/063/src/wCount/MainFrame.java
@@ -0,0 +1,160 @@
+package wCount;
+
+import java.awt.BorderLayout;
+import java.awt.Dimension;
+import java.awt.GridLayout;
+import java.awt.Label;
+import java.awt.TextField;
+import java.awt.Toolkit;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.io.File;
+import java.io.IOException;
+import java.util.regex.Pattern;
+
+import javax.swing.JButton;
+import javax.swing.JFileChooser;
+import javax.swing.JFrame;
+import javax.swing.JLabel;
+import javax.swing.JOptionPane;
+import javax.swing.JPanel;
+
+public class MainFrame extends JFrame implements ActionListener{
+
+ private JButton chooseFile,topCount,lenCount;
+ private TextField topText,lenText;
+ private JPanel jPanel1,jPanel2,jPanel3;
+ private JLabel fileName,topTip,lenTip;
+ private String fileText;
+ private File file;
+ public MainFrame() {
+ this.setTitle("词频统计byYelz");
+ this.setSize(800, 600);
+
+ Toolkit kit = Toolkit.getDefaultToolkit();
+ Dimension dimension = kit.getScreenSize();
+ Dimension size = this.getSize();
+ int x = (int) (dimension.getWidth() - size.getWidth()) / 2;
+ int y = (int) (dimension.getHeight() - size.getHeight()) / 2;
+ this.setLocation(x, y);
+
+ this.setLayout(new GridLayout(3, 1));
+
+ chooseFile = new JButton("选择文件");
+ chooseFile.addActionListener(this);
+ topCount = new JButton("按词频排序前n单词");
+ topCount.addActionListener(this);
+ lenCount = new JButton("按单词长度和词频排序");
+ lenCount.addActionListener(this);
+
+ topText = new TextField(10);
+ lenText = new TextField(10);
+
+ topTip = new JLabel("统计词频前几的单词?");
+ lenTip = new JLabel("请输入想统计的单词长度:");
+
+
+ jPanel1 = new JPanel();
+ jPanel2 = new JPanel();
+ jPanel3 = new JPanel();
+
+ jPanel1.add(chooseFile);
+ this.add(jPanel1);
+
+ jPanel2.add(topTip);
+ jPanel2.add(topText);
+ jPanel2.add(topCount);
+ this.add(jPanel2);
+
+ jPanel3.add(lenTip);
+ jPanel3.add(lenText);
+ jPanel3.add(lenCount);
+ this.add(jPanel3);
+
+ this.fileText="";
+ this.file = null;
+
+ this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+ this.setVisible(true);
+ }
+
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ // TODO 自动生成的方法存根
+ if(e.getSource() == chooseFile)
+ {
+ try {
+ JFileChooser fc = new JFileChooser();
+ fc.setDialogTitle("打开txt文件");
+ int result = fc.showOpenDialog(this); // 打开"打开文件"对话框
+ // int result = dlg.showSaveDialog(this); // 打"开保存文件"对话框
+ if (result == JFileChooser.APPROVE_OPTION) {
+ file = fc.getSelectedFile();
+ }
+ if(file!=null)
+ {
+ FileAdapter fd = new FileAdapter();
+ String text = fd.FileToString(file);
+ this.fileText=text;
+// System.out.println(fileText);
+ if(fileName!=null)
+ jPanel1.remove(1);
+ fileName = new JLabel("已选文件名:"+file.getName());
+ jPanel1.add(fileName,BorderLayout.WEST);
+ this.repaint();
+ this.validate();
+ }
+ } catch (IOException e1) {
+ e1.printStackTrace();
+ }
+ }
+ if(e.getSource() == topCount)
+ {
+ if(file != null)
+ {
+ if(topText.getText().equals("") || topText.getText()==null)
+ {
+ JOptionPane.showMessageDialog(null, "请输入整数确定显示前几单词", "错误", JOptionPane.ERROR_MESSAGE);
+ }
+ else if(!isInteger(topText.getText()))
+ {
+ JOptionPane.showMessageDialog(null, "请输入整数", "错误", JOptionPane.ERROR_MESSAGE);
+ }
+ else {
+ new CountWordFrame(fileText, 0, Integer.parseInt(topText.getText()));
+ topText.setText("");
+ //this.dispose();
+ }
+ }
+ else {
+ JOptionPane.showMessageDialog(null, "请先选择文件!", "错误", JOptionPane.ERROR_MESSAGE);
+ }
+
+ }
+ if(e.getSource()==lenCount){
+ if(file != null)
+ {
+ if(lenText.getText().equals("") || lenText.getText()==null)
+ {
+ JOptionPane.showMessageDialog(null, "请输入整数确定显示前几单词", "错误", JOptionPane.ERROR_MESSAGE);
+ }
+ else if(!isInteger(lenText.getText()))
+ {
+ JOptionPane.showMessageDialog(null, "请输入整数", "错误", JOptionPane.ERROR_MESSAGE);
+ }
+ else {
+ new CountWordFrame(fileText, 1, Integer.parseInt(lenText.getText()));
+ lenText.setText("");
+ //this.dispose();
+ }
+ }
+ else {
+ JOptionPane.showMessageDialog(null, "请先选择文件!", "错误", JOptionPane.ERROR_MESSAGE);
+ }
+ }
+ }
+ public static boolean isInteger(String str) {
+ Pattern pattern = Pattern.compile("^[-\\+]?[\\d]*$");
+ return pattern.matcher(str).matches();
+ }
+}
diff --git a/063/src/wCount/Word.java b/063/src/wCount/Word.java
new file mode 100644
index 0000000000000000000000000000000000000000..6dc51b4efb49a6045bbbfc87c459d0c1a1075030
--- /dev/null
+++ b/063/src/wCount/Word.java
@@ -0,0 +1,96 @@
+package wCount;
+
+import java.util.*;
+import java.util.Map.Entry;
+
+public class Word
+{
+
+ String text; // 文件中内容
+ private int charNum; // 字符个数
+ private int wordNum; // 单词总数
+ private int lines; // 有效行数
+ private Map wordMap; // 单词词频
+
+ public Word(String text) {
+ this.text = text;//在构造函数里传入参数为从文件读入的字符串
+ }
+
+ public int getCharNum() // 统计文件字符数(ascll码(32~126),制表符,换行符,)
+ {
+ char c;
+ for (int i = 0; i < text.length(); i++) {
+ c = text.charAt(i);
+ if (c >= 32 && c <= 126 || c == '\r' || c == '\n'|| c == '\t') {
+ charNum++;
+ }
+ }
+ return charNum;
+ }
+
+
+ public boolean isWord(String s)//判断是否是单词
+ {
+ if(s.matches("[a-zA-Z]{4}[a-zA-Z0-9]*"))//利用正则表达式判断是否是单词(以4个英文字母开头,跟上字母数字符号,单词以分隔符分割,不区分大小写)
+ return true;
+ else
+ return false;
+ }
+
+
+ //返回一个排序好的存放单词和出现次数的List
+ public List getSortedWord() // 统计单词词频(单词:以4个英文字母开头,跟上字母数字符号,单词以分隔符分割,不区分大小写。)
+ {
+ wordMap = new HashMap();
+ String t = text;
+
+ String[] words = t.split("\\s+"); // 对字符串进行分词操作
+ for (int i = 0; i < words.length; i++) {
+ if (isWord(words[i].trim())) { // 如果是单词
+ words[i] = words[i].trim().toLowerCase();//转换为小写
+ if (wordMap.get(words[i]) == null) { // 判断之前Map中是否出现过该字符串
+ wordMap.put(words[i], 1);//没出现过把这个单词作为key放入map,value值设为1
+ } else
+ wordMap.put(words[i], wordMap.get(words[i]) + 1);//出现过value值+1
+ }
+ }
+
+ List> list = new ArrayList>(wordMap.entrySet());//把map的键值对装入一个list中
+ list.sort(new Comparator>() {//对list排序
+ @Override
+ public int compare(Entry o1, Entry o2) { //重写compare方法,对list中内容进行排序,先按词频后按字典顺序
+ if (o1.getValue() == o2.getValue()) {//如果词频相等
+ return o1.getKey().compareTo(o2.getKey());//就按字典序排列
+ }
+ return o2.getValue() - o1.getValue();//否则直接按词频排列
+ }
+
+ });
+
+ return list;//返回排列好后的list
+ }
+
+ public List getLengthSortedWord(int len)
+ {
+ List> list = getSortedWord();
+ List> res = new ArrayList<>();
+ for(int i=0;i