/// <summary>
        /// Perform translation if everything is okay
        /// Preconditions:
        /// 1. the rules must be loaded
        /// 2. Noun file, pronoun file, verbs file, adjectives file, and the rules file should be present in the application directory
        /// 3. Postcondition: the above files in (2) should be editable by the application (I mean they should not be read only)
        /// </summary>
        public void PerformTranslation()
        {
            //resetting the progressbar to zero
            toolStripProgressBar1.ProgressBar.Value = toolStripProgressBar1.ProgressBar.Minimum;

            //Loading rules before starting translating
            pr = new PostProcessor(RuleFileName, VerbListFileName, NounListFileName, AdjectiveListFileName, PronounListFileName, UsersCustomFileName);

            //Getting the source text
            pr.LoadTextToTranslate(richTextBoxHindi.Text);



            pr.OnFeedback            += new PostProcessor.ProgressFeedbackDelgate(C_OnFeedBack);              //this event is required for updating the progressbar
            pr.OnTranslationComplete += new PostProcessor.TranslationCompleteDelegate(C_TranslationComplete); //this event is required for updating the result

            //Lets define a thread before running a memory hungry process, because it takes time and usually hangs the UI, so putting in a thread
            translatorThread      = new Thread(new ThreadStart(pr.TranslateVoid)); //inside the thread is the function that will be executed
            translatorThread.Name = "TranslatorThread";                            //Name of the thread
            translatorThread.Start();                                              //starting translation.

//TODO: Natural language processing
//The following two lines are something I will work in the future, I was splitting the Document, paragraphs, sentences, and words, for a real natural language processing.
//Will work in this in future when I have more idea and more time.. :)
            //Document document = new Document(richTextBoxHindi.Text);

            //document.SplitIntoAllParagraphs(richTextBoxHindi.Text);
            //this.richTextBoxNepali.Text =  document.ReBuildParagraphs();

//End TODO: Natural language processing


            //Changing to the respective tab
            this.tabControl1.SelectedIndex = 0;
            this.tabPageNepali.Focus();
        }
Пример #2
0
        public string ProcessArticle(IAutoWikiBrowser sender, IProcessArticleEventArgs eventargs)
        {
            //MessageBox.Show("Procsssing Article");
            //If menu item is not checked, then return
            if (!PluginEnabled)
            {
                eventargs.Skip = false;
                return(eventargs.ArticleText);
            }
            string text = eventargs.ArticleText;
            string removed = "", replaced = "";


            pr = new PostProcessor(RuleFileName, VerbListFileName, NounListFileName, AdjectiveListFileName, PronounListFileName, UsersCustomFileName);
            pr.LoadTextToTranslate(text);

            // translatorThread = new Thread(new ThreadStart(pr.TranslateVoid));
            text = pr.Translate();
            //translatorThread.Name = "TranslatorThread"; //Name of the thread
            //translatorThread.Start(); //starting translation.
            //pr.OnTranslationComplete += new PostProcessor.TranslationCompleteDelegate(C_TranslationComplete);
            //MessageBox.Show("Translation Complete");
            #region abcd

            //

            //foreach (KeyValuePair<string, string> p in Settings.Categories)
            //{
            //    bool noChange;

            //    if (p.Value.Length == 0)
            //    {
            //        text = Parsers.RemoveCategory(p.Key, text, out noChange);
            //        if (!noChange)
            //        {
            //            if (!string.IsNullOrEmpty(removed))
            //            {
            //                removed += ", ";
            //            }

            //            removed += Variables.Namespaces[Namespace.Category] + p.Key;
            //        }
            //    }
            //    else
            //    {
            //        text = Parsers.ReCategoriser(p.Key, p.Value, text, out noChange);
            //        if (!noChange)
            //        {
            //            if (!string.IsNullOrEmpty(replaced))
            //            {
            //                replaced += ", ";
            //            }

            //            replaced += Variables.Namespaces[Namespace.Category]
            //             + p.Key + FindandReplace.Arrow + Variables.Namespaces[Namespace.Category] + p.Value;
            //        }
            //    }
            //    if (!noChange)
            //    {
            //        text = Regex.Replace(text, "<includeonly>[\\s\\r\\n]*\\</includeonly>", "");
            //    }
            //}

            //string editSummary = "";
            //if (Settings.AppendToEditSummary)
            //{
            //    if (!string.IsNullOrEmpty(replaced))
            //        editSummary = "replaced: " + replaced.Trim();

            //    if (!string.IsNullOrEmpty(removed))
            //    {
            //        if (!string.IsNullOrEmpty(editSummary))
            //            editSummary += ", ";

            //        editSummary += "removed: " + removed.Trim();
            //    }
            //}
            //eventargs.EditSummary = editSummary;

            //eventargs.Skip = (text == eventargs.ArticleText) && Settings.Skip;
            #endregion
            return(text);
        }