Ejemplo n.º 1
0
        //���߳� �����ݷ��͸���� Ȼ���ѯ�Ƿ�ȫ���õ�����  ���ȫ���õ� �����ۺ�  ���ִ���Ļ� ����
        /*
        Query Highlighting
        �����ȴ���һ������������highlighter������ʹ�üӺڣ�bold��������������ʾ��<B>��ѯ��</B>����
        QueryHighlightExtractor highlighter = new      QueryHighlightExtractor(query, new StandardAnalyzer(), "<B>", "</B>");
        ͨ���Խ�����������ǽ�����ԭ���������ƵIJ��֡�
        for (int i = 0; i < hits.Length(); i++) {    // ...    string plainText;    using (StreamReader sr = new StreamReader(doc.Get("filename"),                                   System.Text.Encoding.Default))    {        plainText = parseHtml(sr.ReadToEnd());    }    row["sample"] = highlighter.GetBestFragments(plainText, 80, 2, "...");    // ...}
        */
        /// <summary>
        /// ѹ�������ַ���ת��ΪRSK����
        /// </summary>
        /// <param name="dat"></param>
        /// <returns></returns>
        public RSK RTSTR2RSK(string xxx)
        {
            ///  string xxx = nCode.DeCompress(dat);

            int i0 = xxx.Length;
              //  int i1 = dat.Length;

            RSK gt = new RSK();         //(RSK) ObjDeserialize(dat,typeof(RSK) );

            string[] aa = xxx.Split('^');

            string a1 = nCode_CODE2CN(aa[0]);
            string a2 = nCode_CODE2CN(aa[1]);
            string a3 = nCode_CODE2CN(aa[2]);
            string a4 = aa[3];

            string[] a4_all = a4.Split('~');

            ArrayList Tuu = new ArrayList();
            Tuu.Clear();

            if (a4.Length == 0)
            {

            }
            else
            {

                foreach (string oip in a4_all)
                {

                    OneRs abrs = new OneRs();
                    string[] ab = oip.Split('|');
                    /*
                    string A = nCode_CODE2CN(ab[0]);
                    string B = nCode_CODE2CN(ab[1]);
                    string C = nCode_CODE2CN(ab[2]);
                    string D = nCode_CODE2CN(ab[3]);
                    string M = nCode_CODE2CN(ab[4]);
                    string S = nCode_CODE2CN(ab[5]);
                    string T = nCode_CODE2CN(ab[6]);
                    string U = nCode_CODE2CN(ab[7]);

                    abrs.A = A;
                    abrs.B = B;
                    abrs.C = C;
                    abrs.D = D;
                    abrs.M = M;
                    abrs.Score = float.Parse(S);
                    abrs.T = T;
                    abrs.url = U;
                    */
                    string S = nCode_CODE2CN(ab[5]);
                    abrs.A = ab[0];
                    abrs.B = ab[1];
                    abrs.C = ab[2];
                    abrs.D = ab[3];
                    abrs.M = ab[4];
                    abrs.Score = float.Parse(S);
                    abrs.T = ab[6];
                    abrs.url = ab[7];

                    Tuu.Add(abrs);

                }
            }

            gt.ALLNum = Int32.Parse(a1);
            gt.ANum = Int32.Parse(a2);
            gt.BNum = Int32.Parse(a3);
            gt.rs = Tuu;

            return gt;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// ��������
        /// </summary>
        /// <returns></returns>
        private string GetALL_BACKDAT()
        {
            ClassSeachALL nClass = new ClassSeachALL();

            //��������
            RSK ALL = new RSK();

            ArrayList cNew = new ArrayList();

            //���������ڵ�õ������� �ϲ���� ������������  ���������ҳ��  ����һ�����
            foreach (string aabb in nRSD)
            {
                RSK cc = nClass.RTSTR2RSK(aabb);

                //���ݺϲ���ALL

                ALL.ALLNum = ALL.ALLNum + cc.ALLNum;

                foreach (OneRs ncb in cc.rs)
                {
                    cNew.Add(ncb);
                }

            }

            ALL.ANum = 0;
            ALL.BNum = 0;
            ALL.rs = (ArrayList)cNew.Clone();
            //�õ����ݵĸ���

            //�õ�����������
            int all_a_num = ALL.ALLNum;

            //��ʼ
            int all_a_ws = A_WS;
            //����
            int ALL_a_wl = A_WL;

            //���HTML��ʽ�����ݿ�    �滻ģ���е����ݿռ�

            int CL = A_WS + A_WL;

            if (CL > ALL.rs.Count)
            {
                CL = ALL.rs.Count;
            }
            // "/s?wd=TYPE|title|body|type1|type2&ws=0&wl=10";
            string[] FEFE = A_WD.Split('|');

            QueryParser parser = new QueryParser("E", ClassST.OneAnalyzer);
            Query query = parser.Parse(FEFE[1] + " " + FEFE[2]);

            //Highlighter highlighter = new Highlighter(new QueryScorer(query));

            //  Highlighter highlighter = new Highlighter();
            Highlighter highlighter = new Highlighter(new SimpleHTMLFormatter("<font color=\"red\">", "</font>"), new QueryScorer(query));
            highlighter.TextFragmenter = new SimpleFragmenter(20);

            StringBuilder GHX = new StringBuilder();

            for (int p = A_WS; p < CL; p++)
            {
                OneRs ncb = (OneRs)ALL.rs[p];
                StringBuilder Tmp = new StringBuilder();

                string N_D = newz_code.CODE2CN(ncb.D);
                string N_Url = newz_code.CODE2CN(ncb.url);
                string N_A = newz_code.CODE2CN(ncb.A);

                TokenStream tokenStream = ClassST.OneAnalyzer.TokenStream("D", new System.IO.StringReader(N_D));

                System.String result = highlighter.GetBestFragments(tokenStream, N_D, 100, "...");

                // string   result = N_D;

                Tmp.Append("  <tr>\r\n");
                Tmp.Append("   <td height=\"66\" scope=\"col\"><table width=\"95%\" height=\"78\" border=\"0\" cellpadding=\"0\" cellspacing=\"1\">\r\n");
                Tmp.Append("    <tr>\r\n");
                Tmp.Append("        <td scope=\"col\"><div align=\"left\"><a href=\"" + N_Url + "\" target=\"_blank\"><span class=\"STYLE17\">" + N_A + "</span></a></div></td>\r\n");
                Tmp.Append("    </tr>\r\n");
                Tmp.Append("    <tr>\r\n");
                Tmp.Append("        <td><span class=\"STYLE18\">");
                Tmp.Append(result);
                Tmp.Append("</span></td>\r\n");
                Tmp.Append("    </tr>\r\n");
                Tmp.Append("    <tr>\r\n");
                Tmp.Append("        <td><a href=\"" + N_Url + "\" target=\"_blank\"><span class=\"STYLE19\">" + N_Url + "</span></a></td>\r\n");
                Tmp.Append("    </tr>\r\n");
                Tmp.Append("    </table><p>&nbsp;</p></td>\r\n");
                // Tmp.Append("  <p> </p>\r\n");
                Tmp.Append("  </tr>\r\n");

                GHX.Append(Tmp.ToString());
            }

            string NewTable = "<table width=\"95%\" height=\"152\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\r\n";
            NewTable = NewTable + GHX.ToString();
            NewTable = NewTable + "</table>\r\n";

            //������
            string WebHtml = ClassST.ModelHTM.Replace("<%HTTP://ZD4004.BLOG.163.COM%>", NewTable);

            //   // "/s?wd=TYPE|title|body|type1|type2&ws=0&wl=10";
            //string[] FEFE = A_WD.Split('|');

            //ѡ����
            WebHtml = WebHtml.Replace("<%http://blog.163.com/zd4004/%>", ClassST.GetMainTypeListHtm(FEFE[0], FEFE[2]));

            //������
            WebHtml = WebHtml.Replace("<%HTTP://BLOG.163.COM/ZD4004_1%>", ClassST.GetBoxListDat1(FEFE[0], FEFE[3], FEFE[4]));
            WebHtml = WebHtml.Replace("<%HTTP://BLOG.163.COM/ZD4004_2%>", ClassST.GetBoxListDat2(FEFE[0], FEFE[3], FEFE[4]));

            //ҳ����ʾ
            WebHtml = WebHtml.Replace("<%HTTP://BLOG.163.COM/ZD4004_URL%>", ClassST.GetPageNumHTML("/s?wd=" + A_WD + "&", all_a_num, all_a_ws, ALL_a_wl));

            //���������Ŀ

            string KPP = "�������� ";

            if (all_a_ws + ALL_a_wl < all_a_num)
            {
                int ssrr = all_a_ws + ALL_a_wl;
                int all_a_wsn = all_a_ws + 1;
                KPP = KPP + "" + all_a_num.ToString() + " ����� ���� " + all_a_wsn.ToString() + " - " + ssrr.ToString() + " ��";
            }
            else
            {
                int ssrr = all_a_num;
                int all_a_wsn = all_a_ws + 1;
                KPP = KPP + "" + all_a_num.ToString() + " ����� ���� " + all_a_wsn.ToString() + " - " + ssrr.ToString() + " ��";
            }

            WebHtml = WebHtml.Replace("<%HTTP://BLOG.163.COM/ZD4004_NUM%>", KPP);

            return WebHtml;
        }