public async Task <List <PubMedArticle> > RetrieveResults()
        {
            var args     = new string[] { "\"RadioFrequency Ablation\"[MeSH Terms]", "\"Back Pain\"[MeSH Terms]", "\"Clinical Trial\"[ptyp]" };
            var articles = await this.RetrieveArticleIds(args);

            var results = new List <PubMedArticle>();

            foreach (var id in articles.Result.IdList)
            {
                try
                {
                    if (results.Count == 10)
                    {
                        break;
                    }

                    var article = await this.RetrieveArticle(id);

                    XmlDocument xmlDoc = new XmlDocument();
                    xmlDoc.LoadXml(article);
                    var text = xmlDoc.GetElementsByTagName("body");

                    if (text == null || text.Count == 0)
                    {
                        continue;
                    }

                    var matches = RegexSearch.GetMatches(text[0].InnerText);

                    if (matches.Any())
                    {
                        if (matches.Last().Length > 500)
                        {
                            continue;
                        }

                        var authors = xmlDoc.GetElementsByTagName("contrib");
                        var author  = authors[0].SelectSingleNode("name").SelectSingleNode("surname").InnerText;

                        var pubDate = xmlDoc.GetElementsByTagName("pub-date")[0].SelectSingleNode("year").InnerText;
                        var result  = new PubMedArticle
                        {
                            Excerpt = matches.Last(),
                            Author  = author,
                            PubYear = pubDate,
                            Id      = id
                        };

                        results.Add(result);
                    }
                }
                catch
                {
                    // we can only request so many articles at a time
                    continue;
                }
            }

            return(results);
        }
        /// <summary>
        /// NGワードコレクションに文字列を追加
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public void Add(string str)
        {
            if (str == null)
            {
                throw new ArgumentNullException("str");
            }
            if (str == String.Empty)
            {
                return;
            }

            foreach (ISearchable a in iSearchers)
            {
                if (a.Pattern == str)
                {
                    return;
                }
            }

            ISearchable s;

            if (str.StartsWith("$"))
            {
                s = new RegexSearch(ParseRegexPattern(str), ParseRegexOptions(str));
            }
            else
            {
                s = new BmSearch2(str);
            }

            iSearchers.Add(s);
        }
Example #3
0
 /// <summary>
 /// Søger efter dimser
 /// </summary>
 /// <param name="searchString">søgestring fra codebehind</param>
 public void SearchForDoohickeys(String searchString)
 {
     SearchDoohickeys.Clear();                                                                  // Listen med søgte brugere nulstilles
     foreach (Doohickey doohickey in RegexSearch.SearchDoohickeys(searchString, DoohickeyList)) // Der tilføjes brugere ifølge Regexsearch
     {
         SearchDoohickeys.Add(doohickey);
     }
 }
        /// <summary>
        /// Replaces all instances of the given Regular Expression in the given range of the <see cref="Scintilla"/> text with the given string.
        /// </summary>
        /// <param name="searchRange"><see cref="CharacterRange"/> in which to search.</param>
        /// <param name="findExpression"><see cref="Regex"/> for which to search.</param>
        /// <param name="replaceString">String to replace any matches. Can be a regular expression pattern.</param>
        /// <param name="mark">Set to true to use the configured margin marker to indicate the lines where matches were found.</param>
        /// <param name="highlight">Set to true to use the configured text indicator to highlight each match.</param>
        /// <returns><see cref="List{CharacterRange}"/> containing the locations of every match. Empty if none were found.</returns>
        public List <CharacterRange> ReplaceAll(CharacterRange searchRange, Regex findExpression, string replaceString, bool mark, bool highlight)
        {
            RegexSearch query = new RegexSearch()
            {
                SearchRange = searchRange, SearchExpression = findExpression
            };

            return(ReplaceAll(query, replaceString, mark, highlight));
        }
        /// <summary>
        /// Searches for all instances of the given Regular Expression in the given range of the <see cref="Scintilla"/> text, and optionally and marks/highlights them.
        /// </summary>
        /// <param name="searchRange"><see cref="CharacterRange"/> in which to search.</param>
        /// <param name="findExpression"><see cref="Regex"/> for which to search.</param>
        /// <param name="mark">Set to true to use the configured margin marker to indicate the lines where matches were found.</param>
        /// <param name="highlight">Set to true to use the configured text indicator to highlight each match.</param>
        /// <returns><see cref="List{CharacterRange}"/> containing the locations of every match. Empty if none were found.</returns>
        public List <CharacterRange> FindAll(CharacterRange searchRange, Regex findExpression, bool mark, bool highlight)
        {
            RegexSearch query = new RegexSearch()
            {
                SearchRange = searchRange, SearchExpression = findExpression
            };

            return(FindAll(query, mark, highlight));
        }
        /// <summary>
        /// Replaces the next instance of the given Regular Expression in the given range of the <see cref="Scintilla"/> text with the given string.
        /// </summary>
        /// <param name="searchRange"><see cref="CharacterRange"/> in which to search.</param>
        /// <param name="findExpression"><see cref="Regex"/> for which to search.</param>
        /// <param name="replaceString">String to replace any matches. Can be a regular expression pattern.</param>
        /// <param name="wrap">Set to true to allow the search to wrap back to the beginning of the text.</param>
        /// <returns><see cref="CharacterRange"/> where the result was found.
        /// <see cref="CharacterRange.cpMin"/> will be the same as <see cref="CharacterRange.cpMax"/> if no match was found.</returns>
        public CharacterRange Replace(CharacterRange searchRange, Regex findExpression, string replaceString, bool wrap)
        {
            RegexSearch query = new RegexSearch()
            {
                SearchRange = searchRange, SearchExpression = findExpression
            };

            UpdateResults(query);
            return(query.Replace(Editor, replaceString, wrap));
        }
        /// <summary>
        /// Searches for the previous instance of the given Regular Expression in the given range of the <see cref="Scintilla"/> text based on the current caret position, optionally wrapping back to the end.
        /// </summary>
        /// <param name="searchRange"><see cref="CharacterRange"/> in which to search.</param>
        /// <param name="findExpression"><see cref="Regex"/> for which to search.</param>
        /// <param name="wrap">Set to true to allow the search to wrap back to the end of the text.</param>
        /// <returns><see cref="CharacterRange"/> where the result was found.
        /// <see cref="CharacterRange.cpMin"/> will be the same as <see cref="CharacterRange.cpMax"/> if no match was found.</returns>
        public CharacterRange FindPrevious(CharacterRange searchRange, Regex findExpression, bool wrap)
        {
            RegexSearch query = new RegexSearch()
            {
                SearchRange = searchRange, SearchExpression = findExpression
            };

            UpdateResults(query);
            return(query.FindPrevious(Editor, wrap));
        }
        /// <summary>
        /// Searches for the first or last instance of the given Regular Expression in the given range of the <see cref="Scintilla"/> text.
        /// </summary>
        /// <param name="searchRange"><see cref="CharacterRange"/> in which to search.</param>
        /// <param name="findExpression"><see cref="Regex"/> for which to search.</param>
        /// <param name="searchUp">Search direction. Set to true to search from the bottom up.</param>
        /// <returns><see cref="CharacterRange"/> where the result was found.
        /// <see cref="CharacterRange.cpMin"/> will be the same as <see cref="CharacterRange.cpMax"/> if no match was found.</returns>
        public CharacterRange Find(CharacterRange searchRange, Regex findExpression, bool searchUp)
        {
            RegexSearch query = new RegexSearch {
                SearchRange      = searchRange,
                SearchExpression = findExpression,
                SearchUp         = searchUp
            };

            return(query.Find(Editor));
        }
Example #9
0
 /// <summary>
 /// Søger efter brugere
 /// </summary>
 /// <param name="searchString">Søgestring fra code behind</param>
 public void SearchForUsers(String searchString)
 {
     SearchUsers.Clear();                                                   // Listen med søgte brugere nulstilles
     foreach (User user in RegexSearch.SearchUsers(searchString, UserList)) // Der tilføjes brugere ifølge Regexsearch
     {
         if (!user.Equals(CurrentUser))
         {
             SearchUsers.Add(user);
         }
     }
 }
        private string GetRegexPattern(RegexSearch s)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append("$").Append(s.Pattern);

            // オプションが設定されている場合
            if (s.Regex.Options != RegexOptions.None)
            {
                sb.Append('\t');
                sb.Append(s.Regex.Options.ToString());
            }
            return(sb.ToString());
        }
Example #11
0
 internal RegexPattern(string pattern)
 {
     Pattern = pattern;
     Regex   = new RegexSearch(pattern);
 }
        public int ExtractIntUsingCompiledRegex(string input)
        {
            var number = RegexSearch.Number(input);

            return(int.Parse(number));
        }