zoukankan      html  css  js  c++  java
  • WordCount编程

    这个作业属于哪个课程 https://edu.cnblogs.com/campus/zswxy/computer-science-class1-2018
    这个作业要求在哪里 https://edu.cnblogs.com/campus/zswxy/computer-science-class1-2018/homework/11877
    这个作业的目标 完成词频统计编程
    学号 20188388

    Github地址:

    https://gitee.com/xia_unun

    PSP表格:

    PSP2.1 Personal Software Process Stages 预估耗时(分钟) 实际耗时(分钟)
    Planning 计划 30 25
    • Estimate • 估计这个任务需要多少时间 30 25
    Development 开发 200 250
    • Analysis • 需求分析 (包括学习新技术) 100 110
    • Design Spec • 生成设计文档 20 20
    • Design Review • 设计复审 20 20
    • Coding Standard • 代码规范 (为目前的开发制定合适的规范) 40 40
    • Design • 具体设计 50 50
    • Coding • 具体编码 350 350
    • Code Review • 代码复审 30 30
    • Test • 测试(自我测试,修改代码,提交修改) 30 30
    Reporting 报告 40 30
    • Test Repor • 测试报告 25 30
    • Size Measurement • 计算工作量 30 30
    • Postmortem & Process Improvement Plan • 事后总结, 并提出过程改进计划 30 30
    合计 1025 1070

    解题思路描述:

    第一个模块字符串
    第二个模块

    代码规范链接:

    https://gitee.com/xia_unun/project-java/blob/master/codestyle.md

    设计与实现过程:

    对大写字母进行转换成小写

            for(i=0;i<str1.length;i++){
            	Matcher m = r.matcher(str1[i]);
            	Matcher m1 = r1.matcher(str1[i]);
            	if(m.find()||m1.find()) {
            		StringBuffer sb = new StringBuffer();
            		for(int j=0; j < str1[i].length(); j++) {
            			
        				char c = str1[i].charAt(j);
        	
        				if(Character.isUpperCase(c)) {
        					sb.append(Character.toLowerCase(c));
        				}else {
        					sb.append(Character.toLowerCase(c));
        				}
        				
        			}
            		str1[i]=sb.toString();
            		//System.out.println(str1[i]);
            		lists.add(str1[i]);
            		
            	}
            }
    

    对行数进行判断

    public class Lines {
    
    	public static void lines(String fileName) throws IOException {
            File file = new File(fileName);
            int i=0;
            BufferedReader in = new BufferedReader(new FileReader(file));
            String value = in.readLine();
            while (value != null) {
            	if(!"".equals(value)) {
            	   i++;
            	}
                value=in.readLine();
            }
            if (in!= null)
    			in.close();
    		
            System.out.println("lines: "+i);
        }
    }
    

    对字符数进行统计

    public class Characters {
     
        public static void charCount(String path, String charset) throws IOException {
     
            int charCount = 0;
     
            BufferedReader buff = new BufferedReader(new InputStreamReader(new FileInputStream(path), charset), 1024 * 64);
            int read = -1;
            while ((read = buff.read()) != -1) { 
            	if(read>=32&&read<=126) {   
            		charCount++;
            	}
            }
            
            buff.close();
       
            System.out.println("characters: " + charCount);
        }
    }
    

    单元测试

    异常处理

    正则表达式出现了问题

    心路历程

    码云不太熟,作业不太会,写得十分坎坷,提交是最后一次性提交的,还需要多多学习

  • 相关阅读:
    【今日CV 视觉论文速览】 19 Nov 2018
    【numpy求和】numpy.sum()求和
    【今日CV 视觉论文速览】16 Nov 2018
    【今日CV 视觉论文速览】15 Nov 2018
    poj 2454 Jersey Politics 随机化
    poj 3318 Matrix Multiplication 随机化算法
    hdu 3400 Line belt 三分法
    poj 3301 Texas Trip 三分法
    poj 2976 Dropping tests 0/1分数规划
    poj 3440 Coin Toss 概率问题
  • 原文地址:https://www.cnblogs.com/xia-unun/p/14610568.html
Copyright © 2011-2022 走看看