예제 #1
0
        static void Main(string[] args)
        {
            if (args.Length != 4)
            {
                printUsage();
                return;
            }
            // string dir= @"C:\Users\khalefa\Downloads\itunit-master\itunit-master\";
            //  Console.WriteLine(args[1]);//return;

            string n    = args[0];
            string m    = args[2];
            int    col1 = int.Parse(args[1]);
            int    col2 = int.Parse(args[3]);
            //get the dir
            string dir = "";

            if (n.Contains("\\"))
            {
                dir = n.Substring(0, n.LastIndexOf("\\"));
                dir = dir + "\\";
            }
            else
            if (n.Contains("/"))
            {
                dir = n.Substring(0, n.LastIndexOf("/"));
                dir = dir + "/";
            }
            else

            {
                dir = System.AppDomain.CurrentDomain.BaseDirectory;
                n   = dir + n;
                m   = dir + m;
            }
            Console.Write(dir);
            // return;
            var       x = Matching.Matches(n, m, col1, col2);
            ExcelUtil e = new ExcelUtil();

            //System.IO.Path p=new System.IO.Path()
            e.writeexcel(System.AppDomain.CurrentDomain.BaseDirectory + "output.xls", x);
        }
예제 #2
0
        static public List <Match> Matches(string stud, string mis, int id = 3, int id2 = 2)
        {
            /*            List<Match> exact = new List<Match>();
             *          List<Match> semiexact = new List<Match>();
             *          List<Match> noexact = new List<Match>();*/
            HashSet <int> matched = new HashSet <int>();
            List <Match>  n       = new List <Match>();

            ExcelUtil e = new ExcelUtil();
            ExcelUtil f = new ExcelUtil();

            e.openexcel(stud);
            f.openexcel(mis);

            var n1 = e.valueArray.Slice(id);
            var n2 = f.valueArray.Slice(id2);

            for (int i = 0; i < n1.Length; i++)
            {
                string s1 = ((string)n1[i]).Trim();
                s1 = s1.Space();
                float  m      = int.MaxValue;
                int    j_indx = 0;
                string s      = "";
                for (int j = 0; j < n2.Length; j++)
                {
                    if (matched.Contains(j))
                    {
                        continue;
                    }
                    string s2 = ((string)n2[j]).Trim();
                    s2 = s2.Space();
                    float edn = EditDistance.FuzzyCompute(s1.Arabic(), s2.Arabic(), 10);
                    if (edn < m)
                    {
                        m      = edn;
                        s      = s2;
                        j_indx = j;
                    }
                }


                matchtype mt = matchtype.SemiMatch;
                if (m == 0)
                {
                    if (EditDistance.Compute(s1, s) == 0)
                    {
                        mt = matchtype.Exact;
                    }
                    else
                    {
                        mt = matchtype.Exact;
                    }
                }
                else
                {
                    if (m > 0.5)
                    {
                        mt = matchtype.NoMatch;
                    }
                    else
                    {
                        mt = matchtype.SemiMatch;
                    }
                }
                if (m < 0.5)
                {
                    matched.Add(j_indx);
                }
                n.Add(new Match {
                    A = s1, B = s, match = m, type = mt
                });
                //Console.WriteLine(s1, s, m);
            }

            return(n);
        }