private void editNCBLToolStripMenuItem_Click(object sender, EventArgs e) { bool loadSuggestionEnabled = false; if (richTextBoxNepali.SelectedText.Length > 0) { loadSuggestionEnabled = LoadSuggestions(richTextBoxNepali.SelectedText, SessionsManager.NounsCommonInBothLanguageListFileName); } if (pr == null) { pr = new PostProcessor(SessionsManager.RuleFileName, SessionsManager.VerbListFileName, SessionsManager.NounListFileName, SessionsManager.AdjectiveListFileName, SessionsManager.PronounListFileName, SessionsManager.UsersCustomFileName, SessionsManager.NounsCommonInBothLanguageListFileName); } if (ncblEditor == null || ncblEditor.IsDisposed) { nounEditor = new RuleEditor(); } ncblEditor.SetFileName(SessionsManager.NounsCommonInBothLanguageListFileName); if (loadSuggestionEnabled) { ncblEditor.LoadSuggestion(richTextBoxNepali.SelectedText); } ncblEditor.Show(); }
public void TranslateTemplateThread() { _IsEditorBusy = true; articleContentCache.TranslatedArticle_Content = ""; articleContentCache.IsTranslatedArticle = false; pr = new PostProcessor(SessionsManager.RuleFileName, SessionsManager.VerbListFileName, SessionsManager.NounListFileName, SessionsManager.AdjectiveListFileName, SessionsManager.PronounListFileName, SessionsManager.UsersCustomFileName); pr.LoadTextToTranslate(articleContentCache.Article_WikiContent); pr.OnTranslationComplete += new PostProcessor.TranslationCompleteDelegate(TranslationOfThreadCompleted); templateTranslatorThread = new Thread(new ThreadStart(pr.TranslateVoid)); //inside the thread is the function that will be executed templateTranslatorThread.Name = "TemplateTranslatorThread"; //Name of the thread templateTranslatorThread.Start(); //starting translation. }
/// <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 PerformTranslationWithGuiUpdates() { _IsEditorBusy = true; if (string.IsNullOrEmpty(richTextBoxHindi.Text)) { MessageBox.Show("There is nothing in the Hindi tab to translate from Hindi to Nepali"); return; } //resetting the progressbar to zero toolStripProgressBar1.ProgressBar.Value = toolStripProgressBar1.ProgressBar.Minimum; //Loading rules before starting translating pr = new PostProcessor(SessionsManager.RuleFileName, SessionsManager.VerbListFileName, SessionsManager.NounListFileName, SessionsManager.AdjectiveListFileName, SessionsManager.PronounListFileName, SessionsManager.UsersCustomFileName, SessionsManager.NounsCommonInBothLanguageListFileName); //Getting the source text //pr.LoadTextToTranslate(richTextBoxHindi.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(); }
/// <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 PerformEnglishTranslation() { _IsEditorBusy = true; string m_translatedStringFromEnglish = ""; // Initialize the translator NepaliTranslatorHelper t = new NepaliTranslatorHelper(); // Translate the text try { // Forward translation this.Cursor = Cursors.WaitCursor; m_translatedStringFromEnglish = t.Parse(richTextBoxHindi.Text); Thread.Sleep(500); // let Google breathe } catch (Exception ex) { MessageBox.Show(ex.Message, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } finally { this.Cursor = Cursors.Default; } //resetting the progressbar to zero toolStripProgressBar1.ProgressBar.Value = toolStripProgressBar1.ProgressBar.Minimum; //Loading rules before starting translating pr = new PostProcessor(SessionsManager.RuleFileName, SessionsManager.VerbListFileName, SessionsManager.NounListFileName, SessionsManager.AdjectiveListFileName, SessionsManager.PronounListFileName, SessionsManager.UsersCustomFileName, SessionsManager.NounsCommonInBothLanguageListFileName); //Getting the source text //pr.LoadTextToTranslate(richTextBoxHindi.Text); pr.LoadTextToTranslate(m_translatedStringFromEnglish); 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(); }