zoukankan      html  css  js  c++  java
  • WoreTime 计算单词出现的次数

    string text = @"var query = from info in infoList
    where info.AuditFlag == null || info.AuditFlag == false
    join emp in empList
    on info.SaleMan equals emp.EmployeeCode
    join house in houseList
    on info.WareHouse equals house.WareHouseCode
    join client in clientList
    on info.ClientCode equals client.ClientCode
    join dictPayMode in dictList
    on info.PayMode equals dictPayMode.ValueCode
    where dictPayMode.TypeCode == 'PayMode\'
    join dictInvoiceType in dictList
    on info.InvoiceType equals dictInvoiceType.ValueCode
    where dictInvoiceType.TypeCode == 'InvoiceType'
    select new
    {
    id = info.ID,
    SaleBillCode = info.SaleBillCode,
    SaleMan = emp.Name,
    SaleDate = info.SaleDate,
    Provider = client.ShortName,
    WareHouse = house.ShortName,
    PayMode = dictPayMode.ValueName,
    InvoiceType = dictInvoiceType.ValueName,
    InvoiceCode = info.InvoiceCode,
    AuditFlag = info.AuditFlag
    };";
    //按单词转换为数组
    string[] allWords = text.Split(new char[] {'.','?','!',' ',';',':',',' },
    StringSplitOptions.RemoveEmptyEntries);
    //去掉单词数组中重复的单词
    string[] distinctWords = allWords.Distinct().ToArray<string>();

    int[] counts = new int[distinctWords.Length];
    //遍历每个单词
    for (int i = 0; i<distinctWords.Length; i++)
    {
    string tempWord = distinctWords[i];
    //计算每个单词出现的次数
    var query = from item in allWords
    where item.ToLower() == tempWord.ToLower()
    select item;
    counts[i] = query.Count();
    }
    //输出词频统计结果
    for (int i = 0; i < counts.Count(); i++)
    {
    Response.Write(distinctWords[i] + "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" + counts[i].ToString() + "<br/>");
    }

  • 相关阅读:
    Maven 环境的配置
    zTree的简单例子
    plsql免安装客户端的配置
    HDU 1232 畅通工程
    HDU 5698 瞬间移动
    Codeforces 1015E1 Stars Drawing (Easy Edition)
    Codeforces 784B Santa Claus and Keyboard Check
    Codeforces 500C New Year Book Reading
    NSarray 赋值 拷贝 等问题记录
    UINavigationController 操作记录
  • 原文地址:https://www.cnblogs.com/Yellowshorts/p/2867539.html
Copyright © 2011-2022 走看看