コード例 #1
0
ファイル: Verse.cs プロジェクト: ATouhou/QuranCode
        public Verse(int number, string text, Stopmark stopmark)
        {
            text = text.Replace("\r", "");
            text = text.Replace("\n", "");
            while (text.Contains("  "))
            {
                text = text.Replace("  ", " ");
            }

            this.number = number;
            this.text = text;
            this.stopmark = stopmark;
        }
コード例 #2
0
        //MustPause Occurrences:
        //Stop      ١٨_١	بِسْمِ ٱللَّهِ ٱلرَّحْمَٰنِ ٱلرَّحِيمِ ٱلْحَمْدُ لِلَّهِ ٱلَّذِىٓ أَنزَلَ عَلَىٰ عَبْدِهِ ٱلْكِتَٰبَ وَلَمْ يَجْعَل لَّهُۥ عِوَجَا ۜ
        //StopSTOP  ٣٦_٥٢	قَالُوا۟ يَٰوَيْلَنَا مَنۢ بَعَثَنَا مِن مَّرْقَدِنَا ۜ ۗ هَٰذَا مَا وَعَدَ ٱلرَّحْمَٰنُ وَصَدَقَ ٱلْمُرْسَلُونَ
        //Stop      ٦٩_٢٨	مَآ أَغْنَىٰ عَنِّى مَالِيَهْ ۜ
        //Continue  ٧٥_٢٧	وَقِيلَ مَنْ ۜ رَاقٍۢ
        //Continue  ٨٣_١٤	كَلَّا ۖ بَلْ ۜ رَانَ عَلَىٰ قُلُوبِهِم مَّا كَانُوا۟ يَكْسِبُونَ
        public static Stopmark GetStopmark(string stopmark_text)
        {
            Stopmark stopmark = Stopmark.None;

            if (!String.IsNullOrEmpty(stopmark_text))
            {
                switch (stopmark_text)
                {
                case "":
                    stopmark = Stopmark.None;
                    break;

                case "ۙ":     // Laaa
                    stopmark = Stopmark.MustContinue;
                    break;

                case "ۖ":     // Sala
                    stopmark = Stopmark.ShouldContinue;
                    break;

                case "ۚ":     // Jeem
                    stopmark = Stopmark.CanStop;
                    break;

                case "ۛ":     // Dots
                    stopmark = Stopmark.CanStopAtEither;
                    break;

                case "ۗ":     // Qala
                    stopmark = Stopmark.ShouldStop;
                    break;

                case "ۜ":     // Seen
                    stopmark = Stopmark.MustPause;
                    break;

                case "ۘ":     // Meem
                    stopmark = Stopmark.MustStop;
                    break;

                default:     // Quran word
                    stopmark = Stopmark.None;
                    break;
                }
            }
            return(stopmark);
        }
コード例 #3
0
        public Verse(int number, string text, Stopmark stopmark)
        {
            this.number   = number;
            this.text     = text;
            this.stopmark = stopmark;

            // create words WITHOUT stopmarks
            this.words = new List <Word>();
            int word_number   = 0;
            int word_position = 0;

            string[] word_texts = text.Split();
            for (int i = 0; i < word_texts.Length; i++)
            {
                string word_text = word_texts[i];
                if (word_text.Length > 0)
                {
                    // build new Words
                    if (
                        (word_text.Length == 1)
                        &&
                        !((word_text == "ص") || (word_text == "ق") || (word_text == "ٯ") || (word_text == "ن") || (word_text == "ں") || (word_text == "و"))
                        )
                    {
                        if ((Constants.STOPMARKS.Contains(word_text[0])) || (Constants.QURANMARKS.Contains(word_text[0])))
                        {
                            // increment word position by stopmarks length in original text
                            word_position += 2; // 2 for stopmark and space after it
                        }
                        continue;               // skip stopmarks/quranmarks
                    }
                    else // proper word
                    {
                        word_number++;
                        Word word = new Word(this, word_number, word_position, word_text);
                        if (word != null)
                        {
                            this.words.Add(word);
                        }
                    }

                    // in all cases
                    word_position += word_text.Length + 1; // 1 for space
                }
            }
        }
コード例 #4
0
        public static string GetStopmarkText(Stopmark stopmark)
        {
            string stopmark_text = "";

            switch (stopmark)
            {
            case Stopmark.None:     // none
                stopmark_text = "";
                break;

            case Stopmark.MustContinue:
                stopmark_text = "ۙ";     // Laaa
                break;

            case Stopmark.ShouldContinue:
                stopmark_text = "ۖ";     // Sala
                break;

            case Stopmark.CanStop:
                stopmark_text = "ۚ";     // Jeem
                break;

            case Stopmark.CanStopAtEither:
                stopmark_text = "ۛ";     // Dots
                break;

            case Stopmark.ShouldStop:
                stopmark_text = "ۗ";     // Qala
                break;

            case Stopmark.MustPause:
                stopmark_text = "ۜ";     // Seen
                break;

            case Stopmark.MustStop:
                stopmark_text = "ۘ";     // Meem
                break;

            default:
                stopmark_text = "ۘ";     // Meem;
                break;
            }
            return(stopmark_text);
        }
コード例 #5
0
ファイル: Word.cs プロジェクト: ATouhou/QuranCode
        public Word(Verse verse, int number_in_verse, int position_in_verse, string text, Stopmark stopmark)
        {
            this.verse = verse;
            this.number_in_verse = number_in_verse;
            this.position = position_in_verse;
            this.text = text;
            this.stopmark = stopmark;

            if ((Globals.EDITION == Edition.Grammar) || (Globals.EDITION == Edition.Research))
            {
                this.parts = new List<WordPart>();
            }

            this.letters = new List<Letter>();
            if (this.Letters != null)
            {
                int letter_number_in_word = 0;

                // for correct UniqueLetters calculation in Original text
                string simplified_text = this.text;
                if (this.text.IsArabicWithDiacritics())
                {
                    simplified_text = this.text.Simplify29();
                }

                foreach (char character in simplified_text)
                {
                    if (Constants.ARABIC_LETTERS.Contains(character))
                    {
                        letter_number_in_word++;

                        Letter letter = new Letter(this, character, letter_number_in_word);
                        this.Letters.Add(letter);
                    }
                }
            }
        }
コード例 #6
0
        public void RecreateWordsApplyStopmarks(string waw_text)
        {
            this.text = waw_text;

            this.words = new List <Word>();

            int word_number   = 0;
            int word_position = 0;

            string[] word_texts = waw_text.Split();
            for (int i = 0; i < word_texts.Length; i++)
            {
                string word_text = word_texts[i];
                if (word_text.Length > 0)
                {
                    // build new Words
                    if ((word_text.Length == 1)
                        &&
                        ((word_text[0] == '۩') || (word_text[0] == '⌂'))
                        )
                    {
                        // add stopmark to previous word to stop it interfering with next verse or with chapters 8, 54, 97 as previous ones end with sijood
                        if (((i - 1) >= 0) && ((i - 1) < this.words.Count))
                        {
                            if (this.words[i - 1].Stopmark == Stopmark.None)
                            {
                                this.words[i - 1].Stopmark = Stopmark.MustStop;
                            }
                        }
                    }
                    else if (
                        (word_text.Length == 1)
                        &&
                        !((word_text == "ص") || (word_text == "ق") || (word_text == "ٯ") || (word_text == "ن") || (word_text == "ں") || (word_text == "و"))
                        )
                    {
                        if ((Constants.STOPMARKS.Contains(word_text[0])) || (Constants.QURANMARKS.Contains(word_text[0])))
                        {
                            // increment word position by stopmarks length in original text
                            word_position += 2; // 2 for stopmark and space after it
                        }
                        continue;               // skip stopmarks/quranmarks
                    }
                    else // proper word
                    {
                        word_number++;
                        Stopmark word_stopmark = Stopmark.None;

                        // lookahead to determine word stopmark
                        // if not last word in verse
                        if (i < word_texts.Length - 1)
                        {
                            word_stopmark = StopmarkHelper.GetStopmark(word_texts[i + 1]);

                            // Quran 36:52 has another stopmark after MustPause, so use that instead
                            if (word_stopmark != Stopmark.None)
                            {
                                if (word_texts.Length > (i + 2))
                                {
                                    Stopmark next_word_stopmark = StopmarkHelper.GetStopmark(word_texts[i + 2]);
                                    if (next_word_stopmark != Stopmark.None)
                                    {
                                        word_stopmark = next_word_stopmark;
                                    }
                                }
                            }

                            // add stopmark.CanStop after بسم الله الرحمن الرحيم except 1:1 and 27:30
                            if (word_number == 4)
                            {
                                if ((word_text.Simplify29() == "الرحيم") || (word_text.Simplify29() == "الررحيم"))
                                {
                                    word_stopmark = Stopmark.CanStop;
                                }
                            }
                        }
                        else // last word in verse
                        {
                            // if no stopmark after word
                            if (word_stopmark == Stopmark.None)
                            {
                                // use verse stopmark
                                word_stopmark = this.stopmark;
                            }
                        }

                        Word word = new Word(this, word_number, word_position, word_text);
                        if (word != null)
                        {
                            word.Stopmark = word_stopmark;
                            this.words.Add(word);
                        }
                    }

                    // in all cases
                    word_position += word_text.Length + 1; // 1 for space
                }
            }
        }
コード例 #7
0
        public void ApplyWordStopmarks(string original_text)
        {
            int word_number = 0;

            string[] word_texts = original_text.Split();
            for (int i = 0; i < word_texts.Length; i++)
            {
                string word_text = word_texts[i];
                if (word_text.Length > 0)
                {
                    // build new Words
                    if ((word_text.Length == 1)
                        &&
                        ((word_text[0] == '۩') || (word_text[0] == '⌂'))
                        )
                    {
                        // add stopmark to previous word to stop it interfering with next verse or with chapters 8, 54, 97 as previous ones end with sijood
                        if (((i - 1) >= 0) && ((i - 1) < this.words.Count))
                        {
                            if (this.words[i - 1].Stopmark == Stopmark.None)
                            {
                                this.words[i - 1].Stopmark = Stopmark.MustStop;
                            }
                        }
                    }
                    else if (
                        (word_text.Length == 1)
                        &&
                        !((word_text == "ص") || (word_text == "ق") || (word_text == "ٯ") || (word_text == "ن") || (word_text == "ں") || (word_text == "و"))
                        )
                    {
                        continue; // skip stopmarks/quranmarks
                    }
                    else // proper word
                    {
                        Stopmark word_stopmark = Stopmark.None;
                        word_number++;

                        // lookahead to determine word stopmark
                        // if not last word in verse
                        if (i < word_texts.Length - 1)
                        {
                            word_stopmark = StopmarkHelper.GetStopmark(word_texts[i + 1]);

                            // Quran 36:52 has another stopmark after MustPause, so use that instead
                            if (word_stopmark != Stopmark.None)
                            {
                                if (word_texts.Length > (i + 2))
                                {
                                    Stopmark next_word_stopmark = StopmarkHelper.GetStopmark(word_texts[i + 2]);
                                    if (next_word_stopmark != Stopmark.None)
                                    {
                                        word_stopmark = next_word_stopmark;
                                    }
                                }
                            }

                            // add stopmark.CanStop after بسم الله الرحمن الرحيم except 1:1 and 27:30
                            if (word_number == 4)
                            {
                                if ((word_text.Simplify29() == "الرحيم") || (word_text.Simplify29() == "الررحيم"))
                                {
                                    word_stopmark = Stopmark.CanStop;
                                }
                            }
                        }
                        else // last word in verse
                        {
                            // if no stopmark after word
                            if (word_stopmark == Stopmark.None)
                            {
                                word_stopmark = this.stopmark;
                            }
                        }

                        // apply word stopmark
                        int word_index = word_number - 1;
                        if ((word_index >= 0) && (word_index < this.words.Count))
                        {
                            this.words[word_number - 1].Stopmark = word_stopmark;
                        }
                    }
                }
            }
        }