コード例 #1
0
ファイル: WebIndex.cs プロジェクト: DragonZX/chmprocessor
        public ArrayList Search(SearchWords searchWords)
        {
            // Search documents contaning all words:
            DbCommand cmd     = CreateCommandSinonymous(searchWords.WordSets.Count, searchWords.WordSets);
            ArrayList results = SearchWords(searchWords.WordSets, cmd);

            results.Sort();

            return(results);
        }
コード例 #2
0
ファイル: WebIndex.cs プロジェクト: DragonZX/chmprocessor
        public SearchWords PrepareRealWords(string[] words)
        {
            // Load index language:
            string   language = "";
            IndexCfg cfg      = IndexCfg.Load(cnn);

            if (cfg != null)
            {
                language = cfg.Language.ToLower();
            }

            // Normalize words, see if they are at the index and search synonymous:
            SearchWords synonimous = new SearchWords();

            foreach (string word in words)
            {
                string n = Normalize(word);
                if (!n.Equals(""))
                {
                    ArrayList currentSet = new ArrayList(3);
                    Word      wrd        = Word.Load(cnn, n);
                    if (wrd == null)
                    {
                        currentSet = SearchSynonyms(n, language);
                        if (currentSet.Count == 0)
                        {
                            // Word not found: Exit without results.
                            return(null);
                        }
                    }
                    else
                    {
                        currentSet.Add(wrd);
                        currentSet.AddRange(SearchSynonyms(n, language));
                    }
                    synonimous.WordSets.Add(currentSet);
                }
            }

            if (synonimous.WordSets.Count == 0)
            {
                // Any good search word: Exit without results.
                return(null);
            }

            return(synonimous);
        }
コード例 #3
0
ファイル: Result.cs プロジェクト: DragonZX/chmprocessor
        public string GoogleTextFormat(string textFilesDirectory, SearchWords searchWords)
        {
            string showText = DisplayText(textFilesDirectory);

            showText = BoldSearchedWords(showText, searchWords);

            long   kb   = (long)(Math.Ceiling(((double)DocLenght) / 1024.0)) + 1;
            string text = "<a href=\"" + UrlPath + "\">" + BoldSearchedWords(Description, searchWords) +
                          "</a><br/>" +
                          showText + "<br/><font color=\"green\">" + UrlPath + "</font>";

/*#if DEBUG
 *          text += " - " + NumberOfInstances + " instances";
 #endif*/
            text += "<br/><br/>";
            return(text);
        }
コード例 #4
0
ファイル: Result.cs プロジェクト: DragonZX/chmprocessor
        static private string BoldSearchedWords(string showText, SearchWords searchWords)
        {
            string result = "";

            bool   atWord           = false;
            string currentWord      = "";
            string currentOutOfWord = "";
            int    count            = showText.Length;

            for (int i = 0; i < count; i++)
            {
                char c = WebIndex.Normalize(showText[i]);
                if (WebIndex.GoodChar(c))
                {
                    if (!atWord)
                    {
                        currentWord = "";
                        atWord      = true;
                        result     += HttpUtility.HtmlEncode(currentOutOfWord);
                    }
                    currentWord += c;
                }
                else
                {
                    if (atWord)
                    {
                        currentOutOfWord = "";
                        atWord           = false;
                        result          += FormatSearchWord(currentWord, searchWords);
                    }
                    currentOutOfWord += c;
                }
            }
            if (atWord)
            {
                result += FormatSearchWord(currentWord, searchWords);
            }
            else
            {
                result += HttpUtility.HtmlEncode(currentOutOfWord);
            }

            return(result);
        }
コード例 #5
0
ファイル: Result.cs プロジェクト: DragonZX/chmprocessor
        static private string FormatSearchWord(string currentWord, SearchWords searchWords)
        {
            string currentWordLower = currentWord.ToLower();

            // Check if the word is a search word:

            /*bool searchWord = false;
             * foreach (string word in normalizedWords)
             * {
             *  if (word.Equals(currentWordLower))
             *  {
             *      searchWord = true;
             *      break;
             *  }
             * }*/
            if (!searchWords.Contains(currentWordLower))
            {
                return(HttpUtility.HtmlEncode(currentWord));
            }
            else
            {
                return("<b><u>" + HttpUtility.HtmlEncode(currentWord) + "</u></b>");
            }
        }
コード例 #6
0
ファイル: WebIndex.cs プロジェクト: huoxudong125/chmProcessor
        public ArrayList Search( SearchWords searchWords )
        {
            // Search documents contaning all words:
            DbCommand cmd = CreateCommandSinonymous(searchWords.WordSets.Count, searchWords.WordSets );
            ArrayList results = SearchWords( searchWords.WordSets, cmd);
            results.Sort();

            return results;
        }
コード例 #7
0
ファイル: WebIndex.cs プロジェクト: huoxudong125/chmProcessor
        public SearchWords PrepareRealWords(string[] words)
        {
            // Load index language:
            string language = "";
            IndexCfg cfg = IndexCfg.Load(cnn);
            if (cfg != null)
                language = cfg.Language.ToLower();

            // Normalize words, see if they are at the index and search synonymous:
            SearchWords synonimous = new SearchWords();
            foreach (string word in words)
            {
                string n = Normalize(word);
                if (!n.Equals(""))
                {
                    ArrayList currentSet = new ArrayList(3);
                    Word wrd = Word.Load(cnn, n);
                    if (wrd == null)
                    {
                        currentSet = SearchSynonyms(n, language);
                        if (currentSet.Count == 0)
                            // Word not found: Exit without results.
                            return null;
                    }
                    else
                    {
                        currentSet.Add(wrd);
                        currentSet.AddRange(SearchSynonyms(n, language));
                    }
                    synonimous.WordSets.Add(currentSet);
                }
            }

            if (synonimous.WordSets.Count == 0)
                // Any good search word: Exit without results.
                return null;

            return synonimous;
        }
コード例 #8
0
ファイル: Result.cs プロジェクト: huoxudong125/chmProcessor
        private static string FormatSearchWord(string currentWord, SearchWords searchWords)
        {
            string currentWordLower = currentWord.ToLower();

            // Check if the word is a search word:
            /*bool searchWord = false;
            foreach (string word in normalizedWords)
            {
                if (word.Equals(currentWordLower))
                {
                    searchWord = true;
                    break;
                }
            }*/
            if ( !searchWords.Contains(currentWordLower) )
                return HttpUtility.HtmlEncode(currentWord);
            else
                return "<b><u>" + HttpUtility.HtmlEncode(currentWord) + "</u></b>";
        }
コード例 #9
0
ファイル: Result.cs プロジェクト: huoxudong125/chmProcessor
        private static string BoldSearchedWords(string showText, SearchWords searchWords)
        {
            string result = "";

            bool atWord = false;
            string currentWord = "";
            string currentOutOfWord = "";
            int count = showText.Length;

            for (int i = 0; i < count; i++)
            {
                char c = WebIndex.Normalize( showText[i] );
                if (WebIndex.GoodChar(c))
                {
                    if (!atWord)
                    {
                        currentWord = "";
                        atWord = true;
                        result += HttpUtility.HtmlEncode(currentOutOfWord);
                    }
                    currentWord += c;
                }
                else
                {
                    if (atWord)
                    {
                        currentOutOfWord = "";
                        atWord = false;
                        result += FormatSearchWord(currentWord, searchWords);
                    }
                    currentOutOfWord += c;
                }
            }
            if (atWord)
                result += FormatSearchWord(currentWord, searchWords);
            else
                result += HttpUtility.HtmlEncode(currentOutOfWord);

            return result;
        }
コード例 #10
0
ファイル: Result.cs プロジェクト: huoxudong125/chmProcessor
        public string GoogleTextFormat(string textFilesDirectory, SearchWords searchWords)
        {
            string showText = DisplayText(textFilesDirectory);
            showText = BoldSearchedWords(showText, searchWords);

            long kb = (long)(Math.Ceiling(((double)DocLenght) / 1024.0)) + 1;
            string text = "<a href=\"" + UrlPath + "\">" + BoldSearchedWords(Description, searchWords) +
                "</a><br/>" +
                showText + "<br/><font color=\"green\">" + UrlPath + "</font>";
            /*#if DEBUG
            text += " - " + NumberOfInstances + " instances";
            #endif*/
            text += "<br/><br/>";
            return text;
        }