Skip to content

Commit

Permalink
Added functions to search in abstracts and titles
Browse files Browse the repository at this point in the history
  • Loading branch information
DASpringate committed Feb 15, 2013
1 parent a74c08a commit fb746fe
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 1 deletion.
14 changes: 13 additions & 1 deletion R/rpubmed_textsearch.R
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,11 @@ mesh_to_text <- function(article){
paste(unlist(get_mesh_headings(article)), collapse = " ")
}

#' concatenates a list of MeSH headings to a single string
title_to_text <- function(article){
paste(unlist(article$MedlineCitation$Article$ArticleTitle), collapse = " ")
}


#' predicate function for presence of a term in an article text
term_in_text_p <- function(term, text, case_sensitive, ...){
Expand Down Expand Up @@ -101,6 +106,13 @@ in_mesh_abstract_p <- function(article, terms, case_sensitive = FALSE, ...){
text = mesh_article, case_sensitive, ...)
}


#' predicate function for searching in title and abstract
in_record_text_p <- function(article, terms, case_sensitive = FALSE, ...){
# Are terms found in the mesh headings?
pattern <- paste(terms, collapse = "|")
mesh_article <- paste(title_to_text(article), abstract_to_text(article))
term_in_text_p(term = pattern,
text = mesh_article, case_sensitive, ...)
}


11 changes: 11 additions & 0 deletions man/in_record_text_p.Rd
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
\name{in_record_text_p}
\alias{in_record_text_p}
\title{predicate function for searching in title and abstract}
\usage{
in_record_text_p(article, terms, case_sensitive = FALSE,
...)
}
\description{
predicate function for searching in title and abstract
}

10 changes: 10 additions & 0 deletions man/title_to_text.Rd
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
\name{title_to_text}
\alias{title_to_text}
\title{concatenates a list of MeSH headings to a single string}
\usage{
title_to_text(article)
}
\description{
concatenates a list of MeSH headings to a single string
}

0 comments on commit fb746fe

Please sign in to comment.