diff --git a/201731062422/wordcount/wordcount.psess b/201731062422/wordcount/wordcount.psess new file mode 100644 index 0000000..e91c270 --- /dev/null +++ b/201731062422/wordcount/wordcount.psess @@ -0,0 +1,80 @@ + + + + wordcount.sln + Sampling + None + true + true + Timestamp + Cycles + 10000000 + 10 + 10 + + false + + + + false + 500 + + \Memory\Pages/sec + \PhysicalDisk(_Total)\Avg. Disk Queue Length + \Processor(_Total)\% Processor Time + + + + true + false + false + + false + + + false + + + + wordcount\obj\Debug\wordcount.exe + 01/01/0001 00:00:00 + true + true + false + false + false + false + false + true + false + Executable + wordcount\bin\Debug\wordcount.exe + wordcount\bin\Debug\ + + + IIS + InternetExplorer + true + false + + false + + + false + + {ECAC8591-371E-4446-9CB6-BF7BD733D65B}|wordcount\wordcount.csproj + wordcount\wordcount.csproj + wordcount + + + + + wordcount190404.vspx + + + + + :PB:{ECAC8591-371E-4446-9CB6-BF7BD733D65B}|wordcount\wordcount.csproj + + + \ No newline at end of file diff --git a/201731062422/wordcount/wordcount.sln b/201731062422/wordcount/wordcount.sln new file mode 100644 index 0000000..afd1944 --- /dev/null +++ b/201731062422/wordcount/wordcount.sln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2013 +VisualStudioVersion = 12.0.21005.1 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "wordcount", "wordcount\wordcount.csproj", "{ECAC8591-371E-4446-9CB6-BF7BD733D65B}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {ECAC8591-371E-4446-9CB6-BF7BD733D65B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {ECAC8591-371E-4446-9CB6-BF7BD733D65B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {ECAC8591-371E-4446-9CB6-BF7BD733D65B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {ECAC8591-371E-4446-9CB6-BF7BD733D65B}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/201731062422/wordcount/wordcount.v12.suo b/201731062422/wordcount/wordcount.v12.suo new file mode 100644 index 0000000..1a10de6 Binary files /dev/null and b/201731062422/wordcount/wordcount.v12.suo differ diff --git a/201731062422/wordcount/wordcount/App.config b/201731062422/wordcount/wordcount/App.config new file mode 100644 index 0000000..8e15646 --- /dev/null +++ b/201731062422/wordcount/wordcount/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/201731062422/wordcount/wordcount/Program.cs b/201731062422/wordcount/wordcount/Program.cs new file mode 100644 index 0000000..38c7481 --- /dev/null +++ b/201731062422/wordcount/wordcount/Program.cs @@ -0,0 +1,119 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.IO; +using System.Text.RegularExpressions; +using System.Collections; + +namespace Wordcount +{ + class count + { + int cnum = 0; + int lines = 0; + public int charcount(string txt) + { + char[] txt1 = txt.ToArray();/*接受字符放入数组*/ + for (int i = 0; i < txt1.Length; i++) + { + if (txt1[i] >= 0 && txt1[i] <= 127) + cnum++; + } + return cnum; + + } + public int linescount(string txt)//得到文本行数 + { + var path = txt; + char[] txt1 = txt.ToArray(); + using (var sr = new StreamReader(path)) + { + var ls = ""; + while ((ls=sr.ReadLine())!=null) + { + lines++; + } + } + return lines; + } + public void wordcount(string text)//得到单词个数及前十词频单词 + { + Dictionary dic = new Dictionary(); + StreamReader sr = new StreamReader(text); + string line = sr.ReadLine(); + line = line.ToLower(); + string[] wordArr = null; + int num = 0; + while (!sr.EndOfStream) + { + + wordArr = line.Split(' '); + foreach (string s in wordArr) + { + if (s.Length == 0) + continue; + //去除标点 + line = Regex.Replace(line, @"[\p{P}*]", "", RegexOptions.Compiled); + //将单词加入dic表中 + if (dic.ContainsKey(s)) + { + num = Convert.ToInt32(dic[s]) + 1; + dic[s] = num; + } + else + { + dic.Add(s, 1); + } + } + line = sr.ReadLine(); + } + + ArrayList wordList = new ArrayList(dic.Keys); + //对Hashtable中的Keys按字母序排列 + wordList.Sort(); + //按次数进行插入排序【稳定排序】,所以相同次数的单词依旧是字母序 + string tmp = String.Empty; + int valueTmp = 0; + for (int i = 1; i < wordList.Count; i++) + { + tmp = wordList[i].ToString(); + valueTmp = dic[wordList[i].ToString()];//次数 + int j = i; + while (j > 0 && valueTmp > (int)dic[wordList[j - 1].ToString()]) + { + wordList[j] = wordList[j - 1]; + j--; + } + wordList[j] = tmp;//j=0 + } + //打印出来 + Console.WriteLine("word:{wordList.Count}"); + foreach (object item in wordList) + { + Console.WriteLine((string)item + ":" + (int)dic[item.ToString()]); + } + } + } + class Program + { + static void Main(string[] args) + { + count cc = new count(); + string gettext = Console.ReadLine();//输入文本地址 + string text = @gettext; + if (!File.Exists(text)) + { + Console.WriteLine("文件不存在!"); + return; + } + string txt = File.ReadAllText(@text); + //将字符数与行数打印出来 + Console.WriteLine("characters:" + cc.charcount(txt)); + Console.WriteLine("lines:" + cc.linescount(text)); + cc.wordcount(text); + Console.ReadKey(); + } + } +} diff --git a/201731062422/wordcount/wordcount/Properties/AssemblyInfo.cs b/201731062422/wordcount/wordcount/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..0c49cb4 --- /dev/null +++ b/201731062422/wordcount/wordcount/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// 有关程序集的常规信息通过以下 +// 特性集控制。更改这些特性值可修改 +// 与程序集关联的信息。 +[assembly: AssemblyTitle("wordcount")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("wordcount")] +[assembly: AssemblyCopyright("Copyright © 2019")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// 将 ComVisible 设置为 false 使此程序集中的类型 +// 对 COM 组件不可见。 如果需要从 COM 访问此程序集中的类型, +// 则将该类型上的 ComVisible 特性设置为 true。 +[assembly: ComVisible(false)] + +// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID +[assembly: Guid("82bf474c-d012-490b-a1bd-237248c59fa4")] + +// 程序集的版本信息由下面四个值组成: +// +// 主版本 +// 次版本 +// 生成号 +// 修订号 +// +// 可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值, +// 方法是按如下所示使用“*”: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/201731062422/wordcount/wordcount/bin/Debug/wordcount.exe b/201731062422/wordcount/wordcount/bin/Debug/wordcount.exe new file mode 100644 index 0000000..2e408be Binary files /dev/null and b/201731062422/wordcount/wordcount/bin/Debug/wordcount.exe differ diff --git a/201731062422/wordcount/wordcount/bin/Debug/wordcount.exe.CodeAnalysisLog.xml b/201731062422/wordcount/wordcount/bin/Debug/wordcount.exe.CodeAnalysisLog.xml new file mode 100644 index 0000000..069568b --- /dev/null +++ b/201731062422/wordcount/wordcount/bin/Debug/wordcount.exe.CodeAnalysisLog.xml @@ -0,0 +1,28 @@ + + + + + 类别 + 确定性 + 全部折叠 + 检查 ID + 错误 + 错误 + 全部展开 + 帮助 + + 消息 + [位置未存储在 Pdb 中] + 项目 + 解析 + 规则 + 规则文件 + 规则说明 + + 状态 + 目标 + 警告 + 警告 + 代码分析报告 + + diff --git a/201731062422/wordcount/wordcount/bin/Debug/wordcount.exe.config b/201731062422/wordcount/wordcount/bin/Debug/wordcount.exe.config new file mode 100644 index 0000000..8e15646 --- /dev/null +++ b/201731062422/wordcount/wordcount/bin/Debug/wordcount.exe.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/201731062422/wordcount/wordcount/bin/Debug/wordcount.exe.lastcodeanalysissucceeded b/201731062422/wordcount/wordcount/bin/Debug/wordcount.exe.lastcodeanalysissucceeded new file mode 100644 index 0000000..e69de29 diff --git a/201731062422/wordcount/wordcount/bin/Debug/wordcount.pdb b/201731062422/wordcount/wordcount/bin/Debug/wordcount.pdb new file mode 100644 index 0000000..7a60f84 Binary files /dev/null and b/201731062422/wordcount/wordcount/bin/Debug/wordcount.pdb differ diff --git a/201731062422/wordcount/wordcount/bin/Debug/wordcount.vshost.exe b/201731062422/wordcount/wordcount/bin/Debug/wordcount.vshost.exe new file mode 100644 index 0000000..c0dfecc Binary files /dev/null and b/201731062422/wordcount/wordcount/bin/Debug/wordcount.vshost.exe differ diff --git a/201731062422/wordcount/wordcount/bin/Debug/wordcount.vshost.exe.config b/201731062422/wordcount/wordcount/bin/Debug/wordcount.vshost.exe.config new file mode 100644 index 0000000..8e15646 --- /dev/null +++ b/201731062422/wordcount/wordcount/bin/Debug/wordcount.vshost.exe.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/201731062422/wordcount/wordcount/bin/Debug/wordcount.vshost.exe.manifest b/201731062422/wordcount/wordcount/bin/Debug/wordcount.vshost.exe.manifest new file mode 100644 index 0000000..061c9ca --- /dev/null +++ b/201731062422/wordcount/wordcount/bin/Debug/wordcount.vshost.exe.manifest @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/201731062422/wordcount/wordcount/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache b/201731062422/wordcount/wordcount/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache new file mode 100644 index 0000000..4968f9d Binary files /dev/null and b/201731062422/wordcount/wordcount/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache differ diff --git a/201731062422/wordcount/wordcount/obj/Debug/TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs b/201731062422/wordcount/wordcount/obj/Debug/TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs new file mode 100644 index 0000000..e69de29 diff --git a/201731062422/wordcount/wordcount/obj/Debug/TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs b/201731062422/wordcount/wordcount/obj/Debug/TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs new file mode 100644 index 0000000..e69de29 diff --git a/201731062422/wordcount/wordcount/obj/Debug/TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs b/201731062422/wordcount/wordcount/obj/Debug/TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs new file mode 100644 index 0000000..e69de29 diff --git a/201731062422/wordcount/wordcount/obj/Debug/wordcount.csproj.FileListAbsolute.txt b/201731062422/wordcount/wordcount/obj/Debug/wordcount.csproj.FileListAbsolute.txt new file mode 100644 index 0000000..76f3b20 --- /dev/null +++ b/201731062422/wordcount/wordcount/obj/Debug/wordcount.csproj.FileListAbsolute.txt @@ -0,0 +1,8 @@ +c:\users\ddn\documents\visual studio 2013\Projects\wordcount\wordcount\bin\Debug\wordcount.exe.config +c:\users\ddn\documents\visual studio 2013\Projects\wordcount\wordcount\bin\Debug\wordcount.exe +c:\users\ddn\documents\visual studio 2013\Projects\wordcount\wordcount\bin\Debug\wordcount.pdb +c:\users\ddn\documents\visual studio 2013\Projects\wordcount\wordcount\obj\Debug\wordcount.csprojResolveAssemblyReference.cache +c:\users\ddn\documents\visual studio 2013\Projects\wordcount\wordcount\obj\Debug\wordcount.exe +c:\users\ddn\documents\visual studio 2013\Projects\wordcount\wordcount\obj\Debug\wordcount.pdb +C:\Users\DDN\Documents\Visual Studio 2013\Projects\wordcount\wordcount\bin\Debug\wordcount.exe.CodeAnalysisLog.xml +C:\Users\DDN\Documents\Visual Studio 2013\Projects\wordcount\wordcount\bin\Debug\wordcount.exe.lastcodeanalysissucceeded diff --git a/201731062422/wordcount/wordcount/obj/Debug/wordcount.csprojResolveAssemblyReference.cache b/201731062422/wordcount/wordcount/obj/Debug/wordcount.csprojResolveAssemblyReference.cache new file mode 100644 index 0000000..422effe Binary files /dev/null and b/201731062422/wordcount/wordcount/obj/Debug/wordcount.csprojResolveAssemblyReference.cache differ diff --git a/201731062422/wordcount/wordcount/obj/Debug/wordcount.exe b/201731062422/wordcount/wordcount/obj/Debug/wordcount.exe new file mode 100644 index 0000000..2e408be Binary files /dev/null and b/201731062422/wordcount/wordcount/obj/Debug/wordcount.exe differ diff --git a/201731062422/wordcount/wordcount/obj/Debug/wordcount.pdb b/201731062422/wordcount/wordcount/obj/Debug/wordcount.pdb new file mode 100644 index 0000000..7a60f84 Binary files /dev/null and b/201731062422/wordcount/wordcount/obj/Debug/wordcount.pdb differ diff --git a/201731062422/wordcount/wordcount/wordcount.csproj b/201731062422/wordcount/wordcount/wordcount.csproj new file mode 100644 index 0000000..2c0bc35 --- /dev/null +++ b/201731062422/wordcount/wordcount/wordcount.csproj @@ -0,0 +1,58 @@ + + + + + Debug + AnyCPU + {ECAC8591-371E-4446-9CB6-BF7BD733D65B} + Exe + Properties + wordcount + wordcount + v4.5 + 512 + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/201731062422/wordcount/wordcount1.psess b/201731062422/wordcount/wordcount1.psess new file mode 100644 index 0000000..07fdd41 --- /dev/null +++ b/201731062422/wordcount/wordcount1.psess @@ -0,0 +1,80 @@ + + + + wordcount.sln + Sampling + None + true + true + Timestamp + Cycles + 10000000 + 10 + 10 + + false + + + + false + 500 + + \Memory\Pages/sec + \PhysicalDisk(_Total)\Avg. Disk Queue Length + \Processor(_Total)\% Processor Time + + + + true + false + false + + false + + + false + + + + wordcount\obj\Debug\wordcount.exe + 01/01/0001 00:00:00 + true + true + false + false + false + false + false + true + false + Executable + wordcount\bin\Debug\wordcount.exe + wordcount\bin\Debug\ + + + IIS + InternetExplorer + true + false + + false + + + false + + {ECAC8591-371E-4446-9CB6-BF7BD733D65B}|wordcount\wordcount.csproj + wordcount\wordcount.csproj + wordcount + + + + + wordcount190404(1).vspx + + + + + :PB:{ECAC8591-371E-4446-9CB6-BF7BD733D65B}|wordcount\wordcount.csproj + + + \ No newline at end of file diff --git a/201731062422/wordcount/wordcount190404(1).vspx b/201731062422/wordcount/wordcount190404(1).vspx new file mode 100644 index 0000000..8386672 Binary files /dev/null and b/201731062422/wordcount/wordcount190404(1).vspx differ diff --git a/201731062422/wordcount/wordcount190404(2).vspx b/201731062422/wordcount/wordcount190404(2).vspx new file mode 100644 index 0000000..fdd1f4f Binary files /dev/null and b/201731062422/wordcount/wordcount190404(2).vspx differ diff --git a/201731062422/wordcount/wordcount190404.vspx b/201731062422/wordcount/wordcount190404.vspx new file mode 100644 index 0000000..d5cdb48 Binary files /dev/null and b/201731062422/wordcount/wordcount190404.vspx differ diff --git a/201731062422/wordcount/wordcount2.psess b/201731062422/wordcount/wordcount2.psess new file mode 100644 index 0000000..6ef0487 --- /dev/null +++ b/201731062422/wordcount/wordcount2.psess @@ -0,0 +1,75 @@ + + + + wordcount.sln + Sampling + None + true + true + Timestamp + Cycles + 10000000 + 10 + 10 + + false + + + + false + 500 + + \Memory\Pages/sec + \PhysicalDisk(_Total)\Avg. Disk Queue Length + \Processor(_Total)\% Processor Time + + + + true + false + false + + false + + + false + + + + wordcount\obj\Debug\wordcount.exe + 01/01/0001 00:00:00 + true + true + false + false + false + false + false + true + false + Executable + wordcount\bin\Debug\wordcount.exe + wordcount\bin\Debug\ + + + IIS + InternetExplorer + true + false + + false + + + false + + {ECAC8591-371E-4446-9CB6-BF7BD733D65B}|wordcount\wordcount.csproj + wordcount\wordcount.csproj + wordcount + + + + + :PB:{ECAC8591-371E-4446-9CB6-BF7BD733D65B}|wordcount\wordcount.csproj + + + \ No newline at end of file diff --git a/201731062422/wordcount/wordcount3.psess b/201731062422/wordcount/wordcount3.psess new file mode 100644 index 0000000..9c37147 --- /dev/null +++ b/201731062422/wordcount/wordcount3.psess @@ -0,0 +1,80 @@ + + + + wordcount.sln + Sampling + None + true + true + Timestamp + Cycles + 10000000 + 10 + 10 + + false + + + + false + 500 + + \Memory\Pages/sec + \PhysicalDisk(_Total)\Avg. Disk Queue Length + \Processor(_Total)\% Processor Time + + + + true + false + false + + false + + + false + + + + wordcount\obj\Debug\wordcount.exe + 01/01/0001 00:00:00 + true + true + false + false + false + false + false + true + false + Executable + wordcount\bin\Debug\wordcount.exe + wordcount\bin\Debug\ + + + IIS + InternetExplorer + true + false + + false + + + false + + {ECAC8591-371E-4446-9CB6-BF7BD733D65B}|wordcount\wordcount.csproj + wordcount\wordcount.csproj + wordcount + + + + + wordcount190404(2).vspx + + + + + :PB:{ECAC8591-371E-4446-9CB6-BF7BD733D65B}|wordcount\wordcount.csproj + + + \ No newline at end of file