private static void processBiGram() {
        //移除二元模型出现频率为1的情况
        Iterator<String> iter = BIGRAM.keySet().iterator();
        while(iter.hasNext()){
            String key = iter.next();
            if(BIGRAM.get(key) < 2){
                iter.remove();
            }
        }
        try(BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream("src/main/resources/bigram.txt"),"utf-8"))){
            for(Entry<String, Integer> item : BIGRAM.entrySet()){
                writer.write(item.getKey()+" "+item.getValue()+"\n");
            }
        }catch(Exception e){
            LOGGER.info("保存bigram模型失败：", e);
        }
    }
private static void processBiGram ( ) { Iterator < String > iter = BIGRAM . keySet ( ) . iterator ( ) ; while ( iter . hasNext ( ) ) { String key = iter . next ( ) ; if ( BIGRAM . get ( key ) < 2 ) { iter . remove ( ) ; } } try ( BufferedWriter writer = new BufferedWriter ( new OutputStreamWriter ( new FileOutputStream ( "src/main/resources/bigram.txt" ) , "utf-8" ) ) ) { for ( Entry < String , Integer > item : BIGRAM . entrySet ( ) ) { writer . write ( item . getKey ( ) + " " + item . getValue ( ) + "\n" ) ; } } catch ( Exception e ) { LOGGER . info ( "保存bigram模型失败：" , e ) ; } }
分析处理并存储二元模型
移除二元模型出现频率为1的情况
排序后保存到bigram.txt文件