예제 #1
0
        private void getphrases(string text)
        {
            var hightc = 0;
            // panel1.Controls.Clear();
            var           words         = TokenizeSentence(removes(text));
            var           numberofwords = words.Count();
            SQLiteCommand sql_cmd2;
            //MessageBox.Show(numberofwords.ToString());
            var txt   = "";
            var start = 0;

            if (radioButton1.Checked)
            {
                txt = string.Join(" ", words);
            }
            else
            {
                txt = string.Join("%", words);
            }


            var list = new List <int>();
            var idpp = -1; // this is used to avoid the repetion of phrases


            if (!txt.Equals(""))
            {
                sql_cmd = new SQLiteCommand();

                if (checkBox1.Checked)
                {
                    _database.ExecuteQuery("PRAGMA case_sensitive_like=ON");
                }
                else
                {
                    _database.ExecuteQuery("PRAGMA case_sensitive_like=OFF");
                }

                sql_cmd.CommandText =
                    "select phrase.phrase,paper.id,phrase.id,cha,title  from paper, phrase  where paper.id=phrase.idp and phrase  like '%" +
                    txt + "%'  order by phrase.idp LIMIT 0," + textBox2.Text;

                var DT = _database.ExecuteSelect(sql_cmd);

                if (DT.Rows.Count > 0)
                {
                    panel1.Controls.Clear();
                    DataRow dr;

                    for (var i = 0; i < DT.Rows.Count; i++)
                    {
                        dr = DT.Rows[i];

                        if (dr[1].ToString() == "")
                        {
                            dr[1] = -1;
                        }

                        if (dr[3].ToString() == "")
                        {
                            dr[3] = -1;
                        }

                        if (dr[2].ToString() != "" && Convert.ToInt32(dr[2]) != idpp)
                        {
                            list.Clear();
                            idpp = Convert.ToInt32(dr[1]);
                        }

                        var userControl11 = new UserControl2(Convert.ToInt32(dr[1]), Convert.ToInt32(dr[2]), "Authors",
                                                             dr[0].ToString(), this, Convert.ToInt32(dr[3]));
                        // file2.WriteLine("<node LINK=\"" + dr[4] + "\" TEXT=\"" + dr[0].ToString() + "\">");

                        sql_cmd2             = new SQLiteCommand();
                        sql_cmd2.CommandText = "select phrase,id,idp from phrase  where id >=   " +
                                               (Convert.ToInt32(dr[2]) - 5) + " and id <= " +
                                               (Convert.ToInt32(dr[2]) + 5) + " and idp=" + dr[1];

                        var DT2 = _database.ExecuteSelect(sql_cmd2);
                        if (DT2.Rows.Count > 0)
                        {
                            DataRow dr2;

                            for (var l = 0; l < DT2.Rows.Count; l++)
                            {
                                dr2 = DT2.Rows[l];
                                if (!list.Contains(Convert.ToInt32(dr2[1])))
                                {
                                    list.Add(Convert.ToInt32(dr2[1]));
                                }
                            }
                        }

                        // file2.WriteLine(" <richcontent TYPE=\"NOTE\"><html><body>"+dr[4]+"</body></html></richcontent>");
                        // file2.WriteLine("</node>");


                        var p = new Point(0, hightc);

                        userControl11.Location = p;
                        var nblines = userControl11.richTextBox1.Text.Length / 117 + 1;
                        var lhight  = 80 + nblines * 13;

                        if (lhight > userControl11.Height - 10)
                        {
                            lhight = userControl11.Height - 10;
                        }

                        userControl11.Height = lhight;
                        userControl11.Width  = panel1.Width;
                        hightc = hightc + lhight;

                        panel1.Controls.Add(userControl11);
                        if (radioButton1.Checked)
                        {
                            userControl11.highlight(txt);
                        }
                        else
                        {
                            for (var j = start; j < start + numberofwords; j++)
                            {
                                userControl11.highlight(words[j]);
                            }
                        }
                    }

                    txt = string.Join(" ", words, start, numberofwords);
                    if (radioButton1.Checked)
                    {
                        highlight(txt);
                    }
                    else
                    {
                        for (var i = start; i < start + numberofwords; i++)
                        {
                            highlight(words[i]);
                        }
                    }
                }

                // sql_con.Close();
                // file2.WriteLine("</node>");
                //file2.WriteLine("</map>");
                //file2.Close();
            }
        }
예제 #2
0
        private void getphrases()
        {
            var hightc = 0;

            var words         = TokenizeSentence(removes(advancedTextEditor1.TextEditor.Text));
            var numberofwords = 0;

            var txt   = "";
            var start = 0;

            if (words.Count() - numberofwords >= 0 && numberofwords > 0)
            {
                start = words.Count() - numberofwords;


                if (radioButton1.Checked)
                {
                    txt = string.Join(" ", words, start, numberofwords);
                }
                else
                {
                    txt = string.Join("%", words, start, numberofwords);
                }
            }


            if (!txt.Equals(""))
            {
                sql_cmd             = new SQLiteCommand();
                sql_cmd.CommandText = "select phrase,idp,id from phrase where phrase like '%" + txt + "%' LIMIT 0, 20";
                var DT = _database.ExecuteSelect(sql_cmd);

                if (DT.Rows.Count > 0)
                {
                    panel1.Controls.Clear();
                    for (var i = 0; i < DT.Rows.Count; i++)
                    {
                        var dr = DT.Rows[i];


                        var userControl11 = new UserControl2(Convert.ToInt32(dr[1]), Convert.ToInt32(dr[2]), "Authors",
                                                             dr[0].ToString(), this, Convert.ToInt32(dr[3]));
                        var p = new Point(0, hightc);
                        userControl11.Location = p;
                        var nblines = userControl11.richTextBox1.Text.Length / 117 + 1;
                        if (nblines > 4)
                        {
                            nblines = 4;
                        }
                        var lhight = 150 + nblines * 15;
                        MessageBox.Show("hightc = " + hightc + ", lhight =" + lhight);
                        if (lhight > userControl11.Height)
                        {
                            lhight = userControl11.Height;
                        }

                        userControl11.Height = lhight;
                        hightc = hightc + lhight;

                        panel1.Controls.Add(userControl11);
                    }

                    txt = string.Join(" ", words, start, numberofwords);
                    if (radioButton1.Checked)
                    {
                        highlight(txt);
                    }
                    else
                    {
                        for (var i = start; i < start + numberofwords; i++)
                        {
                            highlight(words[i]);
                        }
                    }
                }
            }
        }