File: diffWordsList.cs

package info (click to toggle)
cadencii 3.3.9%2Bsvn20110818.r1732-5
  • links: PTS
  • area: main
  • in suites: stretch
  • size: 35,880 kB
  • sloc: cs: 160,836; java: 42,449; cpp: 7,605; ansic: 1,728; perl: 1,087; makefile: 236; php: 142; xml: 117; sh: 21
file content (48 lines) | stat: -rw-r--r-- 1,622 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
using System;
using System.IO;
using System.Collections.Generic;

class DiffWordsList {
    public static void Main( string[] args ) {
        if ( args.Length != 3 ) {
            Console.WriteLine( "diffWordsList [base] [diff_target] [diff_result]" );
            return;
        }
        string baseFile = args[0];
        string diffTarget = args[1];
        string diffResult = args[2];

        List<string> dict = new List<string>();
        using ( StreamReader sr = new StreamReader( baseFile ) ) {
            string line = "";
            while ( (line = sr.ReadLine()) != null ) {
                dict.Add( line );
            }
        }
        dict.Sort();
        List<string> target = new List<string>();
        using ( StreamReader sr = new StreamReader( diffTarget ) ) {
            string line = "";
            while ( (line = sr.ReadLine()) != null ) {
                target.Add( line );
            }
        }
        target.Sort();

        int start_index = 0;
        using ( StreamWriter sw = new StreamWriter( diffResult ) ) {
            int count = target.Count;
            for ( int i = 0; i < count; i++ ) {
                string s = target[i];
                int indx = dict.IndexOf( s, start_index );
                if ( indx >= 0 ) {
                    start_index = indx;
                } else {
                    sw.WriteLine( s );
                }
                //Console.Write( "\r" + i + "/" + count );
                Console.Write( "\rstart:" + start_index + "; " + i + "/" + count );
            }
        }
    }
}