lib/rbbt/document/corpus/pubmed.rb in rbbt-text-1.3.9 vs lib/rbbt/document/corpus/pubmed.rb in rbbt-text-1.3.10
- old
+ new
@@ -1,11 +1,11 @@
require 'rbbt/sources/pubmed'
module Document::Corpus
PUBMED_NAMESPACE="PMID"
- def add_pmid(pmid, type = nil, update = false)
- type = :abstract if type.nil?
+ def add_pmid(pmid, type = :title_and_abstract, update = false)
+ type = :title_and_abstract if type.nil?
if ! (update || Array === pmid)
id = [PUBMED_NAMESPACE, pmid, type].collect{|e| e.to_s}*":"
documents = self.documents(id)
return documents.first if documents.any?
@@ -14,12 +14,14 @@
pmids = Array === pmid ? pmid : [pmid]
type = nil if String === type and type.empty?
res = PubMed.get_article(pmids).collect do |pmid, article|
document = if type.to_sym == :abstract
- Document.setup(article.abstract || "", PUBMED_NAMESPACE, pmid, :abstract, self, :corpus => self)
+ Document.setup(article.abstract || "", PUBMED_NAMESPACE, pmid, type.to_sym , self, :corpus => self)
elsif type.to_sym == :title
- Document.setup(article.title, PUBMED_NAMESPACE, pmid, :title, self)
+ Document.setup(article.title || "", PUBMED_NAMESPACE, pmid, type.to_sym, self)
+ elsif type.to_sym == :title_and_abstract
+ Document.setup((article.title || "") + "\n\n" + (article.abstract || ""), PUBMED_NAMESPACE, pmid, type.to_sym, self)
else
raise "No FullText available for #{ pmid }" if article.full_text.nil?
Document.setup(article.full_text, PUBMED_NAMESPACE, pmid, :fulltext, self, :corpus => self)
end
Log.debug "Loading pmid #{pmid}"