我没学过JAVA,现在跟这个老师在做信息检索的课题,今天给了个题目,让我做,我都愁死了,才学了2个星期的JAVA,都不知道怎么入手.题目如下:Write a program  to extract the following from a piece of text.submit a design document outlining the issues you have considered and resolved.Your code will be executed on texts that i will proveide.Dates: 2005;Oct 10,2005; 10/10/2005; 10/10/05
Acronyms: USA,CNN,BBC
Digit.digit: 8.00
Digit,digit: 8,000
Digits: 8000
Currency symbol: $, ...
Email address: [email protected]
URLs: http://www.cnn.com
IP address: 123.67.65.870
Names: Rekha;India;Hyderabad;New York; Los Angles

解决方案 »

  1.   

    什么信息检索,根本不搭界Write a program to extract the following from a piece of text
      

  2.   

    NIIT的吧。
    所谓信息检索就是利用网络将不懂的题目完成。先把所有的数组都定义好
    读行,用BufferedReader.readLine
    每行解析为一个数组填充到某个定义好的数组中去
      每行要去的数组的名称用aLine.subString(0, aLine.indexOf(":"))得到
      冒号后面的内容(也用subString得到)用split分解为字符串数组
      字符串数组中的元素逐一转换为值填到定义好的数组中
      

  3.   

    这题目的是意思,从下面的文本中提炼出有用的信息,JAVA读取文本文档的内容的命令是什么? 因为老师提供的是一个文本文档
      

  4.   

    File类,封装文件引用。
    FileReader类,读取文本文件用的。
    BufferedReader类,成行读取文件中文本用的。BufferedReader  br = new BufferedReader(new FileReader(new File("文件全名")));
    String aLine = br.readLine(); //读取文件中下一行,无下一行则返回null
      

  5.   

    这个是不是要读取文本内容?
    File累+FileReader+BufferedReader(Scanner)可以完成在文本中读取内容,但是具体要读取什么内容~看题目要求了~~代码例子的话楼上已经提供了!
      

  6.   

    我把内容翻译一下:  实际上老师的要求是从一个文本文档中提取出有用的信息,比如提取出所有的日期数据,格式可以自己定 比如 10/10/2010或者Oct,1,2010这样的格式或者是提取所有的IP地址出来,下面一个提取出来的例子:Dates: 2005;Oct 10,2005; 10/10/2005; 10/10/05
    Acronyms: USA,CNN,BBC
    Digit.digit: 8.00
    Digit,digit: 8,000
    Digits: 8000
    Currency symbol: $, ...
    Email address: [email protected]
    URLs: http://www.cnn.com
    IP address: 123.67.65.870
    Names: Rekha;India;Hyderabad;New York; Los Angles这些分类的数据就是最终提取出来的结果,它们存在于个文本文档中,通过数据筛选和提取,最后得到我们要想的数据(信息).希望有高手能写随便一个提取日期或者IP地址的 代码, 也让我这小菜鸟少走点弯路呢
      

  7.   

    经过2天的努力:有个初步的样子了,思路是跟7楼差不多,读出行,用正则判断存入指定的列中
    假设我有个文本的内容如下:
    javaaa  java1,000
    fjiaojfdoa3,1000
    dfjiaojfdoa3,1000
    dfajkldsf;kj5,000测试代码如下:import java.util.regex.Pattern;
    import java.util.regex.Matcher;
    import java.io.BufferedReader;
    import java.io.FileReader;
    import java.io.IOException;
    import java.io.FileNotFoundException;class regex {
        public static void main ( String args[]) throws IOException {
            try {
                FileReader fr = new FileReader("D:/data.txt");
                BufferedReader br = new BufferedReader(fr);
                String str;
                String Dight = "[0-9],[0-9]{3}";
                String[] str2 = new String[100];
                int i = 0;
                
                Pattern pat = Pattern.compile(Dight);
                System.out.print("Dight,digth:\t");
                while ( (str = br.readLine()) != null) {
                Matcher mat = pat.matcher(str);
                    
                    while ( mat.find()) {
                        str2[i] = mat.group();
                        i++;
                    }
                }
                for (int j = 0; j < str2.length; j++) {
                    if ( str2[j] != null) {
                    System.out.print(str2[j] + " ");
                }
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
    输入结果为:Dight,digth: 1,000 3,100 3,100 5,100
    基本实现提取的功能,其他的格式我们只需要变换正则表达就可以了,还请高手拍砖!
      

  8.   

    NIIT的吧。
    所谓信息检索就是利用网络将不懂的题目完成。先把所有的数组都定义好
      

  9.   

    楼主是不是有个单词写错了!proveide 是什么意思啊?