From 78193b1ed1ac8d898925ff6c6bb5a8f4333d77a9 Mon Sep 17 00:00:00 2001 From: 975153251 <975153251@qq.com> Date: Wed, 3 Apr 2019 20:12:06 +0800 Subject: [PATCH 1/3] WordCount --- .gitattributes | 63 +++++ .gitignore | 261 ++++++++++++++++++ .../Properties/AssemblyInfo.cs | 20 ++ .../WordCount/UnitTestProject1/UnitTest1.cs | 25 ++ .../WordCount/UnitTestProject1/UnitTest2.cs | 25 ++ .../UnitTestProject1/UnitTestProject1.csproj | 75 +++++ .../UnitTestProject1/packages.config | 5 + 975153251/WordCount/WordCount.sln | 31 +++ 975153251/WordCount/WordCount/App.config | 6 + 975153251/WordCount/WordCount/Program.cs | 107 +++++++ .../WordCount/Properties/AssemblyInfo.cs | 36 +++ .../WordCount/WordCount/WordCount.csproj | 53 ++++ .../WordCountTests/Properties/AssemblyInfo.cs | 36 +++ 975153251/WordCount/WordCountTests/STests.cs | 20 ++ .../WordCountTests/WordCountTests.csproj | 106 +++++++ .../WordCount/WordCountTests/packages.config | 5 + 16 files changed, 874 insertions(+) create mode 100644 .gitattributes create mode 100644 .gitignore create mode 100644 975153251/WordCount/UnitTestProject1/Properties/AssemblyInfo.cs create mode 100644 975153251/WordCount/UnitTestProject1/UnitTest1.cs create mode 100644 975153251/WordCount/UnitTestProject1/UnitTest2.cs create mode 100644 975153251/WordCount/UnitTestProject1/UnitTestProject1.csproj create mode 100644 975153251/WordCount/UnitTestProject1/packages.config create mode 100644 975153251/WordCount/WordCount.sln create mode 100644 975153251/WordCount/WordCount/App.config create mode 100644 975153251/WordCount/WordCount/Program.cs create mode 100644 975153251/WordCount/WordCount/Properties/AssemblyInfo.cs create mode 100644 975153251/WordCount/WordCount/WordCount.csproj create mode 100644 975153251/WordCount/WordCountTests/Properties/AssemblyInfo.cs create mode 100644 975153251/WordCount/WordCountTests/STests.cs create mode 100644 975153251/WordCount/WordCountTests/WordCountTests.csproj create mode 100644 975153251/WordCount/WordCountTests/packages.config diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..1ff0c42 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,63 @@ +############################################################################### +# Set default behavior to automatically normalize line endings. +############################################################################### +* text=auto + +############################################################################### +# Set default behavior for command prompt diff. +# +# This is need for earlier builds of msysgit that does not have it on by +# default for csharp files. +# Note: This is only used by command line +############################################################################### +#*.cs diff=csharp + +############################################################################### +# Set the merge driver for project and solution files +# +# Merging from the command prompt will add diff markers to the files if there +# are conflicts (Merging from VS is not affected by the settings below, in VS +# the diff markers are never inserted). Diff markers may cause the following +# file extensions to fail to load in VS. An alternative would be to treat +# these files as binary and thus will always conflict and require user +# intervention with every merge. To do so, just uncomment the entries below +############################################################################### +#*.sln merge=binary +#*.csproj merge=binary +#*.vbproj merge=binary +#*.vcxproj merge=binary +#*.vcproj merge=binary +#*.dbproj merge=binary +#*.fsproj merge=binary +#*.lsproj merge=binary +#*.wixproj merge=binary +#*.modelproj merge=binary +#*.sqlproj merge=binary +#*.wwaproj merge=binary + +############################################################################### +# behavior for image files +# +# image files are treated as binary by default. +############################################################################### +#*.jpg binary +#*.png binary +#*.gif binary + +############################################################################### +# diff behavior for common document formats +# +# Convert binary document formats to text before diffing them. This feature +# is only available from the command line. Turn it on by uncommenting the +# entries below. +############################################################################### +#*.doc diff=astextplain +#*.DOC diff=astextplain +#*.docx diff=astextplain +#*.DOCX diff=astextplain +#*.dot diff=astextplain +#*.DOT diff=astextplain +#*.pdf diff=astextplain +#*.PDF diff=astextplain +#*.rtf diff=astextplain +#*.RTF diff=astextplain diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3c4efe2 --- /dev/null +++ b/.gitignore @@ -0,0 +1,261 @@ +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. + +# User-specific files +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ + +# Visual Studio 2015 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUNIT +*.VisualState.xml +TestResult.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# DNX +project.lock.json +project.fragment.lock.json +artifacts/ + +*_i.c +*_p.c +*_i.h +*.ilk +*.meta +*.obj +*.pch +*.pdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# JustCode is a .NET coding add-in +.JustCode + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# TODO: Comment the next line if you want to checkin your web deploy settings +# but database connection strings (with potential passwords) will be unencrypted +#*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# The packages folder can be ignored because of Package Restore +**/packages/* +# except build/, which is used as an MSBuild target. +!**/packages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/packages/repositories.config +# NuGet v3's project.json files produces more ignoreable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +node_modules/ +orleans.codegen.cs + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm + +# SQL Server files +*.mdf +*.ldf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# JetBrains Rider +.idea/ +*.sln.iml + +# CodeRush +.cr/ + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc \ No newline at end of file diff --git a/975153251/WordCount/UnitTestProject1/Properties/AssemblyInfo.cs b/975153251/WordCount/UnitTestProject1/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..eb3d0d7 --- /dev/null +++ b/975153251/WordCount/UnitTestProject1/Properties/AssemblyInfo.cs @@ -0,0 +1,20 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +[assembly: AssemblyTitle("UnitTestProject1")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("UnitTestProject1")] +[assembly: AssemblyCopyright("Copyright © 2019")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +[assembly: ComVisible(false)] + +[assembly: Guid("77bcd113-968b-41d4-b57e-a9a45bf2f01c")] + +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/975153251/WordCount/UnitTestProject1/UnitTest1.cs b/975153251/WordCount/UnitTestProject1/UnitTest1.cs new file mode 100644 index 0000000..e91f7c7 --- /dev/null +++ b/975153251/WordCount/UnitTestProject1/UnitTest1.cs @@ -0,0 +1,25 @@ +using System; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using wordCount; +using System.Collections.Generic; +using System.IO; + +namespace UnitTestProject1 +{ + [TestClass] + public class UnitTest1 + { + [TestMethod] + public void TestMethod1() + { + FileInfo file = new FileInfo(@"D:\input.txt"); + StreamReader sw = file.OpenText(); + List test = new List(); + string str = sw.ReadToEnd(); + int twords = 314; + S s = new S() ; + int words = s.Countwords(str, test); + Assert.IsTrue(words == twords); + } + } +} diff --git a/975153251/WordCount/UnitTestProject1/UnitTest2.cs b/975153251/WordCount/UnitTestProject1/UnitTest2.cs new file mode 100644 index 0000000..6d97528 --- /dev/null +++ b/975153251/WordCount/UnitTestProject1/UnitTest2.cs @@ -0,0 +1,25 @@ +using System; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using wordCount; +using System.Collections.Generic; +using System.IO; + +namespace UnitTestProject1 +{ + [TestClass] + public class UnitTest2 + { + [TestMethod] + public void TestMethod1() + { + FileInfo file = new FileInfo(@"D:\input.txt"); + StreamReader sw = file.OpenText(); + List test = new List(); + string str = sw.ReadToEnd(); + int tlines = 6; + S s = new S(); + int words = s.Countlines(str); + Assert.IsTrue(words == tlines); + } + } +} diff --git a/975153251/WordCount/UnitTestProject1/UnitTestProject1.csproj b/975153251/WordCount/UnitTestProject1/UnitTestProject1.csproj new file mode 100644 index 0000000..ee42da3 --- /dev/null +++ b/975153251/WordCount/UnitTestProject1/UnitTestProject1.csproj @@ -0,0 +1,75 @@ + + + + + + Debug + AnyCPU + {77BCD113-968B-41D4-B57E-A9A45BF2F01C} + Library + Properties + UnitTestProject1 + UnitTestProject1 + v4.6.1 + 512 + {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + 15.0 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + $(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages + False + UnitTest + + + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\packages\MSTest.TestFramework.1.3.2\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.dll + + + ..\packages\MSTest.TestFramework.1.3.2\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.dll + + + + + + + + + + + + + + + {3e086fc5-bd05-4677-af3c-1bbff24113b7} + WordCount + + + + + + + 这台计算机上缺少此项目引用的 NuGet 程序包。使用“NuGet 程序包还原”可下载这些程序包。有关更多信息,请参见 http://go.microsoft.com/fwlink/?LinkID=322105。缺少的文件是 {0}。 + + + + + + \ No newline at end of file diff --git a/975153251/WordCount/UnitTestProject1/packages.config b/975153251/WordCount/UnitTestProject1/packages.config new file mode 100644 index 0000000..102a45c --- /dev/null +++ b/975153251/WordCount/UnitTestProject1/packages.config @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/975153251/WordCount/WordCount.sln b/975153251/WordCount/WordCount.sln new file mode 100644 index 0000000..0cf832b --- /dev/null +++ b/975153251/WordCount/WordCount.sln @@ -0,0 +1,31 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.28307.489 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitTestProject1", "UnitTestProject1\UnitTestProject1.csproj", "{77BCD113-968B-41D4-B57E-A9A45BF2F01C}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WordCount", "WordCount\WordCount.csproj", "{3E086FC5-BD05-4677-AF3C-1BBFF24113B7}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {77BCD113-968B-41D4-B57E-A9A45BF2F01C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {77BCD113-968B-41D4-B57E-A9A45BF2F01C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {77BCD113-968B-41D4-B57E-A9A45BF2F01C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {77BCD113-968B-41D4-B57E-A9A45BF2F01C}.Release|Any CPU.Build.0 = Release|Any CPU + {3E086FC5-BD05-4677-AF3C-1BBFF24113B7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3E086FC5-BD05-4677-AF3C-1BBFF24113B7}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3E086FC5-BD05-4677-AF3C-1BBFF24113B7}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3E086FC5-BD05-4677-AF3C-1BBFF24113B7}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {D81B3FC3-FDA8-440C-9A2E-030846C002FC} + EndGlobalSection +EndGlobal diff --git a/975153251/WordCount/WordCount/App.config b/975153251/WordCount/WordCount/App.config new file mode 100644 index 0000000..731f6de --- /dev/null +++ b/975153251/WordCount/WordCount/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/975153251/WordCount/WordCount/Program.cs b/975153251/WordCount/WordCount/Program.cs new file mode 100644 index 0000000..bf68891 --- /dev/null +++ b/975153251/WordCount/WordCount/Program.cs @@ -0,0 +1,107 @@ +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.Diagnostics; + +namespace wordCount +{ + public class S + { + //统计文件的单词总数 + public int Countwords(string str, List test) + { + MatchCollection rel = Regex.Matches(str, "[a-zA-Z]*"); + for (int i = 0; i < rel.Count; i++) + { + test.Add(Convert.ToString(rel[i])); + } + for (int i = 0; i < test.Count; i++) + { + if (test[i] == "") + { + test.Remove(test[i]); + } + } + Console.WriteLine("\nwords:\t{0}", rel.Count); + return rel.Count; + } + //统计文件的有效行数 + public int Countlines(string str) + { + int n = 1; + MatchCollection strline = Regex.Matches(str, "\n"); + for (int i = 0; i < strline.Count; i++) + { + n++; + } + Console.WriteLine("lines:\t{0}", n); + return n; + } + //统计文件中各单词的出现次数,统计所有字符总数 + public int Counttimes(string str, List test) + { + int j = 1; + Dictionary hot = new Dictionary(); + for (int i = 0; i < test.Count; i++) + { + if (hot.ContainsKey(test[i])) + { + hot[test[i]]++; + } + else + { + hot[test[i]] = 1; + } + } + Dictionary hot_sort = hot.OrderByDescending(p => p.Value).ToDictionary(p => p.Key, o => o.Value); ; + Console.WriteLine("words:\t{0}", test.Count); + foreach (KeyValuePair kvp in hot_sort) + { + if (kvp.Key == "") + { + Console.WriteLine("空格:\t{0}", kvp.Value); + } + else + { + Console.WriteLine("单词为:{0}\t次数为:{1}", kvp.Key, kvp.Value); + } + j++; + if (j == 12)//保留前10的字符 + { + break; + } + } + return 0; + } + //按照字典序输出到文件txt + public void Output() + { + StreamWriter f = new StreamWriter(@"D:\countput.txt", false); + + } + } + public class Program + { + public static void Main(string[] args) + { + string INfile = Console.ReadLine(); + FileInfo file = new FileInfo(@INfile); + StreamReader sw = file.OpenText(); + List test = new List(); + string str = sw.ReadToEnd(); + + sw.Close(); + S s = new S(); + s.Countwords(str, test); + s.Countlines(str); + s.Counttimes(str, test); + s.Output(); + Console.ReadKey(); + + } + } +} \ No newline at end of file diff --git a/975153251/WordCount/WordCount/Properties/AssemblyInfo.cs b/975153251/WordCount/WordCount/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..0c38a49 --- /dev/null +++ b/975153251/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("3e086fc5-bd05-4677-af3c-1bbff24113b7")] + +// 程序集的版本信息由下列四个值组成: +// +// 主版本 +// 次版本 +// 生成号 +// 修订号 +// +// 可以指定所有值,也可以使用以下所示的 "*" 预置版本号和修订号 +// 方法是按如下所示使用“*”: : +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/975153251/WordCount/WordCount/WordCount.csproj b/975153251/WordCount/WordCount/WordCount.csproj new file mode 100644 index 0000000..fd80d5d --- /dev/null +++ b/975153251/WordCount/WordCount/WordCount.csproj @@ -0,0 +1,53 @@ + + + + + Debug + AnyCPU + {3E086FC5-BD05-4677-AF3C-1BBFF24113B7} + Exe + WordCount + WordCount + v4.6.1 + 512 + true + true + + + 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/975153251/WordCount/WordCountTests/Properties/AssemblyInfo.cs b/975153251/WordCount/WordCountTests/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..065b875 --- /dev/null +++ b/975153251/WordCount/WordCountTests/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// 有关程序集的一般信息由以下 +// 控制。更改这些特性值可修改 +// 与程序集关联的信息。 +[assembly: AssemblyTitle("WordCountTests")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("WordCountTests")] +[assembly: AssemblyCopyright("Copyright © 2019")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +//将 ComVisible 设置为 false 将使此程序集中的类型 +//对 COM 组件不可见。 如果需要从 COM 访问此程序集中的类型, +//请将此类型的 ComVisible 特性设置为 true。 +[assembly: ComVisible(false)] + +// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID +[assembly: Guid("e075b184-98d1-478e-8c3f-219a961de0a8")] + +// 程序集的版本信息由下列四个值组成: +// +// 主版本 +// 次版本 +// 生成号 +// 修订号 +// +//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值, +// 方法是按如下所示使用“*”: : +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/975153251/WordCount/WordCountTests/STests.cs b/975153251/WordCount/WordCountTests/STests.cs new file mode 100644 index 0000000..c4c2c52 --- /dev/null +++ b/975153251/WordCount/WordCountTests/STests.cs @@ -0,0 +1,20 @@ +using Microsoft.VisualStudio.TestTools.UnitTesting; +using wordCount.Program; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace wordCount.Program.Tests +{ + [TestClass()] + public class STests + { + [TestMethod()] + public void CountwordsTest() + { + Assert.Fail(); + } + } +} \ No newline at end of file diff --git a/975153251/WordCount/WordCountTests/WordCountTests.csproj b/975153251/WordCount/WordCountTests/WordCountTests.csproj new file mode 100644 index 0000000..fdece08 --- /dev/null +++ b/975153251/WordCount/WordCountTests/WordCountTests.csproj @@ -0,0 +1,106 @@ + + + + + Debug + AnyCPU + {E075B184-98D1-478E-8C3F-219A961DE0A8} + Library + Properties + WordCountTests + WordCountTests + v4.6.1 + 512 + {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + 10.0 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + $(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages + False + UnitTest + + + + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\packages\MSTest.TestFramework.1.3.2\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.dll + + + ..\packages\MSTest.TestFramework.1.3.2\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.dll + + + + + + + + + + + + + + + + + + + + + {3E086FC5-BD05-4677-AF3C-1BBFF24113B7} + WordCount + + + + + + + False + + + False + + + False + + + False + + + + + + + + + 这台计算机上缺少此项目引用的 NuGet 程序包。使用“NuGet 程序包还原”可下载这些程序包。有关更多信息,请参见 http://go.microsoft.com/fwlink/?LinkID=322105。缺少的文件是 {0}。 + + + + + + + \ No newline at end of file diff --git a/975153251/WordCount/WordCountTests/packages.config b/975153251/WordCount/WordCountTests/packages.config new file mode 100644 index 0000000..102a45c --- /dev/null +++ b/975153251/WordCount/WordCountTests/packages.config @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file From fbc8aa7e9825ca33515fa85f88073c2afd415f55 Mon Sep 17 00:00:00 2001 From: 975153251 <975153251@qq.com> Date: Wed, 3 Apr 2019 20:27:04 +0800 Subject: [PATCH 2/3] WordCount --- .../Properties/AssemblyInfo.cs | 20 ++++ .../WordCount/UnitTestProject1/UnitTest1.cs | 25 ++++ .../WordCount/UnitTestProject1/UnitTest2.cs | 25 ++++ .../UnitTestProject1/UnitTestProject1.csproj | 75 ++++++++++++ .../UnitTestProject1/packages.config | 5 + 201731062428/WordCount/WordCount.sln | 31 +++++ 201731062428/WordCount/WordCount/App.config | 6 + 201731062428/WordCount/WordCount/Program.cs | 107 ++++++++++++++++++ .../WordCount/Properties/AssemblyInfo.cs | 36 ++++++ .../WordCount/WordCount/WordCount.csproj | 53 +++++++++ .../WordCountTests/Properties/AssemblyInfo.cs | 36 ++++++ .../WordCount/WordCountTests/STests.cs | 20 ++++ .../WordCountTests/WordCountTests.csproj | 106 +++++++++++++++++ .../WordCount/WordCountTests/packages.config | 5 + 14 files changed, 550 insertions(+) create mode 100644 201731062428/WordCount/UnitTestProject1/Properties/AssemblyInfo.cs create mode 100644 201731062428/WordCount/UnitTestProject1/UnitTest1.cs create mode 100644 201731062428/WordCount/UnitTestProject1/UnitTest2.cs create mode 100644 201731062428/WordCount/UnitTestProject1/UnitTestProject1.csproj create mode 100644 201731062428/WordCount/UnitTestProject1/packages.config create mode 100644 201731062428/WordCount/WordCount.sln create mode 100644 201731062428/WordCount/WordCount/App.config create mode 100644 201731062428/WordCount/WordCount/Program.cs create mode 100644 201731062428/WordCount/WordCount/Properties/AssemblyInfo.cs create mode 100644 201731062428/WordCount/WordCount/WordCount.csproj create mode 100644 201731062428/WordCount/WordCountTests/Properties/AssemblyInfo.cs create mode 100644 201731062428/WordCount/WordCountTests/STests.cs create mode 100644 201731062428/WordCount/WordCountTests/WordCountTests.csproj create mode 100644 201731062428/WordCount/WordCountTests/packages.config diff --git a/201731062428/WordCount/UnitTestProject1/Properties/AssemblyInfo.cs b/201731062428/WordCount/UnitTestProject1/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..eb3d0d7 --- /dev/null +++ b/201731062428/WordCount/UnitTestProject1/Properties/AssemblyInfo.cs @@ -0,0 +1,20 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +[assembly: AssemblyTitle("UnitTestProject1")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("UnitTestProject1")] +[assembly: AssemblyCopyright("Copyright © 2019")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +[assembly: ComVisible(false)] + +[assembly: Guid("77bcd113-968b-41d4-b57e-a9a45bf2f01c")] + +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/201731062428/WordCount/UnitTestProject1/UnitTest1.cs b/201731062428/WordCount/UnitTestProject1/UnitTest1.cs new file mode 100644 index 0000000..e91f7c7 --- /dev/null +++ b/201731062428/WordCount/UnitTestProject1/UnitTest1.cs @@ -0,0 +1,25 @@ +using System; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using wordCount; +using System.Collections.Generic; +using System.IO; + +namespace UnitTestProject1 +{ + [TestClass] + public class UnitTest1 + { + [TestMethod] + public void TestMethod1() + { + FileInfo file = new FileInfo(@"D:\input.txt"); + StreamReader sw = file.OpenText(); + List test = new List(); + string str = sw.ReadToEnd(); + int twords = 314; + S s = new S() ; + int words = s.Countwords(str, test); + Assert.IsTrue(words == twords); + } + } +} diff --git a/201731062428/WordCount/UnitTestProject1/UnitTest2.cs b/201731062428/WordCount/UnitTestProject1/UnitTest2.cs new file mode 100644 index 0000000..6d97528 --- /dev/null +++ b/201731062428/WordCount/UnitTestProject1/UnitTest2.cs @@ -0,0 +1,25 @@ +using System; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using wordCount; +using System.Collections.Generic; +using System.IO; + +namespace UnitTestProject1 +{ + [TestClass] + public class UnitTest2 + { + [TestMethod] + public void TestMethod1() + { + FileInfo file = new FileInfo(@"D:\input.txt"); + StreamReader sw = file.OpenText(); + List test = new List(); + string str = sw.ReadToEnd(); + int tlines = 6; + S s = new S(); + int words = s.Countlines(str); + Assert.IsTrue(words == tlines); + } + } +} diff --git a/201731062428/WordCount/UnitTestProject1/UnitTestProject1.csproj b/201731062428/WordCount/UnitTestProject1/UnitTestProject1.csproj new file mode 100644 index 0000000..ee42da3 --- /dev/null +++ b/201731062428/WordCount/UnitTestProject1/UnitTestProject1.csproj @@ -0,0 +1,75 @@ + + + + + + Debug + AnyCPU + {77BCD113-968B-41D4-B57E-A9A45BF2F01C} + Library + Properties + UnitTestProject1 + UnitTestProject1 + v4.6.1 + 512 + {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + 15.0 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + $(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages + False + UnitTest + + + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\packages\MSTest.TestFramework.1.3.2\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.dll + + + ..\packages\MSTest.TestFramework.1.3.2\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.dll + + + + + + + + + + + + + + + {3e086fc5-bd05-4677-af3c-1bbff24113b7} + WordCount + + + + + + + 这台计算机上缺少此项目引用的 NuGet 程序包。使用“NuGet 程序包还原”可下载这些程序包。有关更多信息,请参见 http://go.microsoft.com/fwlink/?LinkID=322105。缺少的文件是 {0}。 + + + + + + \ No newline at end of file diff --git a/201731062428/WordCount/UnitTestProject1/packages.config b/201731062428/WordCount/UnitTestProject1/packages.config new file mode 100644 index 0000000..102a45c --- /dev/null +++ b/201731062428/WordCount/UnitTestProject1/packages.config @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/201731062428/WordCount/WordCount.sln b/201731062428/WordCount/WordCount.sln new file mode 100644 index 0000000..0cf832b --- /dev/null +++ b/201731062428/WordCount/WordCount.sln @@ -0,0 +1,31 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.28307.489 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitTestProject1", "UnitTestProject1\UnitTestProject1.csproj", "{77BCD113-968B-41D4-B57E-A9A45BF2F01C}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WordCount", "WordCount\WordCount.csproj", "{3E086FC5-BD05-4677-AF3C-1BBFF24113B7}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {77BCD113-968B-41D4-B57E-A9A45BF2F01C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {77BCD113-968B-41D4-B57E-A9A45BF2F01C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {77BCD113-968B-41D4-B57E-A9A45BF2F01C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {77BCD113-968B-41D4-B57E-A9A45BF2F01C}.Release|Any CPU.Build.0 = Release|Any CPU + {3E086FC5-BD05-4677-AF3C-1BBFF24113B7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3E086FC5-BD05-4677-AF3C-1BBFF24113B7}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3E086FC5-BD05-4677-AF3C-1BBFF24113B7}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3E086FC5-BD05-4677-AF3C-1BBFF24113B7}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {D81B3FC3-FDA8-440C-9A2E-030846C002FC} + EndGlobalSection +EndGlobal diff --git a/201731062428/WordCount/WordCount/App.config b/201731062428/WordCount/WordCount/App.config new file mode 100644 index 0000000..731f6de --- /dev/null +++ b/201731062428/WordCount/WordCount/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/201731062428/WordCount/WordCount/Program.cs b/201731062428/WordCount/WordCount/Program.cs new file mode 100644 index 0000000..bf68891 --- /dev/null +++ b/201731062428/WordCount/WordCount/Program.cs @@ -0,0 +1,107 @@ +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.Diagnostics; + +namespace wordCount +{ + public class S + { + //统计文件的单词总数 + public int Countwords(string str, List test) + { + MatchCollection rel = Regex.Matches(str, "[a-zA-Z]*"); + for (int i = 0; i < rel.Count; i++) + { + test.Add(Convert.ToString(rel[i])); + } + for (int i = 0; i < test.Count; i++) + { + if (test[i] == "") + { + test.Remove(test[i]); + } + } + Console.WriteLine("\nwords:\t{0}", rel.Count); + return rel.Count; + } + //统计文件的有效行数 + public int Countlines(string str) + { + int n = 1; + MatchCollection strline = Regex.Matches(str, "\n"); + for (int i = 0; i < strline.Count; i++) + { + n++; + } + Console.WriteLine("lines:\t{0}", n); + return n; + } + //统计文件中各单词的出现次数,统计所有字符总数 + public int Counttimes(string str, List test) + { + int j = 1; + Dictionary hot = new Dictionary(); + for (int i = 0; i < test.Count; i++) + { + if (hot.ContainsKey(test[i])) + { + hot[test[i]]++; + } + else + { + hot[test[i]] = 1; + } + } + Dictionary hot_sort = hot.OrderByDescending(p => p.Value).ToDictionary(p => p.Key, o => o.Value); ; + Console.WriteLine("words:\t{0}", test.Count); + foreach (KeyValuePair kvp in hot_sort) + { + if (kvp.Key == "") + { + Console.WriteLine("空格:\t{0}", kvp.Value); + } + else + { + Console.WriteLine("单词为:{0}\t次数为:{1}", kvp.Key, kvp.Value); + } + j++; + if (j == 12)//保留前10的字符 + { + break; + } + } + return 0; + } + //按照字典序输出到文件txt + public void Output() + { + StreamWriter f = new StreamWriter(@"D:\countput.txt", false); + + } + } + public class Program + { + public static void Main(string[] args) + { + string INfile = Console.ReadLine(); + FileInfo file = new FileInfo(@INfile); + StreamReader sw = file.OpenText(); + List test = new List(); + string str = sw.ReadToEnd(); + + sw.Close(); + S s = new S(); + s.Countwords(str, test); + s.Countlines(str); + s.Counttimes(str, test); + s.Output(); + Console.ReadKey(); + + } + } +} \ No newline at end of file diff --git a/201731062428/WordCount/WordCount/Properties/AssemblyInfo.cs b/201731062428/WordCount/WordCount/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..0c38a49 --- /dev/null +++ b/201731062428/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("3e086fc5-bd05-4677-af3c-1bbff24113b7")] + +// 程序集的版本信息由下列四个值组成: +// +// 主版本 +// 次版本 +// 生成号 +// 修订号 +// +// 可以指定所有值,也可以使用以下所示的 "*" 预置版本号和修订号 +// 方法是按如下所示使用“*”: : +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/201731062428/WordCount/WordCount/WordCount.csproj b/201731062428/WordCount/WordCount/WordCount.csproj new file mode 100644 index 0000000..fd80d5d --- /dev/null +++ b/201731062428/WordCount/WordCount/WordCount.csproj @@ -0,0 +1,53 @@ + + + + + Debug + AnyCPU + {3E086FC5-BD05-4677-AF3C-1BBFF24113B7} + Exe + WordCount + WordCount + v4.6.1 + 512 + true + true + + + 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/201731062428/WordCount/WordCountTests/Properties/AssemblyInfo.cs b/201731062428/WordCount/WordCountTests/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..065b875 --- /dev/null +++ b/201731062428/WordCount/WordCountTests/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// 有关程序集的一般信息由以下 +// 控制。更改这些特性值可修改 +// 与程序集关联的信息。 +[assembly: AssemblyTitle("WordCountTests")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("WordCountTests")] +[assembly: AssemblyCopyright("Copyright © 2019")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +//将 ComVisible 设置为 false 将使此程序集中的类型 +//对 COM 组件不可见。 如果需要从 COM 访问此程序集中的类型, +//请将此类型的 ComVisible 特性设置为 true。 +[assembly: ComVisible(false)] + +// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID +[assembly: Guid("e075b184-98d1-478e-8c3f-219a961de0a8")] + +// 程序集的版本信息由下列四个值组成: +// +// 主版本 +// 次版本 +// 生成号 +// 修订号 +// +//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值, +// 方法是按如下所示使用“*”: : +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/201731062428/WordCount/WordCountTests/STests.cs b/201731062428/WordCount/WordCountTests/STests.cs new file mode 100644 index 0000000..c4c2c52 --- /dev/null +++ b/201731062428/WordCount/WordCountTests/STests.cs @@ -0,0 +1,20 @@ +using Microsoft.VisualStudio.TestTools.UnitTesting; +using wordCount.Program; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace wordCount.Program.Tests +{ + [TestClass()] + public class STests + { + [TestMethod()] + public void CountwordsTest() + { + Assert.Fail(); + } + } +} \ No newline at end of file diff --git a/201731062428/WordCount/WordCountTests/WordCountTests.csproj b/201731062428/WordCount/WordCountTests/WordCountTests.csproj new file mode 100644 index 0000000..fdece08 --- /dev/null +++ b/201731062428/WordCount/WordCountTests/WordCountTests.csproj @@ -0,0 +1,106 @@ + + + + + Debug + AnyCPU + {E075B184-98D1-478E-8C3F-219A961DE0A8} + Library + Properties + WordCountTests + WordCountTests + v4.6.1 + 512 + {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + 10.0 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + $(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages + False + UnitTest + + + + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\packages\MSTest.TestFramework.1.3.2\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.dll + + + ..\packages\MSTest.TestFramework.1.3.2\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.dll + + + + + + + + + + + + + + + + + + + + + {3E086FC5-BD05-4677-AF3C-1BBFF24113B7} + WordCount + + + + + + + False + + + False + + + False + + + False + + + + + + + + + 这台计算机上缺少此项目引用的 NuGet 程序包。使用“NuGet 程序包还原”可下载这些程序包。有关更多信息,请参见 http://go.microsoft.com/fwlink/?LinkID=322105。缺少的文件是 {0}。 + + + + + + + \ No newline at end of file diff --git a/201731062428/WordCount/WordCountTests/packages.config b/201731062428/WordCount/WordCountTests/packages.config new file mode 100644 index 0000000..102a45c --- /dev/null +++ b/201731062428/WordCount/WordCountTests/packages.config @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file From 6503e79f36b306973f3d9244e6090fc35fa0ac10 Mon Sep 17 00:00:00 2001 From: 975153251 <975153251@qq.com> Date: Wed, 3 Apr 2019 22:59:31 +0800 Subject: [PATCH 3/3] WordCount --- 201731062428/WordCount/WordCount/Program.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/201731062428/WordCount/WordCount/Program.cs b/201731062428/WordCount/WordCount/Program.cs index bf68891..37e8441 100644 --- a/201731062428/WordCount/WordCount/Program.cs +++ b/201731062428/WordCount/WordCount/Program.cs @@ -88,12 +88,12 @@ public class Program { public static void Main(string[] args) { + Console.WriteLine("请输入文件路径:"); string INfile = Console.ReadLine(); FileInfo file = new FileInfo(@INfile); StreamReader sw = file.OpenText(); List test = new List(); string str = sw.ReadToEnd(); - sw.Close(); S s = new S(); s.Countwords(str, test);