Ejemplo n.º 1
0
    private static List<List<Verse>> DoFindVerseRanges(List<Verse> source, NumberQuery query)
    {
        List<List<Verse>> result = new List<List<Verse>>();
        if (source != null)
        {
            if (query.VerseCount > 1) // ensure range search
            {
                for (int i = 0; i < source.Count - query.VerseCount + 1; i++)
                {
                    // build required range
                    List<Verse> range = new List<Verse>();
                    for (int j = i; j < i + query.VerseCount; j++)
                    {
                        range.Add(source[j]);
                    }

                    // check range
                    if (Compare(range, query))
                    {
                        result.Add(range);
                    }
                }
            }
        }
        return result;
    }
Ejemplo n.º 2
0
 private static List<Verse> DoFindVerses(List<Verse> source, NumberQuery query)
 {
     List<Verse> result = new List<Verse>();
     if (source != null)
     {
         if (query.VerseCount <= 1) // ensure no range search
         {
             foreach (Verse verse in source)
             {
                 if (Compare(verse, query))
                 {
                     result.Add(verse);
                 }
             }
         }
     }
     return result;
 }
Ejemplo n.º 3
0
 private static List<Chapter> DoFindChapters(List<Verse> source, NumberQuery query)
 {
     List<Chapter> result = new List<Chapter>();
     if (source != null)
     {
         if (source.Count > 0)
         {
             Book book = source[0].Book;
             List<Chapter> chapters = book.GetChapters(source);
             if (chapters != null)
             {
                 if (query.ChapterCount <= 1) // ensure no range search
                 {
                     foreach (Chapter chapter in chapters)
                     {
                         if (Compare(chapter, query))
                         {
                             result.Add(chapter);
                         }
                     }
                 }
             }
         }
     }
     return result;
 }
Ejemplo n.º 4
0
    private static List<Sentence> DoFindSentences(List<Verse> source, NumberQuery query)
    {
        List<Sentence> result = new List<Sentence>();
        if (source != null)
        {
            if (source.Count > 0)
            {
                List<Word> words = new List<Word>();
                foreach (Verse verse in source)
                {
                    words.AddRange(verse.Words);
                }

                // scan linearly for sequence of words with total Text matching letter_frequency_sum
                for (int i = 0; i < words.Count - 1; i++)
                {
                    StringBuilder str = new StringBuilder();

                    // start building word sequence
                    str.Append(words[i].Text);

                    string stopmark_text;
                    switch (words[i].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.CanStopAtOneOnly:
                            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;
                    }

                    // if word has no stopmark or must continue
                    if ((words[i].Stopmark == Stopmark.None) || (words[i].Stopmark == Stopmark.MustContinue))
                    {
                        // continue building with next words until a stopmark
                        for (int j = i + 1; j < words.Count; j++)
                        {
                            str.Append(" " + words[j].Text);

                            if (words[j].Stopmark == Stopmark.None)
                            {
                                continue; // continue building sentence
                            }
                            else // there is a stopmark
                            {
                                if (NumerologySystem.TextMode.Contains("Original"))
                                {
                                    str.Append(" " + stopmark_text);
                                }

                                if (words[j].Stopmark == Stopmark.MustContinue)
                                {
                                    continue; // continue building sentence
                                }
                                else if (
                                    (words[j].Stopmark == Stopmark.CanStopAtOneOnly) ||
                                    (words[j].Stopmark == Stopmark.ShouldContinue) ||
                                    (words[j].Stopmark == Stopmark.CanStop) ||
                                    (words[j].Stopmark == Stopmark.ShouldStop)
                                    )
                                {
                                    // a sub sentence completed
                                    Sentence sentence = new Sentence(words[i].Verse, words[i].Position, words[j].Verse, words[j].Position + words[j].Text.Length, str.ToString());
                                    if (sentence != null)
                                    {
                                        if (Compare(sentence, query))
                                        {
                                            result.Add(sentence);
                                        }
                                    }
                                    continue; // continue building a longer senetence
                                }
                                else if (words[j].Stopmark == Stopmark.MustPause)
                                {
                                    if (
                                        (words[j].Text.Simplify29() == "مَنْ".Simplify29()) ||
                                        (words[j].Text.Simplify29() == "بَلْ".Simplify29())
                                       )
                                    {
                                        continue; // continue building a longer senetence
                                    }
                                    else if (
                                        (words[j].Text.Simplify29() == "عِوَجَا".Simplify29()) ||
                                        (words[j].Text.Simplify29() == "مَّرْقَدِنَا".Simplify29()) ||
                                        (words[j].Text.Simplify29() == "مَالِيَهْ".Simplify29())
                                        )
                                    {
                                        // a sub sentence completed
                                        Sentence sentence = new Sentence(words[i].Verse, words[i].Position, words[j].Verse, words[j].Position + words[j].Text.Length, str.ToString());
                                        if (sentence != null)
                                        {
                                            if (Compare(sentence, query))
                                            {
                                                result.Add(sentence);
                                            }
                                        }
                                        continue; // continue building a longer senetence
                                    }
                                    else // unknown case
                                    {
                                        throw new Exception("Unknown stopmark in Quran text.");
                                    }
                                }
                                else if (words[j].Stopmark == Stopmark.MustStop)
                                {
                                    // the sentence completed
                                    Sentence sentence = new Sentence(words[i].Verse, words[i].Position, words[j].Verse, words[j].Position + words[j].Text.Length, str.ToString());
                                    if (sentence != null)
                                    {
                                        if (Compare(sentence, query))
                                        {
                                            result.Add(sentence);
                                        }
                                    }

                                    i = j; // start a new sentence after j
                                    break; // break j, start next i
                                }
                                else // unknown case
                                {
                                    throw new Exception("Unknown stopmark in Quran text.");
                                }
                            }
                        }
                    }
                }
            }
        }
        return result;
    }
Ejemplo n.º 5
0
    // find by numbers - Sentences
    /// <summary>
    /// Find sentences across verses that meet query criteria.
    /// </summary>
    /// <param name="query"></param>
    /// <returns>Number of found sentences. Result is stored in FoundSentences.</returns>
    public int FindSentences(NumberQuery query)
    {
        m_found_sentences = Server.FindSentences(m_book, m_find_scope, m_selection, m_found_verses, query);
        if (m_found_sentences != null)
        {
            BuildSentencePhrases();

            return m_found_sentences.Count;
        }
        return 0;
    }
Ejemplo n.º 6
0
    private static List<List<Chapter>> DoFindChapterRanges(List<Verse> source, NumberQuery query)
    {
        List<List<Chapter>> result = new List<List<Chapter>>();
        if (source != null)
        {
            if (source.Count > 0)
            {
                Book book = source[0].Book;
                List<Chapter> chapters = book.GetChapters(source);
                if (chapters != null)
                {
                    if (query.ChapterCount > 1) // ensure range search
                    {
                        for (int i = 0; i < chapters.Count - query.ChapterCount + 1; i++)
                        {
                            // build required range
                            List<Chapter> range = new List<Chapter>();
                            for (int j = i; j < i + query.ChapterCount; j++)
                            {
                                range.Add(chapters[j]);
                            }

                            // check range
                            if (Compare(range, query))
                            {
                                result.Add(range);
                            }
                        }
                    }
                }
            }
        }
        return result;
    }
Ejemplo n.º 7
0
    private void FindByNumbers()
    {
        if (m_client != null)
        {
            PrepareNewSearch();

            // 1. number types
            string number_symbol = FindByNumbersNumberNumberTypeLabel.Enabled ? FindByNumbersNumberNumberTypeLabel.Text : "";
            NumberType number_number_type =
                (number_symbol == "PP") ? NumberType.PurePrime :
                (number_symbol == "AP") ? NumberType.AdditivePrime :
                (number_symbol == "P") ? NumberType.Prime :
                (number_symbol == "PC") ? NumberType.PureComposite :
                (number_symbol == "AC") ? NumberType.AdditiveComposite :
                (number_symbol == "C") ? NumberType.Composite :
                (number_symbol == "O") ? NumberType.Odd :
                (number_symbol == "E") ? NumberType.Even :
                (number_symbol == "*") ? NumberType.Any :
                                         NumberType.None;
            string chapter_count_symbol = FindByNumbersChaptersNumberTypeLabel.Enabled ? FindByNumbersChaptersNumberTypeLabel.Text : "";
            NumberType chapter_count_number_type =
                (chapter_count_symbol == "PP") ? NumberType.PurePrime :
                (chapter_count_symbol == "AP") ? NumberType.AdditivePrime :
                (chapter_count_symbol == "P") ? NumberType.Prime :
                (chapter_count_symbol == "PC") ? NumberType.PureComposite :
                (chapter_count_symbol == "AC") ? NumberType.AdditiveComposite :
                (chapter_count_symbol == "C") ? NumberType.Composite :
                (chapter_count_symbol == "O") ? NumberType.Odd :
                (chapter_count_symbol == "E") ? NumberType.Even :
                (chapter_count_symbol == "*") ? NumberType.Any :
                                                NumberType.None;
            string verse_count_symbol = FindByNumbersVersesNumberTypeLabel.Enabled ? FindByNumbersVersesNumberTypeLabel.Text : "";
            NumberType verse_count_number_type =
                (verse_count_symbol == "PP") ? NumberType.PurePrime :
                (verse_count_symbol == "AP") ? NumberType.AdditivePrime :
                (verse_count_symbol == "P") ? NumberType.Prime :
                (verse_count_symbol == "PC") ? NumberType.PureComposite :
                (verse_count_symbol == "AC") ? NumberType.AdditiveComposite :
                (verse_count_symbol == "C") ? NumberType.Composite :
                (verse_count_symbol == "O") ? NumberType.Odd :
                (verse_count_symbol == "E") ? NumberType.Even :
                (verse_count_symbol == "*") ? NumberType.Any :
                                              NumberType.None;
            string word_count_symbol = FindByNumbersWordsNumberTypeLabel.Enabled ? FindByNumbersWordsNumberTypeLabel.Text : "";
            NumberType word_count_number_type =
                (word_count_symbol == "PP") ? NumberType.PurePrime :
                (word_count_symbol == "AP") ? NumberType.AdditivePrime :
                (word_count_symbol == "P") ? NumberType.Prime :
                (word_count_symbol == "PC") ? NumberType.PureComposite :
                (word_count_symbol == "AC") ? NumberType.AdditiveComposite :
                (word_count_symbol == "C") ? NumberType.Composite :
                (word_count_symbol == "O") ? NumberType.Odd :
                (word_count_symbol == "E") ? NumberType.Even :
                (word_count_symbol == "*") ? NumberType.Any :
                                             NumberType.None;
            string letter_count_symbol = FindByNumbersLettersNumberTypeLabel.Enabled ? FindByNumbersLettersNumberTypeLabel.Text : "";
            NumberType letter_count_number_type =
                (letter_count_symbol == "PP") ? NumberType.PurePrime :
                (letter_count_symbol == "AP") ? NumberType.AdditivePrime :
                (letter_count_symbol == "P") ? NumberType.Prime :
                (letter_count_symbol == "PC") ? NumberType.PureComposite :
                (letter_count_symbol == "AC") ? NumberType.AdditiveComposite :
                (letter_count_symbol == "C") ? NumberType.Composite :
                (letter_count_symbol == "O") ? NumberType.Odd :
                (letter_count_symbol == "E") ? NumberType.Even :
                (letter_count_symbol == "*") ? NumberType.Any :
                                               NumberType.None;
            string unique_letter_count_symbol = FindByNumbersUniqueLettersNumberTypeLabel.Enabled ? FindByNumbersUniqueLettersNumberTypeLabel.Text : "";
            NumberType unique_letter_count_number_type =
                (unique_letter_count_symbol == "PP") ? NumberType.PurePrime :
                (unique_letter_count_symbol == "AP") ? NumberType.AdditivePrime :
                (unique_letter_count_symbol == "P") ? NumberType.Prime :
                (unique_letter_count_symbol == "PC") ? NumberType.PureComposite :
                (unique_letter_count_symbol == "AC") ? NumberType.AdditiveComposite :
                (unique_letter_count_symbol == "C") ? NumberType.Composite :
                (unique_letter_count_symbol == "O") ? NumberType.Odd :
                (unique_letter_count_symbol == "E") ? NumberType.Even :
                (unique_letter_count_symbol == "*") ? NumberType.Any :
                                                      NumberType.None;
            string value_symbol = FindByNumbersValueNumberTypeLabel.Enabled ? FindByNumbersValueNumberTypeLabel.Text : "";
            NumberType value_number_type =
                (value_symbol == "PP") ? NumberType.PurePrime :
                (value_symbol == "AP") ? NumberType.AdditivePrime :
                (value_symbol == "P") ? NumberType.Prime :
                (value_symbol == "PC") ? NumberType.PureComposite :
                (value_symbol == "AC") ? NumberType.AdditiveComposite :
                (value_symbol == "C") ? NumberType.Composite :
                (value_symbol == "O") ? NumberType.Odd :
                (value_symbol == "E") ? NumberType.Even :
                (value_symbol == "*") ? NumberType.Any :
                                        NumberType.None;
            string value_digit_sum_symbol = FindByNumbersValueDigitSumNumberTypeLabel.Enabled ? FindByNumbersValueDigitSumNumberTypeLabel.Text : "";
            NumberType value_digit_sum_number_type =
                (value_digit_sum_symbol == "PP") ? NumberType.PurePrime :
                (value_digit_sum_symbol == "AP") ? NumberType.AdditivePrime :
                (value_digit_sum_symbol == "P") ? NumberType.Prime :
                (value_digit_sum_symbol == "PC") ? NumberType.PureComposite :
                (value_digit_sum_symbol == "AC") ? NumberType.AdditiveComposite :
                (value_digit_sum_symbol == "C") ? NumberType.Composite :
                (value_digit_sum_symbol == "O") ? NumberType.Odd :
                (value_digit_sum_symbol == "E") ? NumberType.Even :
                (value_digit_sum_symbol == "*") ? NumberType.Any :
                                                  NumberType.None;
            string value_digital_root_symbol = FindByNumbersValueDigitalRootNumberTypeLabel.Enabled ? FindByNumbersValueDigitalRootNumberTypeLabel.Text : "";
            NumberType value_digital_root_number_type =
                (value_digital_root_symbol == "PP") ? NumberType.PurePrime :
                (value_digital_root_symbol == "AP") ? NumberType.AdditivePrime :
                (value_digital_root_symbol == "P") ? NumberType.Prime :
                (value_digital_root_symbol == "PC") ? NumberType.PureComposite :
                (value_digital_root_symbol == "AC") ? NumberType.AdditiveComposite :
                (value_digital_root_symbol == "C") ? NumberType.Composite :
                (value_digital_root_symbol == "O") ? NumberType.Odd :
                (value_digital_root_symbol == "E") ? NumberType.Even :
                (value_digital_root_symbol == "*") ? NumberType.Any :
                                                     NumberType.None;

            // 2. numbers
            int number = FindByNumbersNumberNumericUpDown.Enabled ? ((number_number_type == NumberType.None) ? (int)FindByNumbersNumberNumericUpDown.Value : 0) : 0;
            int chapter_count = FindByNumbersChaptersNumericUpDown.Enabled ? ((chapter_count_number_type == NumberType.None) ? (int)FindByNumbersChaptersNumericUpDown.Value : 0) : 0;
            int verse_count = FindByNumbersVersesNumericUpDown.Enabled ? ((verse_count_number_type == NumberType.None) ? (int)FindByNumbersVersesNumericUpDown.Value : 0) : 0;
            int word_count = FindByNumbersWordsNumericUpDown.Enabled ? ((word_count_number_type == NumberType.None) ? (int)FindByNumbersWordsNumericUpDown.Value : 0) : 0;
            int letter_count = FindByNumbersLettersNumericUpDown.Enabled ? ((letter_count_number_type == NumberType.None) ? (int)FindByNumbersLettersNumericUpDown.Value : 0) : 0;
            int unique_letter_count = FindByNumbersUniqueLettersNumericUpDown.Enabled ? ((unique_letter_count_number_type == NumberType.None) ? (int)FindByNumbersUniqueLettersNumericUpDown.Value : 0) : 0;
            long value = FindByNumbersValueNumericUpDown.Enabled ? ((value_number_type == NumberType.None) ? (long)FindByNumbersValueNumericUpDown.Value : 0) : 0;
            int value_digit_sum = FindByNumbersValueDigitSumNumericUpDown.Enabled ? ((value_digit_sum_number_type == NumberType.None) ? (int)FindByNumbersValueDigitSumNumericUpDown.Value : 0) : 0;
            int value_digital_root = FindByNumbersValueDigitalRootNumericUpDown.Enabled ? ((value_digital_root_number_type == NumberType.None) ? (int)FindByNumbersValueDigitalRootNumericUpDown.Value : 0) : 0;

            // 3. comparison operators = ≠ < ≤ > ≥
            string number_operator_symbol = FindByNumbersNumberComparisonOperatorLabel.Text;
            ComparisonOperator number_comparison_operator =
                (number_operator_symbol == "=") ? ComparisonOperator.Equal :
                (number_operator_symbol == "≠") ? ComparisonOperator.NotEqual :
                (number_operator_symbol == "<") ? ComparisonOperator.LessThan :
                (number_operator_symbol == "≤") ? ComparisonOperator.LessThanOrEqual :
                (number_operator_symbol == ">") ? ComparisonOperator.GreaterThan :
                (number_operator_symbol == "≥") ? ComparisonOperator.GreaterThanOrEqual :
                                                  ComparisonOperator.Unknown;
            string chapter_count_operator_symbol = FindByNumbersChaptersComparisonOperatorLabel.Text;
            ComparisonOperator chapter_count_comparison_operator =
                (chapter_count_operator_symbol == "=") ? ComparisonOperator.Equal :
                (chapter_count_operator_symbol == "≠") ? ComparisonOperator.NotEqual :
                (chapter_count_operator_symbol == "<") ? ComparisonOperator.LessThan :
                (chapter_count_operator_symbol == "≤") ? ComparisonOperator.LessThanOrEqual :
                (chapter_count_operator_symbol == ">") ? ComparisonOperator.GreaterThan :
                (chapter_count_operator_symbol == "≥") ? ComparisonOperator.GreaterThanOrEqual :
                                                         ComparisonOperator.Unknown;
            string verse_count_operator_symbol = FindByNumbersVersesComparisonOperatorLabel.Text;
            ComparisonOperator verse_count_comparison_operator =
                (verse_count_operator_symbol == "=") ? ComparisonOperator.Equal :
                (verse_count_operator_symbol == "≠") ? ComparisonOperator.NotEqual :
                (verse_count_operator_symbol == "<") ? ComparisonOperator.LessThan :
                (verse_count_operator_symbol == "≤") ? ComparisonOperator.LessThanOrEqual :
                (verse_count_operator_symbol == ">") ? ComparisonOperator.GreaterThan :
                (verse_count_operator_symbol == "≥") ? ComparisonOperator.GreaterThanOrEqual :
                                                       ComparisonOperator.Unknown;
            string word_count_operator_symbol = FindByNumbersWordsComparisonOperatorLabel.Text;
            ComparisonOperator word_count_comparison_operator =
                (word_count_operator_symbol == "=") ? ComparisonOperator.Equal :
                (word_count_operator_symbol == "≠") ? ComparisonOperator.NotEqual :
                (word_count_operator_symbol == "<") ? ComparisonOperator.LessThan :
                (word_count_operator_symbol == "≤") ? ComparisonOperator.LessThanOrEqual :
                (word_count_operator_symbol == ">") ? ComparisonOperator.GreaterThan :
                (word_count_operator_symbol == "≥") ? ComparisonOperator.GreaterThanOrEqual :
                                                      ComparisonOperator.Unknown;
            string letter_count_operator_symbol = FindByNumbersLettersComparisonOperatorLabel.Text;
            ComparisonOperator letter_count_comparison_operator =
                (letter_count_operator_symbol == "=") ? ComparisonOperator.Equal :
                (letter_count_operator_symbol == "≠") ? ComparisonOperator.NotEqual :
                (letter_count_operator_symbol == "<") ? ComparisonOperator.LessThan :
                (letter_count_operator_symbol == "≤") ? ComparisonOperator.LessThanOrEqual :
                (letter_count_operator_symbol == ">") ? ComparisonOperator.GreaterThan :
                (letter_count_operator_symbol == "≥") ? ComparisonOperator.GreaterThanOrEqual :
                                                        ComparisonOperator.Unknown;
            string unique_letter_count_operator_symbol = FindByNumbersUniqueLettersComparisonOperatorLabel.Text;
            ComparisonOperator unique_letter_count_comparison_operator =
                (unique_letter_count_operator_symbol == "=") ? ComparisonOperator.Equal :
                (unique_letter_count_operator_symbol == "≠") ? ComparisonOperator.NotEqual :
                (unique_letter_count_operator_symbol == "<") ? ComparisonOperator.LessThan :
                (unique_letter_count_operator_symbol == "≤") ? ComparisonOperator.LessThanOrEqual :
                (unique_letter_count_operator_symbol == ">") ? ComparisonOperator.GreaterThan :
                (unique_letter_count_operator_symbol == "≥") ? ComparisonOperator.GreaterThanOrEqual :
                                                               ComparisonOperator.Unknown;
            string value_operator_symbol = FindByNumbersValueComparisonOperatorLabel.Text;
            ComparisonOperator value_comparison_operator =
                (value_operator_symbol == "=") ? ComparisonOperator.Equal :
                (value_operator_symbol == "≠") ? ComparisonOperator.NotEqual :
                (value_operator_symbol == "<") ? ComparisonOperator.LessThan :
                (value_operator_symbol == "≤") ? ComparisonOperator.LessThanOrEqual :
                (value_operator_symbol == ">") ? ComparisonOperator.GreaterThan :
                (value_operator_symbol == "≥") ? ComparisonOperator.GreaterThanOrEqual :
                                                 ComparisonOperator.Unknown;
            string digit_sum_operator_symbol = FindByNumbersValueDigitSumComparisonOperatorLabel.Text;
            ComparisonOperator value_digit_sum_comparison_operator =
                (digit_sum_operator_symbol == "=") ? ComparisonOperator.Equal :
                (digit_sum_operator_symbol == "≠") ? ComparisonOperator.NotEqual :
                (digit_sum_operator_symbol == "<") ? ComparisonOperator.LessThan :
                (digit_sum_operator_symbol == "≤") ? ComparisonOperator.LessThanOrEqual :
                (digit_sum_operator_symbol == ">") ? ComparisonOperator.GreaterThan :
                (digit_sum_operator_symbol == "≥") ? ComparisonOperator.GreaterThanOrEqual :
                                                     ComparisonOperator.Unknown;
            string digital_root_operator_symbol = FindByNumbersValueDigitalRootComparisonOperatorLabel.Text;
            ComparisonOperator value_digital_root_comparison_operator =
                (digital_root_operator_symbol == "=") ? ComparisonOperator.Equal :
                (digital_root_operator_symbol == "≠") ? ComparisonOperator.NotEqual :
                (digital_root_operator_symbol == "<") ? ComparisonOperator.LessThan :
                (digital_root_operator_symbol == "≤") ? ComparisonOperator.LessThanOrEqual :
                (digital_root_operator_symbol == ">") ? ComparisonOperator.GreaterThan :
                (digital_root_operator_symbol == "≥") ? ComparisonOperator.GreaterThanOrEqual :
                                                        ComparisonOperator.Unknown;

            string text = null;
            text += "number" + number_operator_symbol + ((number > 0) ? number.ToString() : ((number_number_type != NumberType.None) ? FindByNumbersNumberNumberTypeLabel.Text : "*")) + " ";

            if (
                (m_numbers_result_type == NumberSearchType.ChapterRanges)
               )
            {
                text += "chapters" + chapter_count_operator_symbol + ((chapter_count > 0) ? chapter_count.ToString() : ((chapter_count_number_type != NumberType.None) ? FindByNumbersChaptersNumberTypeLabel.Text : "*")) + " ";
            }

            if (
                (m_numbers_result_type == NumberSearchType.Chapters) ||
                (m_numbers_result_type == NumberSearchType.ChapterRanges) ||
                (m_numbers_result_type == NumberSearchType.VerseRanges)
               )
            {
                text += "verses" + verse_count_operator_symbol + ((verse_count > 0) ? verse_count.ToString() : ((verse_count_number_type != NumberType.None) ? FindByNumbersVersesNumberTypeLabel.Text : "*")) + " ";
            }

            if (
                (m_numbers_result_type == NumberSearchType.Chapters) ||
                (m_numbers_result_type == NumberSearchType.ChapterRanges) ||
                (m_numbers_result_type == NumberSearchType.Verses) ||
                (m_numbers_result_type == NumberSearchType.VerseRanges) ||
                (m_numbers_result_type == NumberSearchType.Sentences) ||
                (m_numbers_result_type == NumberSearchType.WordRanges)
               )
            {
                text += "words" + word_count_operator_symbol + ((word_count > 0) ? word_count.ToString() : ((word_count_number_type != NumberType.None) ? FindByNumbersWordsNumberTypeLabel.Text : "*")) + " ";
            }

            text += "letters" + letter_count_operator_symbol + ((letter_count > 0) ? letter_count.ToString() : ((letter_count_number_type != NumberType.None) ? FindByNumbersLettersNumberTypeLabel.Text : "*")) + " ";
            text += "unique" + unique_letter_count_operator_symbol + ((unique_letter_count > 0) ? unique_letter_count.ToString() : ((unique_letter_count_number_type != NumberType.None) ? FindByNumbersUniqueLettersNumberTypeLabel.Text : "*")) + " ";
            text += "value" + value_operator_symbol + ((value > 0) ? value.ToString() : ((value_number_type != NumberType.None) ? FindByNumbersValueNumberTypeLabel.Text : "*")) + " ";
            text += "digit_sum" + digit_sum_operator_symbol + ((value_digit_sum > 0) ? value_digit_sum.ToString() : ((value_digit_sum_number_type != NumberType.None) ? FindByNumbersValueDigitSumNumberTypeLabel.Text : "*")) + " ";
            text += "digital_root" + digital_root_operator_symbol + ((value_digital_root > 0) ? value_digital_root.ToString() : ((value_digital_root_number_type != NumberType.None) ? FindByNumbersValueDigitalRootNumberTypeLabel.Text : "*")) + "";

            NumberQuery query = new NumberQuery();
            query.Number = number;
            query.ChapterCount = chapter_count;
            query.VerseCount = verse_count;
            query.WordCount = word_count;
            query.LetterCount = letter_count;
            query.UniqueLetterCount = unique_letter_count;
            query.Value = value;
            query.ValueDigitSum = value_digit_sum;
            query.ValueDigitalRoot = value_digital_root;
            query.NumberNumberType = number_number_type;
            query.ChapterCountNumberType = chapter_count_number_type;
            query.VerseCountNumberType = verse_count_number_type;
            query.WordCountNumberType = word_count_number_type;
            query.LetterCountNumberType = letter_count_number_type;
            query.UniqueLetterCountNumberType = unique_letter_count_number_type;
            query.ValueNumberType = value_number_type;
            query.ValueDigitSumNumberType = value_digit_sum_number_type;
            query.ValueDigitalRootNumberType = value_digital_root_number_type;
            query.NumberComparisonOperator = number_comparison_operator;
            query.ChapterCountComparisonOperator = chapter_count_comparison_operator;
            query.VerseCountComparisonOperator = verse_count_comparison_operator;
            query.WordCountComparisonOperator = word_count_comparison_operator;
            query.LetterCountComparisonOperator = letter_count_comparison_operator;
            query.UniqueLetterCountComparisonOperator = unique_letter_count_comparison_operator;
            query.ValueComparisonOperator = value_comparison_operator;
            query.ValueDigitSumComparisonOperator = value_digit_sum_comparison_operator;
            query.ValueDigitalRootComparisonOperator = value_digital_root_comparison_operator;

            if (!query.IsEmpty(m_numbers_result_type))
            {
                int match_count = -1;
                switch (m_numbers_result_type)
                {
                    case NumberSearchType.Words:
                        {
                            match_count = m_client.FindWords(query);
                            m_find_result_header = match_count + ((match_count == 1) ? " word" : " words") + " in " + m_client.FoundVerses.Count + ((m_client.FoundVerses.Count == 1) ? " verse" : " verses") + " with " + text + " in " + m_client.FindScope.ToString();
                            DisplayFoundVerses(true);
                        }
                        break;
                    case NumberSearchType.WordRanges:
                        {
                            match_count = m_client.FindWordRanges(query);
                            m_find_result_header = match_count + ((match_count == 1) ? " word range" : " word ranges") + " in " + m_client.FoundVerses.Count + ((m_client.FoundVerses.Count == 1) ? " verse" : " verses") + " with " + text + " in " + m_client.FindScope.ToString();
                            DisplayFoundVerses(true);
                        }
                        break;
                    case NumberSearchType.Sentences:
                        {
                            match_count = m_client.FindSentences(query);
                            m_find_result_header = match_count + ((match_count == 1) ? " sentence" : " sentences") + " with " + text + " in " + m_client.FindScope.ToString();
                            DisplayFoundVerses(true);
                        }
                        break;
                    case NumberSearchType.Verses:
                        {
                            match_count = m_client.FindVerses(query);
                            m_find_result_header = match_count + ((match_count == 1) ? " verse" : " verses") + " with " + text + " in " + m_client.FindScope.ToString();
                            DisplayFoundVerses(true);
                        }
                        break;
                    case NumberSearchType.VerseRanges:
                        {
                            match_count = m_client.FindVerseRanges(query);
                            m_find_result_header = match_count + ((match_count == 1) ? " verse range" : " verse ranges") + " with " + text + " in " + m_client.FindScope.ToString();
                            DisplayFoundVerseRanges(true);
                        }
                        break;
                    case NumberSearchType.Chapters:
                        {
                            match_count = m_client.FindChapters(query);
                            m_find_result_header = match_count + ((match_count == 1) ? " chapter" : " chapters") + " with " + text + " in " + m_client.FindScope.ToString();
                            DisplayFoundChapters(true);
                        }
                        break;
                    case NumberSearchType.ChapterRanges:
                        {
                            match_count = m_client.FindChapterRanges(query);
                            m_find_result_header = match_count + ((match_count == 1) ? " chapter range" : " chapter ranges") + " with " + text + " in " + m_client.FindScope.ToString();
                            DisplayFoundChapterRanges(true);
                        }
                        break;
                    default:
                        break;
                }
            }
        }
    }
Ejemplo n.º 8
0
 private static List<Word> DoFindWords(List<Verse> source, NumberQuery query)
 {
     List<Word> result = new List<Word>();
     if (source != null)
     {
         if (query.WordCount <= 1) // ensure no range search
         {
             foreach (Verse verse in source)
             {
                 foreach (Word word in verse.Words)
                 {
                     if (Compare(word, query))
                     {
                         result.Add(word);
                     }
                 }
             }
         }
     }
     return result;
 }
Ejemplo n.º 9
0
    // find by numbers - Words
    /// <summary>
    /// Find words that meet query criteria.
    /// </summary>
    /// <param name="query"></param>
    /// <returns>Number of found words. Result is stored in FoundWords.</returns>
    public int FindWords(NumberQuery query)
    {
        m_found_words = Server.FindWords(m_book, m_find_scope, m_selection, m_found_verses, query);
        if (m_found_words != null)
        {
            m_found_verses = new List<Verse>();
            m_found_phrases = new List<Phrase>();
            foreach (Word word in m_found_words)
            {
                if (word != null)
                {
                    Verse verse = word.Verse;
                    if (!m_found_verses.Contains(verse))
                    {
                        m_found_verses.Add(verse);
                    }
                }

                Phrase phrase = new Phrase(word.Verse, word.Position, word.Text);
                m_found_phrases.Add(phrase);
            }

            return m_found_words.Count;
        }
        return 0;
    }
Ejemplo n.º 10
0
    private void DoFindSameValue(long value)
    {
        if (m_client != null)
        {
            int match_count = 0;
            List<Verse> found_verses = new List<Verse>();
            List<Phrase> found_phrases = new List<Phrase>();
            PrepareNewSearch();

            string text = "value" + "" + "=" + value.ToString();

            NumberQuery query = new NumberQuery();
            query.Value = value;

            match_count += m_client.FindWords(query);
            if (match_count > 0)
            {
                found_verses.InsertRange(0, new List<Verse>(m_client.FoundVerses));
                found_phrases.InsertRange(0, new List<Phrase>(m_client.FoundPhrases));
            }

            match_count += m_client.FindSentences(query);
            if (match_count > 0)
            {
                found_verses.InsertRange(0, new List<Verse>(m_client.FoundVerses));
                found_phrases.InsertRange(0, new List<Phrase>(m_client.FoundPhrases));
            }

            match_count += m_client.FindVerses(query);
            if (match_count > 0)
            {
                found_verses.InsertRange(0, new List<Verse>(m_client.FoundVerses));
                found_phrases.InsertRange(0, new List<Phrase>(m_client.FoundPhrases));
            }

            m_client.FoundVerses = found_verses;
            m_client.FoundPhrases = found_phrases;
            m_find_result_header = match_count + ((match_count == 1) ? " match" : " matches") + " in " + m_client.FoundVerses.Count + ((m_client.FoundVerses.Count == 1) ? " verse" : " verses") + " with " + text + " in " + m_client.FindScope.ToString();
            DisplayFoundVerses(true);
        }
    }
Ejemplo n.º 11
0
    // find by numbers - WordRanges
    /// <summary>
    /// Find word ranges that meet query criteria.
    /// </summary>
    /// <param name="query"></param>
    /// <returns>Number of found word ranges. Result is stored in FoundWordRanges.</returns>
    public int FindWordRanges(NumberQuery query)
    {
        m_found_word_ranges = Server.FindWordRanges(m_book, m_find_scope, m_selection, m_found_verses, query);
        if (m_found_word_ranges != null)
        {
            m_found_verses = new List<Verse>();
            m_found_phrases = new List<Phrase>();
            foreach (List<Word> range in m_found_word_ranges)
            {
                if (range != null)
                {
                    if (range.Count > 0)
                    {
                        // prepare found phrase verse
                        Verse verse = range[0].Verse;

                        // build found verses // prevent duplicate verses in case more than 1 range is found in same verse
                        if (!m_found_verses.Contains(verse))
                        {
                            m_found_verses.Add(verse);
                        }

                        // prepare found phrase text
                        string range_text = null;
                        foreach (Word word in range)
                        {
                            range_text += word.Text + " ";
                        }
                        range_text = range_text.Remove(range_text.Length - 1, 1);

                        // prepare found phrase position
                        int range_position = range[0].Position;

                        // build found phrases // allow multiple phrases even if overlapping inside same verse
                        Phrase phrase = new Phrase(verse, range_position, range_text);
                        m_found_phrases.Add(phrase);
                    }
                }
            }

            return m_found_word_ranges.Count;
        }
        return 0;
    }
Ejemplo n.º 12
0
 // find by numbers - Verses
 /// <summary>
 /// Find verses that meet query criteria.
 /// </summary>
 /// <param name="query"></param>
 /// <returns>Number of found verses. Result is stored in FoundVerses.</returns>
 public int FindVerses(NumberQuery query)
 {
     m_found_verses = Server.FindVerses(m_book, m_find_scope, m_selection, m_found_verses, query);
     if (m_found_verses != null)
     {
         return m_found_verses.Count;
     }
     return 0;
 }
Ejemplo n.º 13
0
    // find by numbers - VerseRanges
    /// <summary>
    /// Find verse ranges that meet query criteria.
    /// </summary>
    /// <param name="query"></param>
    /// <returns>Number of found verse ranges. Result is stored in FoundVerseRanges.</returns>
    public int FindVerseRanges(NumberQuery query)
    {
        m_found_verse_ranges = Server.FindVerseRanges(m_book, m_find_scope, m_selection, m_found_verses, query);
        if (m_found_verse_ranges != null)
        {
            m_found_verses = new List<Verse>();
            foreach (List<Verse> range in m_found_verse_ranges)
            {
                m_found_verses.AddRange(range);
            }

            return m_found_verse_ranges.Count;
        }
        return 0;
    }
Ejemplo n.º 14
0
    private static List<List<Word>> DoFindWordRanges(List<Verse> source, NumberQuery query)
    {
        List<List<Word>> result = new List<List<Word>>();
        if (source != null)
        {
            if (query.WordCount > 1) // ensure range search
            {
                foreach (Verse verse in source) // find words within verse boundaries
                {
                    for (int i = 0; i < verse.Words.Count - query.WordCount + 1; i++)
                    {
                        // build required range
                        List<Word> range = new List<Word>();
                        for (int j = i; j < i + query.WordCount; j++)
                        {
                            range.Add(verse.Words[j]);
                        }

                        // check range
                        if (Compare(range, query))
                        {
                            result.Add(range);
                        }
                    }
                }
            }
        }
        return result;
    }
Ejemplo n.º 15
0
    private static bool Compare(Chapter chapter, NumberQuery query)
    {
        if (chapter != null)
        {
            long value = 0L;

            if (query.NumberNumberType == NumberType.None)
            {
                if (query.Number > 0)
                {
                    if (!Numbers.Compare(chapter.Number, query.Number, query.NumberComparisonOperator))
                    {
                        return false;
                    }
                }
            }
            else
            {
                if (!Numbers.IsNumberType(chapter.Number, query.NumberNumberType))
                {
                    return false;
                }
            }

            if (query.VerseCountNumberType == NumberType.None)
            {
                if (query.VerseCount > 0)
                {
                    if (!Numbers.Compare(chapter.Verses.Count, query.VerseCount, query.VerseCountComparisonOperator))
                    {
                        return false;
                    }
                }
            }
            else
            {
                if (!Numbers.IsNumberType(chapter.Verses.Count, query.VerseCountNumberType))
                {
                    return false;
                }
            }

            if (query.WordCountNumberType == NumberType.None)
            {
                if (query.WordCount > 0)
                {
                    if (!Numbers.Compare(chapter.WordCount, query.WordCount, query.WordCountComparisonOperator))
                    {
                        return false;
                    }
                }
            }
            else
            {
                if (!Numbers.IsNumberType(chapter.WordCount, query.WordCountNumberType))
                {
                    return false;
                }
            }

            if (query.LetterCountNumberType == NumberType.None)
            {
                if (query.LetterCount > 0)
                {
                    if (!Numbers.Compare(chapter.LetterCount, query.LetterCount, query.LetterCountComparisonOperator))
                    {
                        return false;
                    }
                }
            }
            else
            {
                if (!Numbers.IsNumberType(chapter.LetterCount, query.LetterCountNumberType))
                {
                    return false;
                }
            }

            if (query.UniqueLetterCountNumberType == NumberType.None)
            {
                if (query.UniqueLetterCount > 0)
                {
                    if (!Numbers.Compare(chapter.UniqueLetters.Count, query.UniqueLetterCount, query.UniqueLetterCountComparisonOperator))
                    {
                        return false;
                    }
                }
            }
            else
            {
                if (!Numbers.IsNumberType(chapter.UniqueLetters.Count, query.UniqueLetterCountNumberType))
                {
                    return false;
                }
            }

            if (query.ValueNumberType == NumberType.None)
            {
                if (query.Value > 0)
                {
                    if (value == 0L) { value = CalculateValue(chapter); }
                    if (!Numbers.Compare(value, query.Value, query.ValueComparisonOperator))
                    {
                        return false;
                    }
                }
            }
            else
            {
                if (value == 0L) { value = CalculateValue(chapter); }
                if (!Numbers.IsNumberType(value, query.ValueNumberType))
                {
                    return false;
                }
            }

            if (query.ValueDigitSumNumberType == NumberType.None)
            {
                if (query.ValueDigitSum > 0)
                {
                    if (value == 0L) { value = CalculateValue(chapter); }
                    if (!Numbers.Compare(Numbers.DigitSum(value), query.ValueDigitSum, query.ValueDigitSumComparisonOperator))
                    {
                        return false;
                    }
                }
            }
            else
            {
                if (value == 0L) { value = CalculateValue(chapter); }
                if (!Numbers.IsNumberType(Numbers.DigitSum(value), query.ValueDigitSumNumberType))
                {
                    return false;
                }
            }

            if (query.ValueDigitalRootNumberType == NumberType.None)
            {
                if (query.ValueDigitalRoot > 0)
                {
                    if (value == 0L) { value = CalculateValue(chapter); }
                    if (!Numbers.Compare(Numbers.DigitalRoot(value), query.ValueDigitalRoot, query.ValueDigitalRootComparisonOperator))
                    {
                        return false;
                    }
                }
            }
            else
            {
                if (value == 0L) { value = CalculateValue(chapter); }
                if (!Numbers.IsNumberType(Numbers.DigitalRoot(value), query.ValueDigitalRootNumberType))
                {
                    return false;
                }
            }
        }

        // passed all tests successfully
        return true;
    }
Ejemplo n.º 16
0
 private static List<Word> DoFindWords(Book book, FindScope find_scope, Selection current_selection, List<Verse> previous_result, NumberQuery query)
 {
     List<Verse> source = GetSourceVerses(book, find_scope, current_selection, previous_result);
     return DoFindWords(source, query);
 }
Ejemplo n.º 17
0
    private static bool Compare(List<Chapter> range, NumberQuery query)
    {
        if (range != null)
        {
            int sum = 0;
            long value = 0L;

            if (query.NumberNumberType == NumberType.None)
            {
                if (query.Number > 0)
                {
                    sum = 0;
                    foreach (Chapter chapter in range)
                    {
                        sum += chapter.Number;
                    }
                    if (!Numbers.Compare(sum, query.Number, query.NumberComparisonOperator))
                    {
                        return false;
                    }
                }
            }
            else
            {
                sum = 0;
                foreach (Chapter chapter in range)
                {
                    sum += chapter.Number;
                }
                if (!Numbers.IsNumberType(sum, query.NumberNumberType))
                {
                    return false;
                }
            }

            if (query.VerseCountNumberType == NumberType.None)
            {
                if (query.VerseCount > 0)
                {
                    sum = 0;
                    foreach (Chapter chapter in range)
                    {
                        sum += chapter.Verses.Count;
                    }
                    if (!Numbers.Compare(sum, query.VerseCount, query.VerseCountComparisonOperator))
                    {
                        return false;
                    }
                }
            }
            else
            {
                sum = 0;
                foreach (Chapter chapter in range)
                {
                    sum += chapter.Verses.Count;
                }
                if (!Numbers.IsNumberType(sum, query.VerseCountNumberType))
                {
                    return false;
                }
            }

            if (query.WordCountNumberType == NumberType.None)
            {
                if (query.WordCount > 0)
                {
                    sum = 0;
                    foreach (Chapter chapter in range)
                    {
                        sum += chapter.WordCount;
                    }
                    if (!Numbers.Compare(sum, query.WordCount, query.WordCountComparisonOperator))
                    {
                        return false;
                    }
                }
            }
            else
            {
                sum = 0;
                foreach (Chapter chapter in range)
                {
                    sum += chapter.WordCount;
                }
                if (!Numbers.IsNumberType(sum, query.WordCountNumberType))
                {
                    return false;
                }
            }

            if (query.LetterCountNumberType == NumberType.None)
            {
                if (query.LetterCount > 0)
                {
                    sum = 0;
                    foreach (Chapter chapter in range)
                    {
                        sum += chapter.LetterCount;
                    }
                    if (!Numbers.Compare(sum, query.LetterCount, query.LetterCountComparisonOperator))
                    {
                        return false;
                    }
                }
            }
            else
            {
                sum = 0;
                foreach (Chapter chapter in range)
                {
                    sum += chapter.LetterCount;
                }
                if (!Numbers.IsNumberType(sum, query.LetterCountNumberType))
                {
                    return false;
                }
            }

            if (query.UniqueLetterCountNumberType == NumberType.None)
            {
                if (query.UniqueLetterCount > 0)
                {
                    List<char> unique_letters = new List<char>();
                    foreach (Chapter chapter in range)
                    {
                        foreach (char character in chapter.UniqueLetters)
                        {
                            if (!unique_letters.Contains(character))
                            {
                                unique_letters.Add(character);
                            }
                        }
                    }
                    if (!Numbers.Compare(unique_letters.Count, query.UniqueLetterCount, query.UniqueLetterCountComparisonOperator))
                    {
                        return false;
                    }
                }
            }
            else
            {
                List<char> unique_letters = new List<char>();
                foreach (Chapter chapter in range)
                {
                    foreach (char character in chapter.UniqueLetters)
                    {
                        if (!unique_letters.Contains(character))
                        {
                            unique_letters.Add(character);
                        }
                    }
                }
                if (!Numbers.IsNumberType(unique_letters.Count, query.UniqueLetterCountNumberType))
                {
                    return false;
                }
            }

            if (query.ValueNumberType == NumberType.None)
            {
                if (query.Value > 0)
                {
                    if (value == 0L)
                    {
                        foreach (Chapter chapter in range)
                        {
                            value += CalculateValue(chapter);
                        }
                    }
                    if (!Numbers.Compare(value, query.Value, query.ValueComparisonOperator))
                    {
                        return false;
                    }
                }
            }
            else
            {
                if (value == 0L)
                {
                    foreach (Chapter chapter in range)
                    {
                        value += CalculateValue(chapter);
                    }
                }
                if (!Numbers.IsNumberType(value, query.ValueNumberType))
                {
                    return false;
                }
            }

            if (query.ValueDigitSumNumberType == NumberType.None)
            {
                if (query.ValueDigitSum > 0)
                {
                    if (value == 0L)
                    {
                        foreach (Chapter chapter in range)
                        {
                            value += CalculateValue(chapter);
                        }
                    }
                    if (!Numbers.Compare(Numbers.DigitSum(value), query.ValueDigitSum, query.ValueDigitSumComparisonOperator))
                    {
                        return false;
                    }
                }
            }
            else
            {
                if (value == 0L)
                {
                    foreach (Chapter chapter in range)
                    {
                        value += CalculateValue(chapter);
                    }
                }
                if (!Numbers.IsNumberType(Numbers.DigitSum(value), query.ValueDigitSumNumberType))
                {
                    return false;
                }
            }

            if (query.ValueDigitalRootNumberType == NumberType.None)
            {
                if (query.ValueDigitalRoot > 0)
                {
                    if (value == 0L)
                    {
                        foreach (Chapter chapter in range)
                        {
                            value += CalculateValue(chapter);
                        }
                    }
                    if (!Numbers.Compare(Numbers.DigitalRoot(value), query.ValueDigitalRoot, query.ValueDigitalRootComparisonOperator))
                    {
                        return false;
                    }
                }
            }
            else
            {
                if (value == 0L)
                {
                    foreach (Chapter chapter in range)
                    {
                        value += CalculateValue(chapter);
                    }
                }
                if (!Numbers.IsNumberType(Numbers.DigitalRoot(value), query.ValueDigitalRootNumberType))
                {
                    return false;
                }
            }
        }

        // passed all tests successfully
        return true;
    }
Ejemplo n.º 18
0
 // find by numbers - Words
 public static List<Word> FindWords(Book book, FindScope find_scope, Selection current_selection, List<Verse> previous_result, NumberQuery query)
 {
     return DoFindWords(book, find_scope, current_selection, previous_result, query);
 }
Ejemplo n.º 19
0
    // find by numbers - Chapters
    /// <summary>
    /// Find chapters that meet query criteria.
    /// </summary>
    /// <param name="query"></param>
    /// <returns>Number of found chapters. Result is stored in FoundChapters.</returns>
    public int FindChapters(NumberQuery query)
    {
        m_found_chapters = Server.FindChapters(m_book, m_find_scope, m_selection, m_found_verses, query);
        if (m_found_chapters != null)
        {
            m_found_verses = new List<Verse>();
            foreach (Chapter chapter in m_found_chapters)
            {
                if (chapter != null)
                {
                    m_found_verses.AddRange(chapter.Verses);
                }
            }

            return m_found_chapters.Count;
        }
        return 0;
    }