宝马x1新能源 评测:如何搜索文档中反复出现的词汇?

来源:百度文库 编辑:杭州交通信息网 时间:2024/05/05 04:18:37
软件也好,方法也好。前提是我不知道文档将重复出现的词汇是什么(由于文档内容很多),要通过搜索才能知道。
请回答者务必看一下问题补充,谢谢。

 
 
 
我用 Java 5 写了个程序,能搜索并打印文本文件里所有重复出现的词汇(一行一个;升序)。
只需把文本文件名作为程序的第一个参数:

/*
* Prints all repeated words (sorted, one per line) in the text file specified
* as program's first argument.
*
* Delimiter of words is one or more non-word characters, excluding "'" and "-"
* when not more than one of either is embedded in word sequence, to avoid
* splitting words like "high-brow" and "won't".
* Case of words and words without any alphabets are ignored.
*
* Requires the favorable Java 5.
*/
import java.util.*;
import java.io.*;

class PrintRepeatedWords {
    public static void main( String[ ] args ) throws Exception {
        Map<String, Integer> count = new TreeMap<String, Integer>( );
        BufferedReader br = new BufferedReader( new FileReader( args[ 0 ] ) );
        for ( String line; ( line = br.readLine( ) ) != null; ) {
            String[ ] words = line.split( "^\\W+|\\W+$|['-]{2,}|['-]*[\\W&&[^'-]]+['-]*" );
            for ( String word : words ) {
                word = word.replaceAll( "^[^\\p{Alpha}]+$", "" ).toLowerCase( );
                if ( word.length( ) != 0 )
                    count.put( word, count.containsKey( word ) ? count.get( word ) + 1 : 1 );
            }
        }
        for ( String word : count.keySet( ) )
            if ( count.get( word ) > 1 ) System.out.println( word );
    }
}
 
 
 

55555555555555
你想要什么答案?5?55?555???。。。。

什么语言,还是说用软件

一般文档编辑都有搜索功能

第一次搜索后按F3