Ðåôåðàòû. Àíàëèç òåêñòîâ íà çàèìñòâîâàíèå ìåòîäîì ïîñòðîåíèÿ ñåìàíòè÷åñêèõ ìîäåëåé

        /// Ԣ欨�氠讠�㟰rogress 1

        /// </summary>

        /// <param name="value"></param>

        private void ProgressInc(int value)

        {

            if (this.progress.InvokeRequired)

            {

                SetProgressIncCallBack d = new SetProgressIncCallBack(ProgressInc);

                this.Invoke(d, new object[] { value });

            }

            else

                progress.Increment(value);

        }


        /// <summary>

        /// Į󯣨𡲲񯫳 衯דּ���易�欨

        /// </summary>

        /// <param name="source"></param>

        /// <returns></returns>

        private string prepare_string(string source)

        {

            string tmp = source;


            //Ҩ�칬 믲ﱻ㡭� 㼰樿󺡢 ᬥ 桪﮶㋊            string symbols = " .,()!@#$%^&*_-\\|/";


            bool flag = true;


            while (flag)

            {

                flag = false;


                for (int i = 0; i < symbols.Length; i++)

                {

                    //û񦨠檠쩸 򩭢כּ ࡭Ḡ죍

                    while (tmp.IndexOf(symbols[i]) == 0)

                    {

                        tmp = tmp.Remove(0, 1);

                        flag = true;

                    }//while ' '


                    //û񦨠檠쩸 򩭢כּ ࡪ﮶㋊                    while (tmp.IndexOf(symbols[i]) == tmp.Length)

                    {

                        tmp = tmp.Remove(tmp.Length, 1);

                        flag = true;

                    }//while ' '


                }//for

            }//while flag


            //û񦨠檠壮ꮻ㡯񯢥칍

            while (tmp.IndexOf("  ") >= 0)

            {

                tmp = tmp.Remove(tmp.IndexOf("  "), 1);

            }//while "  "

           

            return tmp;

        }


        /// <summary>

        /// û𐯫𡲨벨�駠񡨡ﮠ󦫱󞋊        /// </summary>

        /// <param name="source"></param>

        /// <returns></returns>

        private void parse_syntax(string source)

        {

            //Ҿ垠ⴤ檠㲥 򯢨񡳼

            //�𐯲猪㲥 㭥򳣠㯧㱠󩪍

            List<string> tmp = new List<string>();


            string s = "";


            SetProgressRange(0, source.Length);


            for (int i = 0; i < source.Length; i++)

            {

                ProgressInc(1);

                statistics.syntax_bytes++;

                //Ʊ즠󦫳�魢褐- 񡨤欨󦬼

                if (separators.IndexOf(source[i]) >= 0)

                {

                    s = prepare_string(s);

                   

                    //Ʊ즠򳱮랠𐴱󡽠- 󬡭渥䬠棠񡲱�񩣠󺋊                    if (s == "") continue;


                    //Ʊ즠宨򳱮릠��, 󬡲痢 㱿⮫桢館吝졡�

                    //Þ촷鳼 롪�颮 򦭠��񭡶鼍

                    if (s.Length < 2)

                    {

                        s = "";

                        continue;

                    }


                    //ɱ묾� 򳱮뱠饠񡲬ﳰ�沫桮򯲲全 ��ꡨ塮宮䬠򬯢�                    if (s.IndexOf(' ') < 0)

                    {

                        s = "";

                        continue;

                    }


                    syntax_list.Add(s);

                    s = "";

                    statistics.syntax_count++;

                    continue;

                }


                //Ʊ즠︥񦥭易򩭢褐�򽡯渠󡦬�졭㡢묾� 椮 ࡰᨡﮍ

                if ((int)source[i] < 32) continue;


                s += source[i];

               

                //ū�, �鮲汴檱 񡢮󡩬 졢�

                Thread.Sleep(1);

            }//for

        }


        /// <summary>

        /// û𐯫𡲥�󩸥򫩩 ᮠ쩧 󦫱󞋊        /// </summary>

        public void AnalizeText()

        {

           

            WriteIntoText("Þ央󯣪�櫱󞠩;

/*

            //Ԥᬿ檠饠󦫱󞡨 衣אַ㫠 㲥 泌 桤㯩 롢�

            while (caption.IndexOf("'") >= 0)

                caption = caption.Remove(caption.IndexOf("'"), 1);


            while (caption.IndexOf("\"") >= 0)

                caption = caption.Remove(caption.IndexOf("\""), 1);


            while (source.IndexOf("'") >= 0)

                source = source.Remove(source.IndexOf("'"), 1);


            while (source.IndexOf("\"") >= 0)

                source = source.Remove(source.IndexOf("\""), 1);

*/

            WriteIntoText("û𐯫󲽠𐯤묾�㡪 „");


//            string connection_string = "Provider=SQLOLEDB.1;Source=E-ART-LAPTOP\\SQLEXPRESS;Initial Catalog=adb;Integrated Security=SSPI";

            string connection_string = "Provider=SQLOLEDB;Data Source=e-art-laptop\\sqlexpress;Integrated Security=SSPI;Initial Catalog=adb";

            OleDbConnection connection = new OleDbConnection(connection_string);


            WriteIntoText("û𐯫󲽠㮥򦮨㡲櫱󞡢 „");

            CFileWriter.WriteToFile("texts\\" + caption + ".txt", source);

            string SQLInsertText = "insert into texts(text, text_caption) values ('files/" + caption + ".txt', '" + caption + "');";


            OleDbCommand command = new OleDbCommand(SQLInsertText, connection);

           

            connection.Open();

            

            command.ExecuteNonQuery();


            //Ƞ𐴱롥ꡱ⯰ 򳡲鲲髨

            timer_statistics.Enabled = true;


            WriteIntoText("û𐯫󲽠򩮲᫱鸥򫩩 񡨡ﮠ󦫱󞠩;

       

            parse_syntax(source);


            if (File.Exists("syntax.txt")) File.Delete("syntax.txt");


            foreach (string s in syntax_list)

            {

                CFileWriter.WriteToFile("syntax.txt", s + '\n');

            }//foreach


           

        }


        private void TextOperation_Click(object sender, EventArgs e)

        {


        }


        private void FResult_FormClosing(object sender, FormClosingEventArgs e)

        {

            Application.Exit();

        }


        /// <summary>

        /// ϡ퀥𡲲᳨򳩪񋈠       /// </summary>

        /// <param name="sender"></param>

        /// <param name="e"></param>

        private void timer1_Tick(object sender, EventArgs e)

        {

            l_syntax_bytes.Text = statistics.syntax_bytes.ToString();

            l_syntax_count.Text = statistics.syntax_count.ToString();

        }

    }

}





FResult.Designer


namespace app

{

    partial class FResult

    {

        /// <summary>

        /// Required designer variable.

        /// </summary>

        private System.ComponentModel.IContainer components = null;


        /// <summary>

        /// Clean up any resources being used.

        /// </summary>

        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>

        protected override void Dispose(bool disposing)

        {

            if (disposing && (components != null))

            {

                components.Dispose();

            }

            base.Dispose(disposing);

        }


        #region Windows Form Designer generated code


        /// <summary>

        /// Required method for Designer support - do not modify

        /// the contents of this method with the code editor.

        /// </summary>

        private void InitializeComponent()

        // label3


        #endregion


        private System.Windows.Forms.TabControl tabControl1;

        private System.Windows.Forms.TabPage tabPage1;

        private System.Windows.Forms.Label TextOperation;

        private System.Windows.Forms.RichTextBox ProgressLog;

        private System.Windows.Forms.ProgressBar progress;

        private System.Windows.Forms.TabPage tabPage3;

Ñòðàíèöû: 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



2012 © Âñå ïðàâà çàùèùåíû
Ïðè èñïîëüçîâàíèè ìàòåðèàëîâ àêòèâíàÿ ññûëêà íà èñòî÷íèê îáÿçàòåëüíà.