コード例 #1
0
        public override ResultInterpreterOpt check(ResultInterpreterOpt interpreter, String dbText, String userText)
        {
            int sliceIndex = 0;
            int resultIndexId = 0;
            foreach (String slice in Splitter.SplitBySentence(userText))
            {
                //Console.Out.WriteLine(slice);
                if (slice == ""){
                    continue;
                }
                String r = findPattern(dbText, slice+". ");
                var indexes = r.Split(';').Where(x => x != "").Select(x => Convert.ToInt32(x)).ToList();
                foreach (int i in indexes)
                {
                    interpreter.addIndex(resultIndexId, sliceIndex, sliceIndex + slice.Length, i, i + slice.Length);
                    resultIndexId++;
                   // Console.Out.WriteLine();

                }
                sliceIndex = sliceIndex + slice.Length + 2;
            }
            //Console.ReadKey();
            interpreter.getNormalizedIndexes();
            return interpreter;
        }
コード例 #2
0
        public override ResultInterpreterOpt check(ResultInterpreterOpt interpreter, String dbText, String userText)
        {
            int sliceIndex = 0;
            int resultIndexId = 0;
            foreach (String slice in Splitter.SplitByNGram(userText, 1))
            {
                if (slice == "")
                {
                    sliceIndex++;
                    continue;
                }
                //Console.Out.WriteLine(slice);
                String r = findPattern(dbText, " "+slice+" ");
                var indexes = r.Split(';').Where(x => x != "").Select(x => Convert.ToInt32(x)).ToList();
                //Console.Out.WriteLine(indexes.Count)
                foreach (int i in indexes)
                {
                    interpreter.addIndex(resultIndexId, sliceIndex+1, sliceIndex + slice.Length+1, i+1, i+slice.Length+1);
                    resultIndexId++;
                    // Console.Out.WriteLine();
                    //Console.Out.WriteLine(slice);
                }
                sliceIndex = sliceIndex + slice.Length+1;
            }

            interpreter.getNormalizedIndexes();
            return interpreter;
        }
コード例 #3
0
        public override ResultInterpreterOpt check(ResultInterpreterOpt interpreter, String dbText, String userText)
        {
            int sliceIndex = 0;
            int resultIndexId = 0;
            foreach (String slice in Splitter.SplitByLength(userText, this.width))
            {
                String r = findPattern(dbText, slice);
                var indexes = r.Split(';').Where(x => x != "").Select(x => Convert.ToInt32(x)).ToList();
                foreach (int i in indexes)
                {
                    //Console.Out.WriteLine(dbText.Substring(i, slice.Length));
                    interpreter.addIndex(resultIndexId, sliceIndex * slice.Length, (sliceIndex + 1) * slice.Length, i, i + slice.Length);
                    resultIndexId++;
                }
                sliceIndex++;
            }

            interpreter.getNormalizedIndexes();
            return interpreter;
        }
コード例 #4
0
        public override ResultInterpreterOpt check(ResultInterpreterOpt interpreter, String dbText, String userText)
        {
            int n = 3;
            int sliceIndex = 0;
            int resultIndexId = 0;
            Console.Out.WriteLine("before search");
            foreach (String slice in Splitter.SplitByNGram(userText, n))
            {
                if (slice == "")
                {
                    sliceIndex++;
                    continue;
                }
                //Console.Out.WriteLine(slice);
               // Console.Out.WriteLine(dbText.Substring(sliceIndex, 30));
               // Console.Out.WriteLine("|");

                String r = findPattern(dbText, slice);
                //Console.Out.WriteLine(r);
                //Console.ReadLine();
                var indexes = r.Split(';').Where(x => x != "").Select(x => Convert.ToInt32(x)).ToList();
                //Console.Out.WriteLine(indexes.Count)
                int skipValue = slice.Split(' ')[0].Length;

                foreach (int i in indexes)
                {
                    //Console.Out.WriteLine(slice);
                    interpreter.addIndex(resultIndexId, sliceIndex , sliceIndex + slice.Length , i , i + slice.Length );
                    resultIndexId++;
                    // Console.Out.WriteLine();
                    //Console.Out.WriteLine(slice);
                }
                sliceIndex = sliceIndex + skipValue + 1;
            }
            Console.Out.WriteLine("found");
            interpreter.getNormalizedIndexes();
            Console.Out.WriteLine("normalized");
            return interpreter;
        }