<commit_before>#
# bio/reference.rb - journal reference class
#
#   Copyright (C) 2001 <NAME> <<EMAIL>>
#
#  This library is free software; you can redistribute it and/or
#  modify it under the terms of the GNU Lesser General Public
#  License as published by the Free Software Foundation; either
#  version 2 of the License, or (at your option) any later version.
#
#  This library is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
#  Lesser General Public License for more details.
#
#  You should have received a copy of the GNU Lesser General Public
#  License along with this library; if not, write to the Free Software
#  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
#
#  $Id: reference.rb,v 1.10 2002/07/03 08:50:08 k Exp $
#

module Bio

  class Reference

    def initialize(hash)
      @authors	= hash['authors']	# [ "<NAME>.", "<NAME>." ]
      @title	= hash['title']		# "Title of the study."
      @journal	= hash['journal']	# "Theor. J. Hoge"
      @volume	= hash['volume']	# 12
      @issue	= hash['issue']		# 3
      @pages	= hash['pages']		# 123-145
      @year	= hash['year']		# 2001
      @pubmed	= hash['pubmed']	# 12345678
      @medline	= hash['medline']	# 98765432
    end
    attr_reader :authors, :title, :journal, :volume, :issue, :pages, :year,
      :pubmed, :medline

    def format(style = nil, option = nil)
      case style
      when /^nature$/i
	return nature(option)
      when /^science$/i
	return science
      when /^genome\s*biology$/i
	return genomebiology
      when /^genome\s*res/i
	return genomeres
      when /^nar$/i
	return nar
      when /^current/i
	return current
      when /^trends/i
	return trends
      when /^cell$/i
	return cell
      when 'bibitem'
	return bibitem(option)
      when 'bibtex'
	return bibtex(option)
      else
	return general
      end
    end

    def bibitem(item = nil)
      item  = "PMID:#{@pubmed}" unless item
      pages = @pages.sub('-', '--')
      return <<-"END".collect {|line| line.strip}.join("\n")
	\\bibitem{#{item}}
	#{@authors.join(', ')}
	#{@title},
	{\\em #{@journal}}, #{@volume}(#{@issue}):#{pages}, #{@year}.
      END
    end

    def bibtex(section = nil)
      section = "article" unless section
      authors = authors_join(' and ')
      pages   = @pages.sub('-', '--')
      return <<-END
	@#{section}{PMID:#{@pubmed},
	  author  = {#{authors}},
	  title   = {#{@title}},
	  journal = {#{@journal}},
	  year    = {#{@year}},
	  volume  = {#{@volume}},
	  number  = {#{@issue}},
	  pages   = {#{pages}},
	}
      END
    end

    def nature(short = false)
      if short
	if @authors.size > 4
	  authors = "#{@authors[0]} et al."
	elsif @authors.size == 1
	  authors = "#{@authors[0]}"<commit_msg>* remove tab in bibtex<commit_after>#
# bio/reference.rb - journal reference class
#
#   Copyright (C) 2001 <NAME> <<EMAIL>>
#
#  This library is free software; you can redistribute it and/or
#  modify it under the terms of the GNU Lesser General Public
#  License as published by the Free Software Foundation; either
#  version 2 of the License, or (at your option) any later version.
#
#  This library is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
#  Lesser General Public License for more details.
#
#  You should have received a copy of the GNU Lesser General Public
#  License along with this library; if not, write to the Free Software
#  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
#
#  $Id: reference.rb,v 1.11 2002/07/23 04:50:07 k Exp $
#

module Bio

  class Reference

    def initialize(hash)
      @authors	= hash['authors']	# [ "<NAME>.", "<NAME>." ]
      @title	= hash['title']		# "Title of the study."
      @journal	= hash['journal']	# "Theor. J. Hoge"
      @volume	= hash['volume']	# 12
      @issue	= hash['issue']		# 3
      @pages	= hash['pages']		# 123-145
      @year	= hash['year']		# 2001
      @pubmed	= hash['pubmed']	# 12345678
      @medline	= hash['medline']	# 98765432
    end
    attr_reader :authors, :title, :journal, :volume, :issue, :pages, :year,
      :pubmed, :medline

    def format(style = nil, option = nil)
      case style
      when /^nature$/i
	return nature(option)
      when /^science$/i
	return science
      when /^genome\s*biology$/i
	return genomebiology
      when /^genome\s*res/i
	return genomeres
      when /^nar$/i
	return nar
      when /^current/i
	return current
      when /^trends/i
	return trends
      when /^cell$/i
	return cell
      when 'bibitem'
	return bibitem(option)
      when 'bibtex'
	return bibtex(option)
      else
	return general
      end
    end

    def bibitem(item = nil)
      item  = "PMID:#{@pubmed}" unless item
      pages = @pages.sub('-', '--')
      return <<-"END".collect {|line| line.strip}.join("\n")
	\\bibitem{#{item}}
	#{@authors.join(', ')}
	#{@title},
	{\\em #{@journal}}, #{@volume}(#{@issue}):#{pages}, #{@year}.
      END
    end

    def bibtex(section = nil)
      section = "article" unless section
      authors = authors_join(' and ')
      pages   = @pages.sub('-', '--')
      return <<-"END".gsub(/\t/, '')
	@#{section}{PMID:#{@pubmed},
	  author  = {#{authors}},
	  title   = {#{@title}},
	  journal = {#{@journal}},
	  year    = {#{@year}},
	  volume  = {#{@volume}},
	  number  = {#{@issue}},
	  pages   = {#{pages}},
	}
      END
    end

    def nature(short = false)
      if short
	if @authors.size > 4
	  authors = "#{@authors[0]} et al."
	elsif @authors.size == 1
	  authors = "#{@authors[0]}"
{'fraction_non_alphanumeric': 0.15159944367176634, 'fraction_numerical': 0.023991655076495134, 'mean_word_length': 2.769986893840105, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2089343', 'n_tokens_mistral': 2090, 'n_tokens_neox': 1911, 'n_words': 613}