Astro-Bibcode

 view release on metacpan or  search on metacpan

Bibcode.pm  view on Meta::CPAN

}

=item B<_verify_journalcode>

Check that the journal code looks okay. Returns the code if okay,
false otherwise.

Does not check to see if the journal code can be translated.

Trailing dots are removed from the input string.

=cut

sub _verify_journalcode {
  my $self = shift;
  my $jcode = shift;

  # Clean the string
  $jcode = _clean_string($jcode, 'L');

  # Just make sure we have A-Z and &
  return ( ( $jcode =~ /^[A-Za-z&]+$/) ? $jcode : () );
}

=item B<_verify_volume>

Check that the volume and class are okay.

In scalar context returns the verified string (with leading
dots removed).

  ($class, $volume) = $bib->_verify_volume( $v );
  $v = $bib->_verify_volume($v);

In list context returns two values. First is the classification
flag (blank string for a periodical), second is the volume number
(leasing zeroes removed).

Note that since ADS does not seem to use the classification
code as presented in the reference documentation, this is a bit
of a hack (eg a Thesis would be expected to have class = T but
instead simply uses PhDT in the journal name and not the university).

This means that a blank volume and class are okay and the
class needs to be hacked in higher up.

=cut

sub _verify_volume {
  my $self = shift;
  my $vol = shift;

  # Second character is important so we need to get that before
  # cleaning
  my $second = substr($vol,1,1);


  # Clean the string
  $vol = _clean_string( $vol, 'R' );

  # empty is okay [need to guess later on]
  return (wantarray ? ('', '') : $vol) unless $vol;

  # Get standard classification codes
  my $classes = join( "", keys %CLASS);

  # Get adass codes and form a pattern match string
  my $adsmatch = join("|",keys %CLASS_ADS);

  # Either we are all numbers
  if ($vol =~ /^\d+$/) {
    # periodical. Test calling context
    return (wantarray ? ('',$vol) : $vol );
  } elsif ($vol =~ /([$classes])(\d\d)$/) {
    # We are a classification other than a published journal
    # with multi-volume
    my $c = $1;
    my $num = $2;
    # strip leading zero
    $num =~ s/^0+//g;

    # return the result (checking for context)
    return (wantarray ? ($c, $num) : $vol);

  } elsif ($second =~ /^([$classes])$/) {
    my $class = $1;
    return (wantarray ? ($class, '') : $vol );
  } elsif ($vol =~ /^($adsmatch)$/) {
    return (wantarray ? ($1, '') : $vol);
  }
  # bad code
  return;
}

=item B<_verify_misc>

Verify the misc field which is used to break ambiguity.

 L     letter section in periodical
 p     pink MNRAS pages
 a-z   issue number in same volume
 A-K   issue designations within same volume
 Q-Z   articles on same page
 A-Z   For theses, first initial of author
 E     "ephemeral". These are temporary bibcodes
       submitted prior to publication [ADS-specific]

Fundamentally, any letter matches or a ".".

To be truly accurate the verification requires the 
journal name and classification flag.

=cut

sub _verify_misc {
  my $self = shift;
  my $m = shift;

  # a . is fine
  return "" if $m eq ".";



( run in 0.711 second using v1.01-cache-2.11-cpan-39bf76dae61 )