Beispiel #1
0
        public static List <WordInfo> LookForForignWord(string Word, List <WordInfo> Result)
        {
            OleDbCommand com = new OleDbCommand("Select * From ArabizedWords where Word='" + Word + "'");

            com.Connection = Analyzer.con;
            OleDbDataReader dread = com.ExecuteReader();

            while (dread.Read())
            {
                WordInfo WI = new WordInfo();
                WI.Word       = Word;
                WI.Meaning    = dread["Meaning"].ToString();
                WI.Diacritics = dread["diacritics"].ToString();
                Result.Add(WI);
            }
            return(Result);
        }
Beispiel #2
0
        public static void CheckForPronoun(ArabicWord WordToProcess, ref List <WordInfo> Possibilities)
        {
            WordInfo     NewInfo;
            OleDbCommand com = new OleDbCommand("Select * from ProperNouns where Word='" + WordToProcess.word + "'");

            com.Connection = Analyzer.con;
            OleDbDataReader dread = com.ExecuteReader();

            while (dread.Read())
            {
                NewInfo              = new WordInfo();
                NewInfo.Meaning      = dread["meaning"].ToString();
                NewInfo.SpecialClass = "PN";
                NewInfo.Word         = WordToProcess.word;
                NewInfo.Diacritics   = dread["Diacritics"].ToString();
                Possibilities.Add(NewInfo);
            }
            dread.Close();
        }
Beispiel #3
0
        private void btnModify_Click(object sender, RoutedEventArgs e)
        {
            if (lstPossibilities.SelectedItem == null)
            {
                return;
            }
            int CorrectionIndex = lstPossibilities.SelectedIndex;

            //إسقاط المسافات السابقة واللاحقة من التحديد
            if (txtOut.SelectedText.EndsWith(" "))
            {
                txtOut.SelectionLength--;
                lstPossibilities.SelectedIndex = CorrectionIndex;
            }
            if (txtOut.SelectedText.StartsWith(" "))
            {
                txtOut.SelectionStart++;
                txtOut.SelectionLength--;
                lstPossibilities.SelectedIndex = CorrectionIndex;
            }
            if (!Analyzer.ArabicWords[SelectedWordIndex].Corrected)
            {
                Analyzer.ArabicWords[SelectedWordIndex].Corrected = true;
                Analyzer.CorrectedWords++;
            }
            WordInfo winf = Analyzer.AllWordsInfo[SelectedWordIndex][0];

            Analyzer.AllWordsInfo[SelectedWordIndex][0] = Analyzer.AllWordsInfo[SelectedWordIndex][lstPossibilities.SelectedIndex];
            Analyzer.AllWordsInfo[SelectedWordIndex][lstPossibilities.SelectedIndex] = winf;
            stsCorrections.Text = "corrected : " + Analyzer.CorrectedWords;
            double CorrectionsPercent = 0;

            if (Analyzer.ArabicWords.Count > 0)
            {
                CorrectionsPercent = Analyzer.CorrectedWords * 100.0 / (Analyzer.ArabicWords.Count - Analyzer.NumberOfSentences);
            }
            stsPercent.Text     = string.Format("correctness precentage: : {0:f2} %", CorrectionsPercent);
            txtOut.SelectedText = lstPossibilities.SelectedItem.ToString();
            //txtOut.Text = Analyzer.GenerateOutput();
            btnModify.IsEnabled = false;
        }
Beispiel #4
0
        public AnalysisDetails(WordInfo word)
        {
            InitializeComponent();
            txtWord.Text     = word.ToString();
            txtTemplate.Text = word.Template;
            txtRoot.Text     = word.Root.Root;

            txtRootCompatibility.Text = (word.Root.IsCompatible) ? "متوافق" : "غير مؤكد";
            txtDerivative.Text        = word.Root.DerivationType.ToString().Replace('_', ' ');
            txtPrefix.Text            = word.Prefix.Text;
            if (word.Prefix.Meaning.Length > 0)
            {
                txtPrefix.Text += "؛ " + Interpreter.MeaningOf(word.Prefix.Meaning);
            }
            txtSuffix.Text = word.Suffix.Text;
            if (word.Suffix.Meaning.Length > 0)
            {
                txtSuffix.Text += "؛ " + Interpreter.MeaningOf(word.Suffix.Meaning);
            }
            txtMeaning.Text = Interpreter.MeaningOf(word.Meaning) + " " + Interpreter.MeaningOf(word.SpecialClass);
            if (word.Word == "الله" && word.Meaning == "N211")
            {
                txtMeaning.Text += "(لفظ الجلالة الله)";
            }

            if (word.Interpretations != null && word.Interpretations.Count > 0)
            {
                txtInterpretation.Text = word.Interpretations[0].Description;
            }
            string M2;

            M1 = word.Meaning;
            if (M1.StartsWith("V2"))
            {
                txtInterpretation.Text = "فعل مضارع مرفوع بالضمه";
            }

            string word2 = Tashkeel.Remove(word.Word);

            if (word2 == "كان")
            {
                txtInterpretation.Text = "فعل ماض ناقص مبني على الفتح";
            }
            if (word2 == "إن")
            {
                txtInterpretation.Text = ".حرف توكيد ونصب، مبني على الفتح ، لا محل له من الإعراب ";
            }
            if (txtPrefix.Text.StartsWith("و"))
            {
                txtInterpretation.Text += "معطوف ";
            }
            if (word2.StartsWith("ت"))
            {
                txtPrefix.Text = "ت";
            }

            if ((word2 == "من") || (word2 == "على") || (word2 == "الى") || (word2 == "إلى") || (word2 == "فى") || (word2 == "حتى") || (word2 == "عدا") ||
                (word2 == "الى") || (word2 == "لعل") || (word2 == "متى") || (word2 == "كى") || (word2 == "منذ"))
            {
                txtInterpretation.Text = "حرف جر";
            }
            if ((word2 == "لم") || (word2 == "لما") || (txtPrefix.Text.StartsWith("ل")) || (word2 == "لا") || (word.Word == "إنْ"))
            {
                txtInterpretation.Text = " جازمة ، حرف، مبني على السكون، لا محل له من الإعراب";
            }

            if (txtPrefix.Text.StartsWith("ب") || txtPrefix.Text.StartsWith("ك") || txtPrefix.Text.StartsWith("ف") || (word2 == "الى"))
            {
                txtInterpretation.Text = "اسم مجرور بالكسره";
            }



            for (int i = 1; i < Analyzer.ArabicWords.Count - 1; i++)
            {
                M2 = Analyzer.AllWordsInfo[i][0].Word;
                if (M2 == word.Word && M2 != "كان")
                {
                    M1 = Analyzer.AllWordsInfo[i - 1][0].Meaning; M2 = word.Meaning;
                    if (M1.StartsWith("N") && M2.StartsWith("V"))
                    {
                        txtInterpretation.Text = "جمله فعليه فى محل رفع خبر المبتدأ";
                    }
                }

                M2 = Analyzer.AllWordsInfo[i][0].Word;
                if (M2 == word.Word)
                {
                    M1 = Analyzer.AllWordsInfo[i - 1][0].Meaning; M2 = word.Meaning;
                    if (M1.StartsWith("N1") && M2.StartsWith("N2"))
                    {
                        txtInterpretation.Text = "مضاف اليه مجرور بالكسرة";
                    }
                }

                M2 = Analyzer.AllWordsInfo[i][0].Word;
                if (M2 == word.Word)
                {
                    M1 = Analyzer.AllWordsInfo[i - 1][0].Meaning; M2 = word.Meaning;
                    if (M1.StartsWith("T1") && M2.StartsWith("N"))
                    {
                        txtInterpretation.Text = "إسم مجرور بالكسرة";
                    }
                }

                M2 = Analyzer.AllWordsInfo[i][0].Word;
                if (M2 == word.Word)
                {
                    M1 = Analyzer.AllWordsInfo[i - 1][0].Meaning;   M2 = word.Meaning;
                    if (M1 == "V113111" && M2.StartsWith("N"))
                    {
                        txtInterpretation.Text = "إسم" + " " + Tashkeel.Remove(Analyzer.AllWordsInfo[i - 1][0].Word) + " " + "مرفوع بالضمة ";
                    }
                }

                M2 = Analyzer.AllWordsInfo[i][0].Word;
                if (M2 == word.Word && i > 1)
                {
                    M1 = Analyzer.AllWordsInfo[i - 2][0].Meaning; M2 = word.Meaning;
                    if (M1 == "V113111" && M2.StartsWith("N"))
                    {
                        txtInterpretation.Text = "خبر" + " " + Tashkeel.Remove(Analyzer.AllWordsInfo[i - 2][0].Word) + " " + "منصوب بالفتحة ";
                    }
                }



                M2 = Analyzer.AllWordsInfo[i][0].Word;
                if (M2 == word.Word)
                {
                    M1 = Analyzer.AllWordsInfo[i - 1][0].Meaning; M2 = word.Meaning;

                    if (M1 == "T3" && M2.StartsWith("V2"))
                    {
                        txtInterpretation.Text = " .فعل مضارع مجزوم وعلامة جزمه السكون الظاهرة على آخره ";

                        txtWord.Text = txtWord.Text.Replace(txtWord.Text.Substring(txtWord.Text.Length - 1), "ْ");

                        if (txtWord.Text.EndsWith("نْ") && txtWord.Text.Length > 6)
                        {
                            txtWord.Text           = txtWord.Text.Substring(0, txtWord.Text.Length - 2);
                            txtInterpretation.Text = " .فعل مضارع مجزوم وعلامة جزمه حذف النون لأنه من الأفعال الخمسة والألف في محل رفع فاعل ";
                        }

                        if (txtWord.Text.EndsWith("يْ"))
                        {
                            txtWord.Text           = txtWord.Text.Substring(0, txtWord.Text.Length - 2);
                            txtInterpretation.Text = " . فعل مضارع مجزوم وعلامة جزمه حذف حرف العلة من آخره. ";
                        }
                    }
                }
            }

            if (txtInterpretation.Text.Contains("منصوب") && !txtWord.Text.EndsWith("َ") && !txtWord.Text.EndsWith("ً") && !word2.EndsWith("ا") && !word2.EndsWith("و") && !word2.EndsWith("ى") && !word2.EndsWith("ه"))
            {
                txtWord.Text = txtWord.Text.Replace(txtWord.Text.Substring(txtWord.Text.Length - 1), "َ");
            }

            if (txtInterpretation.Text.Contains("مرفوع") && !txtWord.Text.EndsWith("ُ") && !txtWord.Text.EndsWith("ٌ") && !word2.EndsWith("ا") && !word2.EndsWith("و") && !word2.EndsWith("ى") && !word2.EndsWith("ه"))
            {
                txtWord.Text = txtWord.Text.Replace(txtWord.Text.Substring(txtWord.Text.Length - 1), "ُ");
            }

            if (txtInterpretation.Text.Contains("مجرور") && !txtWord.Text.EndsWith("ِ") && !txtWord.Text.EndsWith("ٍ") && !word2.EndsWith("ا") && !word2.EndsWith("ى") && !word2.EndsWith("و") && !word2.EndsWith("ه"))
            {
                txtWord.Text = txtWord.Text.Replace(txtWord.Text.Substring(txtWord.Text.Length - 1), "ِ");
            }

            //txtInterpretation.Text = word.Meaning;
        }
Beispiel #5
0
        public AllDetails()
        {
            InitializeComponent();

            AnalysisDetails Details;



            int i = 0;

            if (i < Analyzer.ArabicWords.Count - 1)
            {
                selectedWord = Analyzer.AllWordsInfo[i][0];

                Details = new AnalysisDetails(selectedWord);

                word1.Text  = Details.txtWord.Text;
                suf1.Text   = Details.txtSuffix.Text;
                pre1.Text   = Details.txtPrefix.Text;
                root1.Text  = Details.txtRoot.Text;
                parse1.Text = Details.txtInterpretation.Text;
                pat1.Text   = Details.txtTemplate.Text;

                i++;
                string word = Tashkeel.Remove(word1.Text);
                if (word == "كان")
                {
                    parse1.Text = "فعل ماض ناقص مبني على الفتح";
                }
                if (word == "إن")
                {
                    parse1.Text = "حرف توكيد ونصب";
                }
                if (pre1.Text.StartsWith("و"))
                {
                    parse1.Text += "معطوف ";
                }
                if (word.StartsWith("ت"))
                {
                    pre1.Text = "ت";
                }
            }

            if (i < Analyzer.ArabicWords.Count - 1)
            {
                selectedWord = Analyzer.AllWordsInfo[i][0];

                Details     = new AnalysisDetails(selectedWord);
                word2.Text  = Details.txtWord.Text;
                suf2.Text   = Details.txtSuffix.Text;
                pre2.Text   = Details.txtPrefix.Text;
                root2.Text  = Details.txtRoot.Text;
                parse2.Text = Details.txtInterpretation.Text;
                pat2.Text   = Details.txtTemplate.Text;

                i++;
            }
            if (i < Analyzer.ArabicWords.Count - 1)
            {
                selectedWord = Analyzer.AllWordsInfo[i][0];

                Details = new AnalysisDetails(selectedWord);

                word3.Text  = Details.txtWord.Text;
                suf3.Text   = Details.txtSuffix.Text;
                pre3.Text   = Details.txtPrefix.Text;
                root3.Text  = Details.txtRoot.Text;
                parse3.Text = Details.txtInterpretation.Text;
                pat3.Text   = Details.txtTemplate.Text;

                i++;
            }

            if (i < Analyzer.ArabicWords.Count - 1)
            {
                selectedWord = Analyzer.AllWordsInfo[i][0];

                Details = new AnalysisDetails(selectedWord);

                word4.Text  = Details.txtWord.Text;
                suf4.Text   = Details.txtSuffix.Text;
                pre4.Text   = Details.txtPrefix.Text;
                root4.Text  = Details.txtRoot.Text;
                parse4.Text = Details.txtInterpretation.Text;
                pat4.Text   = Details.txtTemplate.Text;

                i++;
            }
            if (i < Analyzer.ArabicWords.Count - 1)
            {
                selectedWord = Analyzer.AllWordsInfo[i][0];

                Details = new AnalysisDetails(selectedWord);

                word5.Text  = Details.txtWord.Text;
                suf5.Text   = Details.txtSuffix.Text;
                pre5.Text   = Details.txtPrefix.Text;
                root5.Text  = Details.txtRoot.Text;
                parse5.Text = Details.txtInterpretation.Text;
                pat5.Text   = Details.txtTemplate.Text;
            }
            if (i < Analyzer.ArabicWords.Count - 1)
            {
                selectedWord = Analyzer.AllWordsInfo[i][0];

                Details = new AnalysisDetails(selectedWord);

                word6.Text  = Details.txtWord.Text;
                suf6.Text   = Details.txtSuffix.Text;
                pre6.Text   = Details.txtPrefix.Text;
                root6.Text  = Details.txtRoot.Text;
                parse6.Text = Details.txtInterpretation.Text;
                pat6.Text   = Details.txtTemplate.Text;
            }
            if (i < Analyzer.ArabicWords.Count - 1)
            {
                selectedWord = Analyzer.AllWordsInfo[i][0];

                Details = new AnalysisDetails(selectedWord);

                word7.Text  = Details.txtWord.Text;
                suf7.Text   = Details.txtSuffix.Text;
                pre7.Text   = Details.txtPrefix.Text;
                root7.Text  = Details.txtRoot.Text;
                parse7.Text = Details.txtInterpretation.Text;
                pat7.Text   = Details.txtTemplate.Text;
            }
            if (i < Analyzer.ArabicWords.Count - 1)
            {
                selectedWord = Analyzer.AllWordsInfo[i][0];

                Details = new AnalysisDetails(selectedWord);

                word8.Text  = Details.txtWord.Text;
                suf8.Text   = Details.txtSuffix.Text;
                pre8.Text   = Details.txtPrefix.Text;
                root8.Text  = Details.txtRoot.Text;
                parse8.Text = Details.txtInterpretation.Text;
                pat8.Text   = Details.txtTemplate.Text;
            }
            string M1 = Analyzer.AllWordsInfo[0][0].Meaning;
            string M2 = Analyzer.AllWordsInfo[1][0].Meaning;

            if (M1.StartsWith("V") && M2 == ("N222112"))
            {
                word2.BackColor = Color.Red;
            }
            if (M1.StartsWith("V2"))
            {
                parse1.Text = "فعل مضارع مرفوع بالضمه";
            }
            if (M1.StartsWith("N") && M2.StartsWith("V"))
            {
                parse2.Text = "جمله فعليه فى محل رفع خبر المبتدأ";
            }
        }
Beispiel #6
0
        public static string AnalyzeText(string TextToParse, ref BackgroundWorker BackGroundProcess)
        {
            //TextToParse = Tashkeel.Remove(TextToParse);
            Analyzer.TextToParse = TextToParse;
            Corrections          = 0;
            NotRecognized        = 0;
            ArabicWords          = ExtractArabicWords(TextToParse, out Sentences);
            //للاحتفاظ باحتمالات النطق المختلفة لكل كلمة لأغراض التعديل
            AllWordsInfo = new List <List <WordInfo> >();
            con.Open();
            LoadInterpreterData();
            for (int i = 0; i < ArabicWords.Count; i++) //التحليل الصرفي
            {
                if (ArabicWords[i].word == "EOS")       //نهاية جملة
                {
                    List <WordInfo> EOS = new List <WordInfo>();
                    EOS.Add(new WordInfo {
                        Word = "EOS"
                    });
                    AllWordsInfo.Add(EOS);
                    continue;
                }
                List <WordInfo> NewWordInfo = ProcessWord(ArabicWords[i]);                        //ابدأ معالجة الكلمة الجديدة
                AllWordsInfo.Add(NewWordInfo);                                                    //أضف ناتج المعالجة لمعلومات الكلمات
                if (NewWordInfo.Count == 0)                                                       //إذا لم يجد تفسير للكلمة
                {
                    NewWordInfo = Morphology.LookForForignWord(ArabicWords[i].word, NewWordInfo); //ابحث في الكلمات الأعجمية المخزنة
                    if (NewWordInfo.Count == 0)
                    {
                        //فشل تفسير الكلمة والتشكيل بناء على تتابع الحروف -غالبا للكلمات الأعجمية
                        //هذه الخوارزمية تحتاج تحسين
                        //للتعامل مع الكلمات الأعجمية المضاف لها ألف ولام أو ياء نسب
                        WordInfo NewWord = new WordInfo();
                        NewWord.Word       = ArabicWords[i].word;
                        NewWord.Diacritics = Tashkeel.Guess(ArabicWords[i].word);
                        NewWord.Meaning    = "N";
                        NewWordInfo.Add(NewWord);
                        NotRecognized += 1;
                    }
                }
                BackGroundProcess.ReportProgress((i + 1) * 100 / ArabicWords.Count);//تحديث شريط التقدم
            }

            for (int i = 0; i < ArabicWords.Count; i++)
            {
                int Longest = 0, Index = 0;
                List <GrammarRelation> PossibleRelations = Interpreter.StartInterpreting(i, "", 1, false);
                for (int PR = 0; PR < PossibleRelations.Count; PR++)
                {
                    if (Longest < PossibleRelations[PR].WordsCovered)
                    {
                        Longest = PossibleRelations[PR].WordsCovered;
                        Index   = PR;
                    }
                    //Interpreter.ApplyGrammarRelation(PossibleRelations[PR]);
                }
                i += Longest;
                if (PossibleRelations.Count > 0)
                {
                    GrammarRelation.ApplyGrammarRelation(PossibleRelations[Index]);
                    PossibleRelations[Index].ActivateRelation();
                }
            }
            con.Close();
            return(GenerateOutput());
        }
Beispiel #7
0
        private static List <WordInfo> ProcessWord(ArabicWord WordToProcess)
        {
            List <WordInfo> CurrentWordInfo = new List <WordInfo>();
            WordInfo        NewInfo;

            Morphology.CheckForSpecialWord(WordToProcess, ref CurrentWordInfo);
            Morphology.CheckForPronoun(WordToProcess, ref CurrentWordInfo);
            if (FastAnalysis && CurrentWordInfo.Count > 0) //للاكتفاء باحتمالات الكلمات الخاصة وعدم البحث عن تحليل صرفي لأسماء أو أفعال
            {
                return(CurrentWordInfo);
            }
            List <WordPrefix> ValidPrefixes = WordPrefix.CheckPrefix(WordToProcess.word);
            List <WordSuffix> ValidSuffixes = WordSuffix.CheckSuffixes(WordToProcess.word);

            //المعاني الافتراضية عند عدم وجود إضافات
            ValidPrefixes.Add(new WordPrefix()
            {
                WordClass = "N1"
            });                                                      //الأسماء نكرة
            ValidPrefixes.Add(new WordPrefix()
            {
                WordClass = "V1"
            });                                                      //فعل ماض
            ValidPrefixes.Add(new WordPrefix()
            {
                WordClass = "V3"
            });                                                      //فعل أمر

            ValidSuffixes.Add(new WordSuffix()
            {
                WordClass = "N0001"
            });                                                         //اسم مذكر
            ValidSuffixes.Add(new WordSuffix()
            {
                WordClass = "V10311"
            });                                                          //فعل ماض غائب مفرد مذكر
            ValidSuffixes.Add(new WordSuffix()
            {
                WordClass = "V20211"
            });                                                          //فعل مضارع مخاطب مفرد مذكر
            ValidSuffixes.Add(new WordSuffix()
            {
                WordClass = "V201"
            });                                                        //فعل مضارع متكلم
            ValidSuffixes.Add(new WordSuffix()
            {
                WordClass = "V2031"
            });                                                         //فعل مضارع غائب مفرد
            ValidSuffixes.Add(new WordSuffix()
            {
                WordClass = "V30011"
            });                                                          //فعل أمر مفرد مذكر
            List <string[]> Result = new List <string[]>();
            string          Stem;

            for (int i = 0; i < ValidPrefixes.Count; i++)
            {
                for (int j = 0; j < ValidSuffixes.Count; j++)
                {
                    Result = new List <string[]>();

                    if (WordToProcess.word.Length <= (ValidSuffixes[j].Text.Length + ValidPrefixes[i].Text.Length))
                    {   //طول الإضافات يغطي طول الكلمة بأكملها
                        continue;
                    }
                    List <string> CompatibleAdditions = Morphology.CheckAdditionsCompatibility(ValidPrefixes[i].WordClass, ValidSuffixes[j].WordClass);
                    if (CompatibleAdditions.Count == 0)
                    {   //إضافات غير متوافقة
                        continue;
                    }
                    Stem = WordToProcess.word.Substring(ValidPrefixes[i].Text.Length, WordToProcess.word.Length - (ValidPrefixes[i].Text.Length + ValidSuffixes[j].Text.Length));
                    //ابحث عن الأوزان المتوافقة مع الإضافات المحددة
                    Result = Morphology.LookForTemplate(Stem, CompatibleAdditions, Result);
                    if (Result.Count == 0)
                    {
                        continue;
                    }

                    /* اختبار وجود جذر للكلمة متوافق مع الوزن المحدد
                     * واختبار توافق الجذر الموجود مع هذا الوزن
                     * يمكن الاستغناء عن بعض هذه الخطوات عند إكمال قاعدة البيانات
                     *
                     */

                    #region اختبار توافق الوزن والجذر
                    string[]          CurrentResult;
                    ArabicRoot        CurrentRoot      = new ArabicRoot();
                    List <ArabicRoot> CheckRootResults = new List <ArabicRoot>();
                    for (int R = 0; R < Result.Count; R++)
                    {
                        CurrentResult = Result[R];
                        bool RootResult = Morphology.CheckRoot(Stem, CurrentResult[2], CurrentResult[4], CurrentResult[5], CurrentResult[6], CurrentResult[7], ref CurrentResult[3], ref CurrentRoot);
                        if (!RootResult) //اختبار وجود الجذر حسب الوزن
                        {
                            Result.RemoveAt(R);
                            R--;
                        }
                        else
                        {
                            if (CurrentRoot.IsCompatible)
                            {
                                for (int prev = 0; prev < R; prev++)
                                {
                                    //عثر على جذر متوافق احذف كل الأوزان السابقة التي ليس لها جذور متوافقة
                                    if (!CheckRootResults[prev].IsCompatible)
                                    {
                                        Result.RemoveAt(prev);
                                        CheckRootResults.RemoveAt(prev);
                                        R--;
                                        prev--;
                                    }
                                }
                                CheckRootResults.Add(CurrentRoot);
                            }
                            else
                            {
                                bool AddThisOne = true;
                                for (int prev = 0; prev < R; prev++)
                                {
                                    if (CheckRootResults[prev].IsCompatible)
                                    {
                                        AddThisOne = false; //عثر من قبل على جذور متوافقة لها أولوية
                                        Result.RemoveAt(R--);
                                        break;
                                    }
                                    //مفاضلة الأوزان من نفس قاعدة الاشتقاق
                                    byte CompareResult = Morphology.CompareRules(CurrentResult[7], Result[prev][7]);
                                    if (CompareResult == 1)
                                    {
                                        CheckRootResults.RemoveAt(prev);
                                        Result.RemoveAt(prev--);
                                        R--;
                                    }
                                    else if (CompareResult == 2)//الوزن المضاف مسبقا أولى
                                    {
                                        AddThisOne = false;
                                        Result.RemoveAt(R--);
                                        break;
                                    }
                                }
                                if (AddThisOne)
                                {
                                    CheckRootResults.Add(CurrentRoot);
                                }
                            }
                        }
                    }
                    #endregion

                    for (int R = 0; R < Result.Count; R++)
                    {
                        NewInfo            = new WordInfo();
                        NewInfo.Word       = Stem;
                        NewInfo.Diacritics = Result[R][1];
                        NewInfo.Prefix     = ValidPrefixes[i];
                        NewInfo.Suffix     = ValidSuffixes[j];
                        Tashkeel.DiacritizeWord(NewInfo);
                        if (!IgnoreExistingDiacritics && !CheckOriginalDiacritics(WordToProcess.Original, NewInfo.FullDiacritics))
                        {
                            continue;
                        }

                        NewInfo.Template = Result[R][0];
                        NewInfo.Meaning  = Result[R][3];
                        NewInfo.Root     = CheckRootResults[R];
                        CurrentWordInfo.Add(NewInfo);
                    }
                }
            }

            for (int W = 0; W < CurrentWordInfo.Count; W++)
            {
                if (CurrentWordInfo[W].Root.IsCompatible)
                {
                    WordInfo Temp;
                    for (int prev = W; prev > 0; prev--)
                    {
                        Temp = CurrentWordInfo[prev];
                        CurrentWordInfo[prev]     = CurrentWordInfo[prev - 1];
                        CurrentWordInfo[prev - 1] = Temp;
                    }
                }
            }
            CurrentWordInfo = RecallCorrections(WordToProcess, CurrentWordInfo);
            return(CurrentWordInfo);
        }
Beispiel #8
0
        private void btnDetails_Click(object sender, RoutedEventArgs e)
        {
            dataGrid1.Items.Clear();
            dataGrid1.Columns.Clear();
            AnalysisDetails Details;



            DataGridTextColumn word = new DataGridTextColumn();

            word.Header  = "Word";
            word.Binding = new Binding("word");
            word.Width   = 100;
            dataGrid1.Columns.Add(word);
            DataGridTextColumn pattern = new DataGridTextColumn();

            pattern.Header  = "Pattern";
            pattern.Width   = 100;
            pattern.Binding = new Binding("pattern");
            dataGrid1.Columns.Add(pattern);
            DataGridTextColumn suffix = new DataGridTextColumn();

            suffix.Header  = "Suffix";
            suffix.Width   = 100;
            suffix.Binding = new Binding("suffix");
            dataGrid1.Columns.Add(suffix);
            DataGridTextColumn prefix = new DataGridTextColumn();

            prefix.Header  = "Prefix";
            prefix.Width   = 100;
            prefix.Binding = new Binding("prefix");
            dataGrid1.Columns.Add(prefix);
            DataGridTextColumn root = new DataGridTextColumn();

            root.Header  = "Root";
            root.Width   = 100;
            root.Binding = new Binding("root");
            dataGrid1.Columns.Add(root);
            DataGridTextColumn interpertation = new DataGridTextColumn();

            interpertation.Header  = "Interpertation";
            interpertation.Width   = 300;
            interpertation.Binding = new Binding("parsing");
            dataGrid1.Columns.Add(interpertation);
            DataGridTextColumn analysis = new DataGridTextColumn();

            analysis.Header  = "Analysis";
            analysis.Width   = 300;
            analysis.Binding = new Binding("analysis");
            dataGrid1.Columns.Add(analysis);

            string word1, suf1, prf1, root1, parse1, pattern1, analysis1;


            for (int i = 0; i < Analyzer.ArabicWords.Count - 1; i++)
            {
                selectedWord = Analyzer.AllWordsInfo[i][0];

                Details = new AnalysisDetails(selectedWord);

                word1     = Details.txtWord.Text;
                suf1      = Details.txtSuffix.Text;
                prf1      = Details.txtPrefix.Text;
                root1     = Details.txtRoot.Text;
                analysis1 = Details.txtMeaning.Text;
                parse1    = Details.txtInterpretation.Text;

                pattern1 = Details.txtTemplate.Text;

                string M1 = Analyzer.AllWordsInfo[0][0].Meaning;
                string M2 = Analyzer.AllWordsInfo[1][0].Meaning;


                dataGrid1.Items.Add(new AnalysisItem(word1, suf1, prf1, root1, pattern1, parse1, analysis1));
            }
        }