| 1 |
package Biblio::Citation::Parser::Jiao; |
| 2 |
|
| 3 |
###################################################################### |
| 4 |
# |
| 5 |
# Biblio::Citation::Parser::Jiao; |
| 6 |
# |
| 7 |
###################################################################### |
| 8 |
# |
| 9 |
# This file is part of ParaCite Tools (http://paracite.eprints.org/developers/) |
| 10 |
# Based on Zhuoan Jiao's ([email protected]) citation parser (available |
| 11 |
# at http://arabica.ecs.soton.ac.uk/code/doc/ReadMe.html) |
| 12 |
# |
| 13 |
# The code is relatively unchanged, except to bring into compliance |
| 14 |
# with the ParaCite metadata style, and to allow interoperability with |
| 15 |
# the other parsers. |
| 16 |
# |
| 17 |
# Copyright (c) 2004 University of Southampton, UK. SO17 1BJ. |
| 18 |
# |
| 19 |
# ParaTools is free software; you can redistribute it and/or modify |
| 20 |
# it under the terms of the GNU General Public License as published by |
| 21 |
# the Free Software Foundation; either version 2 of the License, or |
| 22 |
# (at your option) any later version. |
| 23 |
# |
| 24 |
# ParaTools is distributed in the hope that it will be useful, |
| 25 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 26 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 27 |
# GNU General Public License for more details. |
| 28 |
# |
| 29 |
# You should have received a copy of the GNU General Public License |
| 30 |
# along with ParaTools; if not, write to the Free Software |
| 31 |
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 32 |
# |
| 33 |
###################################################################### |
| 34 |
|
| 35 |
use strict; |
| 36 |
use vars qw(@ISA @EXPORT @EXPORT_OK); |
| 37 |
# This provides various utility functions. |
| 38 |
use Biblio::Citation::Parser::Jiao::Utility; |
| 39 |
use Biblio::Citation::Parser::Utils; |
| 40 |
|
| 41 |
require Exporter; |
| 42 |
@ISA = ("Exporter", "Biblio::Citation::Parser"); |
| 43 |
our @EXPORT_OK = ( 'parse', 'new' ); |
| 44 |
|
| 45 |
|
| 46 |
=pod |
| 47 |
|
| 48 |
=head1 NAME |
| 49 |
|
| 50 |
B<Biblio::Citation::Parser::Jiao> - citation parsing using Zhuoan Jiao's |
| 51 |
parsing module. |
| 52 |
|
| 53 |
|
| 54 |
=head1 SYNOPSIS |
| 55 |
|
| 56 |
use Biblio::Citation::Parser::Jiao; |
| 57 |
# Parse a simple reference |
| 58 |
$parser = new Biblio::Citation::Parser::Jiao; |
| 59 |
$metadata = $parser->parse("M. Jewell (2002) Citation Parsing for Beginners. Journal of Madeup References 4(3)."); |
| 60 |
print "The title of this article is ".$metadata->{atitle}."\n"; |
| 61 |
|
| 62 |
=head1 DESCRIPTION |
| 63 |
|
| 64 |
Biblio::Citation::Parser::Jiao uses a reference parsing module written by |
| 65 |
Zhuoan Jiao ([email protected]). This is a good module to use if titles are not required (if they are in double-quotes they will be picked up, however). |
| 66 |
|
| 67 |
For more information see: |
| 68 |
http://arabica.ecs.soton.ac.uk/code/doc/ref/Parser/about_Citation_module.html |
| 69 |
|
| 70 |
The module has been repackaged to comply with the ParaCite metadata style |
| 71 |
and uses the Citation parser interface to preserve interoperability with the other |
| 72 |
modules. |
| 73 |
|
| 74 |
=head1 METHODS |
| 75 |
|
| 76 |
=over 4 |
| 77 |
|
| 78 |
=item $parser = Biblio::Citation::Parser::Jiao-E<gt>new() |
| 79 |
|
| 80 |
The new() method creates a new parser. |
| 81 |
|
| 82 |
=cut |
| 83 |
|
| 84 |
sub new { |
| 85 |
my $class = shift; |
| 86 |
my $cite = {}; |
| 87 |
bless $cite, $class; |
| 88 |
} |
| 89 |
|
| 90 |
=pod |
| 91 |
|
| 92 |
=item $metadata = $parser-E<gt>parse($reference, [$notrim]); |
| 93 |
|
| 94 |
This method provides a wrapper to the functions within the Jiao module that carry out the parsing. Simply pass a reference string, and a metadata hash is returned. Note that this is trimmed to comply to OpenURL standards (thus removing some information that you may wish to keep). To prevent this from occurring, ensure that $notrim is non-zero. |
| 95 |
|
| 96 |
=cut |
| 97 |
|
| 98 |
sub parse |
| 99 |
{ |
| 100 |
my($self, $ref, $notrim) = @_; |
| 101 |
my $cite = {}; |
| 102 |
bless $cite, "Biblio::Citation::Parser::Jiao"; |
| 103 |
$cite->initialize($ref); |
| 104 |
$cite->{auinit} = $cite->{aufirst}; |
| 105 |
$cite->{date} = $cite->{year}; |
| 106 |
$cite = _debless($cite); |
| 107 |
my $metadata = ($notrim ? $cite : trim_openurl($cite)); |
| 108 |
|
| 109 |
return $metadata; |
| 110 |
} |
| 111 |
|
| 112 |
sub _debless |
| 113 |
{ |
| 114 |
my($hash) = @_; |
| 115 |
my $out = {}; |
| 116 |
foreach(keys %$hash) |
| 117 |
{ |
| 118 |
$out->{$_} = $hash->{$_}; |
| 119 |
} |
| 120 |
return $out; |
| 121 |
} |
| 122 |
|
| 123 |
sub initialize { |
| 124 |
my $cite = shift; |
| 125 |
my $text = shift || return; |
| 126 |
$cite->{'text'} = $text; |
| 127 |
$cite->{'rest_text'} = $cite->{'text'}; |
| 128 |
|
| 129 |
$cite->{'aufull'} = ''; |
| 130 |
$cite->{'aulast'} = ''; |
| 131 |
$cite->{'aufirst'}= ''; |
| 132 |
$cite->{'authors'}= ''; |
| 133 |
$cite->{'atitle'} = ''; |
| 134 |
$cite->{'title'} = ''; |
| 135 |
$cite->{'volume'} = ''; |
| 136 |
$cite->{'issue'} = ''; |
| 137 |
$cite->{'supl'} = ''; |
| 138 |
$cite->{'spage'} = ''; |
| 139 |
$cite->{'year'} = ''; |
| 140 |
$cite->{'targetURL'} = ''; |
| 141 |
|
| 142 |
$cite->{'featureID'} = ''; |
| 143 |
$cite->{'jnl_spos'} = 0; |
| 144 |
$cite->{'jnl_epos'} = 0; |
| 145 |
$cite->{'num_of_fig'}= 0; |
| 146 |
|
| 147 |
$cite->find_metadata(); |
| 148 |
$cite->find_featureID(); |
| 149 |
} |
| 150 |
|
| 151 |
# |
| 152 |
# Actions |
| 153 |
# |
| 154 |
sub pre_process { |
| 155 |
my $cite = shift; |
| 156 |
my $Text = $cite->{'text'}; |
| 157 |
|
| 158 |
$Text = normalisation($Text); |
| 159 |
$Text = normalise_date($Text); |
| 160 |
$Text = normalise_html($Text); |
| 161 |
# remove front label to get accurate $nFig |
| 162 |
# (Note: do not perform this for arXiv ref. like: "46(4), 90 (1993)") |
| 163 |
# [Smith, 1998], [1], (1), (1a) ... |
| 164 |
$Text =~ s/^\s*[\[(]\s* # bracket |
| 165 |
([^\])]+?)\s* # content |
| 166 |
[\])]\s*//x; # bracket |
| 167 |
|
| 168 |
# "1. Gary Smith, ...." |
| 169 |
$Text =~ s/^\d+\s*\.\s+//; |
| 170 |
# "1 Gary Smith, ...." |
| 171 |
$Text =~ s/^\s*\d+ ([A-Z])/$1/; |
| 172 |
# "2) Brand, P. ..." |
| 173 |
$Text =~ s/^[\[\(]?\s*\w+\s*[\])]\s*//; |
| 174 |
|
| 175 |
$cite->{'rest_text'} = $Text; |
| 176 |
|
| 177 |
my $nFig = num_of_figures($Text); |
| 178 |
$cite->{'num_of_fig'} = $nFig; |
| 179 |
} |
| 180 |
|
| 181 |
sub find_metadata { |
| 182 |
my $cite = shift; |
| 183 |
|
| 184 |
return 0 if (!defined($cite->{'text'})); |
| 185 |
$cite->pre_process(); |
| 186 |
|
| 187 |
# find URL |
| 188 |
$cite->find_url(); |
| 189 |
|
| 190 |
my $nFig = $cite->{'num_of_fig'}; |
| 191 |
|
| 192 |
# find the authors |
| 193 |
if ($cite->find_authors()) { |
| 194 |
$cite->find_first_author() |
| 195 |
}; |
| 196 |
|
| 197 |
# find article titile |
| 198 |
$cite->find_atitle(); |
| 199 |
|
| 200 |
# only process references to 'journal' articles. |
| 201 |
return 0 if ($nFig == 0) ; # no number, ignore. |
| 202 |
return 0 if ($nFig >= 8); # too many numbers, maybe an error, ignore. |
| 203 |
# return 0 if ($cite->{'rest_text'} =~ /\W(proc.|proceedings) of /i); |
| 204 |
|
| 205 |
# extract 'supplement' first before find_vol_no_pg_year() |
| 206 |
$cite->find_supplement(); |
| 207 |
|
| 208 |
if ($cite->find_vol_no_pg_year() or |
| 209 |
$cite->find_vol_pg_year()) { |
| 210 |
|
| 211 |
$cite->find_jnl_name(); |
| 212 |
return 1 |
| 213 |
}; |
| 214 |
|
| 215 |
if ($cite->guess_vol_no_pg()) { |
| 216 |
$cite->find_jnl_name(); |
| 217 |
return 1; |
| 218 |
}; |
| 219 |
|
| 220 |
if ($cite->find_vol_no() or |
| 221 |
$cite->find_vol_supl()) { |
| 222 |
|
| 223 |
$cite->find_jnl_name(); |
| 224 |
$cite->find_page(); |
| 225 |
$cite->find_year(); |
| 226 |
|
| 227 |
return 1; |
| 228 |
}; |
| 229 |
|
| 230 |
if ($cite->guess_vol_pg()) { |
| 231 |
$cite->find_year(); |
| 232 |
$cite->find_jnl_name(); |
| 233 |
|
| 234 |
return 1; |
| 235 |
}; |
| 236 |
|
| 237 |
if ($cite->guess_vol_year()) { |
| 238 |
|
| 239 |
$cite->find_page(); |
| 240 |
$cite->find_jnl_name(); |
| 241 |
|
| 242 |
return 1; |
| 243 |
}; |
| 244 |
|
| 245 |
my $Count = 0; |
| 246 |
$Count++ if ($cite->find_vol()); |
| 247 |
$Count++ if ($cite->find_issue()); |
| 248 |
$Count++ if ($cite->find_supplement()); |
| 249 |
$Count++ if ($cite->find_jnl_name()); |
| 250 |
$Count++ if ($cite->find_page()); |
| 251 |
$Count++ if ($cite->find_year()); |
| 252 |
|
| 253 |
return 1 if ($Count >=2 ); |
| 254 |
|
| 255 |
# too few metadata |
| 256 |
return 0 |
| 257 |
} |
| 258 |
|
| 259 |
sub find_atitle { |
| 260 |
my $cite = shift; |
| 261 |
my $Text = $cite->{'rest_text'}; |
| 262 |
|
| 263 |
# title is quoted. |
| 264 |
# return 0 if ($Text !~ /(['"])/); # |
| 265 |
# my $Qt = $1; |
| 266 |
# ignore ' case, because author nams may contain ', e.g. |
| 267 |
# A. I. L'vov, V. A. Petrun'kin, and M. Schumacher, |
| 268 |
# Phys. Rev. C 55, 359 (1997) |
| 269 |
return 0 if ($Text !~ /"/); |
| 270 |
|
| 271 |
if ($Text =~ /"(.+?)"\s*\.?/ and |
| 272 |
word_count($1) >= 2) { |
| 273 |
my $Guess_title = $1; |
| 274 |
return 0 if ($Guess_title =~ /^http:/i); |
| 275 |
|
| 276 |
$cite->{'atitle'} = $Guess_title; |
| 277 |
# use ';' ! |
| 278 |
# $Text =~ s/$Qt(.+?)$Qt\s*\.?/;/o; |
| 279 |
# $Text =~ s/"[^"]+"\s*\.?/;/; |
| 280 |
$Text =~ s/"[^"]+"/" "/; |
| 281 |
# $Text =~ s/[,;.]\s*[,;.]/,/g; # doesn't work |
| 282 |
while ($Text =~ /[,;.]\s*[,;.]/g) { |
| 283 |
$Text =~ s/[,;.]\s*[,;.]/,/ |
| 284 |
}; |
| 285 |
$Text =~ s/^[;" ]+//; |
| 286 |
$cite->{'rest_text'} = $Text; |
| 287 |
return 1 |
| 288 |
}; |
| 289 |
|
| 290 |
return 0 |
| 291 |
} |
| 292 |
|
| 293 |
# for the OpCit Project . |
| 294 |
sub find_featureID { |
| 295 |
my $cite = shift; |
| 296 |
|
| 297 |
my $featureID = ''; |
| 298 |
$featureID .= "v$cite->{'volume'}" if ($cite->{'volume'}); |
| 299 |
$featureID .= ":n$cite->{'issue'}" if ($cite->{'issue'}); |
| 300 |
$featureID .= ":s$cite->{'supl'}" if ($cite->{'supl'}); |
| 301 |
$featureID .= ":p$cite->{'spage'}" if ($cite->{'spage'}); |
| 302 |
$featureID .= ":y$cite->{'year'}" if ($cite->{'year'}); |
| 303 |
|
| 304 |
# tidy up |
| 305 |
# $featureID =~ s/:[nsp]\s*:/:/g; # doesn't work. |
| 306 |
while ($featureID =~ /:[nsp]\s*:/g) { |
| 307 |
$featureID =~ s/:[nsp]\s*:/:/ |
| 308 |
}; |
| 309 |
$featureID =~ s/^://; |
| 310 |
$featureID =~ s/\s+//g; |
| 311 |
|
| 312 |
my @Features = split(':', $featureID); |
| 313 |
|
| 314 |
# ignore those having too few metadata |
| 315 |
if (scalar(@Features) >= 2) { |
| 316 |
# standardize |
| 317 |
$featureID = lc($featureID); |
| 318 |
$cite->{'featureID'} = $featureID; |
| 319 |
}; |
| 320 |
} |
| 321 |
|
| 322 |
|
| 323 |
sub find_authors { |
| 324 |
my $cite = shift; |
| 325 |
my $Text = $cite->{'rest_text'}; |
| 326 |
|
| 327 |
my $aText = locate_authors($Text); |
| 328 |
return 0 if ($aText eq '' or $aText =~ /^\W+$/); |
| 329 |
|
| 330 |
my @Chunks = (); |
| 331 |
@Chunks = split(/\s*[,;:]\s*/, $aText); |
| 332 |
|
| 333 |
# ignore text longer than 4 words (don't count initials) |
| 334 |
return 0 if (word_count($Chunks[0])>4 and no_initials($Chunks[0])); |
| 335 |
|
| 336 |
my($author, $Authors) = ('',''); |
| 337 |
while (@Chunks) { |
| 338 |
if (scalar(@Chunks)==1) { |
| 339 |
last if !full_name($Chunks[0]); |
| 340 |
$author = normalise_name($Chunks[0]); |
| 341 |
$Authors = "$Authors:$author"; |
| 342 |
last |
| 343 |
}; |
| 344 |
|
| 345 |
|
| 346 |
# (1) forename and surname are not separated by [,;]. |
| 347 |
if (full_name($Chunks[0])){ |
| 348 |
if ($Chunks[1] =~ /^\s*Jr\.?\s*$/i) { |
| 349 |
$author = "$Chunks[0], $Chunks[1]"; |
| 350 |
$author = normalise_name($author); |
| 351 |
$Authors = "$Authors:$author"; |
| 352 |
splice(@Chunks, 0, 2); # remove the first two |
| 353 |
next |
| 354 |
} |
| 355 |
elsif (!only_initials($Chunks[1])) { |
| 356 |
$author = normalise_name($Chunks[0]); |
| 357 |
$Authors = "$Authors:$author"; |
| 358 |
shift(@Chunks); |
| 359 |
next |
| 360 |
} |
| 361 |
} |
| 362 |
elsif (full_name($Chunks[1])) { |
| 363 |
# $Chunks[0] is not a name, skip. |
| 364 |
shift @Chunks; |
| 365 |
next |
| 366 |
}; |
| 367 |
|
| 368 |
# (2) forename and surname are separated by [,;]. |
| 369 |
# Ignore text containing too many words. |
| 370 |
my $aFull = "$Chunks[0] $Chunks[1]"; |
| 371 |
my @abbr = (); |
| 372 |
last if (word_count($aFull) > 4); |
| 373 |
last if ($aFull =~ /[\d\/]+/); |
| 374 |
|
| 375 |
# journal title maybe mixed up with the name |
| 376 |
last if (@abbr = ($aFull =~ /\w\w\./g) and (@abbr >= 2)); |
| 377 |
|
| 378 |
# surname first. |
| 379 |
# "Oemler, A., Jr. and Lynds, C. R. 1975, ApJ, 199, 558" |
| 380 |
if (scalar(@Chunks) > 2) { |
| 381 |
if (is_surname($Chunks[0]) and |
| 382 |
has_initials($Chunks[1]) and |
| 383 |
$Chunks[2] =~ /^\s*Jr\.?\s*$/i) { |
| 384 |
$author = "$Chunks[1] $Chunks[0], Jr"; |
| 385 |
$author = normalise_name($author); |
| 386 |
$Authors = "$Authors:$author"; |
| 387 |
splice(@Chunks, 0, 3); # remove the first three |
| 388 |
next |
| 389 |
}; |
| 390 |
}; |
| 391 |
|
| 392 |
# surname first |
| 393 |
# "Reisenegger, A. and Miralda-Escude, J. 1995, ApJ, 449, 476 |
| 394 |
if (is_surname($Chunks[0]) and |
| 395 |
has_initials($Chunks[1])) { |
| 396 |
if ($Chunks[1] =~ /(.+?\.?)\s*Jr\.?\s*$/i){ |
| 397 |
$author = "$1 $Chunks[0], Jr"; |
| 398 |
} |
| 399 |
else |
| 400 |
{ |
| 401 |
$author = "$Chunks[1] $Chunks[0]"; |
| 402 |
}; |
| 403 |
$author = normalise_name($author); |
| 404 |
$Authors = "$Authors:$author"; |
| 405 |
splice(@Chunks, 0, 2); # remove the first two |
| 406 |
next |
| 407 |
}; |
| 408 |
|
| 409 |
# forename first |
| 410 |
if (only_initials($Chunks[0]) and |
| 411 |
is_surname($Chunks[1])) { |
| 412 |
if ($Chunks[0] =~ /(.+?[. ])\s*Jr\.?\s*$/i){ |
| 413 |
$author = "$1 $Chunks[1], Jr"; |
| 414 |
} |
| 415 |
else |
| 416 |
{ |
| 417 |
$author = $aFull |
| 418 |
}; |
| 419 |
$author = normalise_name($author); |
| 420 |
$Authors = "$Authors:$author"; |
| 421 |
splice(@Chunks, 0, 2); # remove the first two |
| 422 |
next |
| 423 |
}; |
| 424 |
|
| 425 |
# 'Liu, Gong', hard to tell which is the surname; |
| 426 |
if (no_initials($Chunks[0]) and |
| 427 |
no_initials($Chunks[1])) { |
| 428 |
if (word_count($aFull) <= 4 ) { |
| 429 |
$author = normalise_name($aFull); |
| 430 |
$Authors = "$Authors:$author"; |
| 431 |
splice(@Chunks, 0, 2); # remove the first two |
| 432 |
next |
| 433 |
} |
| 434 |
}; |
| 435 |
|
| 436 |
# cannot determin the author name |
| 437 |
last |
| 438 |
|
| 439 |
}; # end of while |
| 440 |
|
| 441 |
return 0 if ($Authors eq ''); |
| 442 |
$Authors =~ s/^://; |
| 443 |
$cite->{'authors'} = $Authors; |
| 444 |
} |
| 445 |
|
| 446 |
sub find_first_author { |
| 447 |
my $cite = shift; |
| 448 |
|
| 449 |
return 0 if ($cite->{'authors'} eq ''); |
| 450 |
|
| 451 |
my @Authors = split(':', $cite->{'authors'}); |
| 452 |
$cite->{'aufull'} = shift @Authors; |
| 453 |
if ($cite->{'aufull'} =~ /./) |
| 454 |
{ |
| 455 |
($cite->{'aufirst'}, $cite->{'aulast'}) = ($cite->{'aufull'} =~ /^(.+)\.(.+)$/); |
| 456 |
} |
| 457 |
else |
| 458 |
{ |
| 459 |
($cite->{'aufirst'}, $cite->{'aulast'}) = ($cite->{'aufull'} =~ /^(.+)\s+(.+)$/); |
| 460 |
} |
| 461 |
|
| 462 |
} |
| 463 |
|
| 464 |
|
| 465 |
# locate_authors |
| 466 |
sub locate_authors { |
| 467 |
my $Text = shift; |
| 468 |
|
| 469 |
$Text =~ s/^\s*For .*?review(s)?\W+//i; |
| 470 |
$Text =~ s/^\s*(see )?also //i; |
| 471 |
$Text =~ s/^\s*see[, ]\s*for example\W+//i; |
| 472 |
$Text =~ s/^\s*see e\.g\.\W+//i; |
| 473 |
my $aText = $Text; |
| 474 |
|
| 475 |
# author name(s) is assumed to be in front of a consecutive |
| 476 |
# 4 words, e.g. J. A. Harvey. String Duality and Non-supersymmetric |
| 477 |
# Strings. |
| 478 |
# if ($Text =~ /\b([\w\-'`"]+\s+){3,}[\w\-'"]+\b/){ |
| 479 |
if ($Text =~ /\.\s+([\w\-'`"]+\s+){3,}[\w\-'"]{2,}\b/){ |
| 480 |
$aText = $`; |
| 481 |
}; |
| 482 |
|
| 483 |
if ($Text =~ /[,;]\s*([\w\-'`"]{2,}\s+){3,}[\w\-'"]{2,}\b/) { |
| 484 |
$aText = $`; |
| 485 |
}; |
| 486 |
# the above has truncated too much. |
| 487 |
# "S. Popescu and Sudbery G. A. Multi-particle entanglement ..." |
| 488 |
if (only_initials($aText)) { |
| 489 |
$aText = $Text |
| 490 |
}; |
| 491 |
|
| 492 |
if ($aText =~ /[,:; ]\s*[a-z][\w\-'"]*\s+([a-z0-9\-'"]+\s+)*?[a-z0-9\-'"]{4,}(\b|$)/) { # "[6] M.Gotay, Constraints, reduction and quantization, |
| 493 |
# J. Math. Phys. (1986) 2051. |
| 494 |
$aText = $`; |
| 495 |
}; |
| 496 |
|
| 497 |
# Or before the following sybmols. |
| 498 |
# if ($aText =~ /["\[\(]/) { |
| 499 |
if ($aText =~ /[:"\[\(]/) { |
| 500 |
$aText = $` |
| 501 |
}; |
| 502 |
|
| 503 |
|
| 504 |
# before '/', e.g. "Halzen F. astro-ph/0001001" |
| 505 |
if ($aText =~ /\S+\//) { |
| 506 |
$aText = $` |
| 507 |
}; |
| 508 |
|
| 509 |
# before any number |
| 510 |
if ($aText =~ /\d+/i) { |
| 511 |
$aText = $` |
| 512 |
}; |
| 513 |
|
| 514 |
# "14. A. J. Leggett, in Percolation, Localization and ..." |
| 515 |
if ($aText =~ /[,;: ]\s*in /i) { |
| 516 |
$aText = $` |
| 517 |
}; |
| 518 |
|
| 519 |
# last author name after 'and'. |
| 520 |
if ($aText =~ /[,; ]\s*and ([^,;:]+)[,:;]([^,;:]+)/i) { |
| 521 |
my $Aft1 = $1; |
| 522 |
my $Aft2 = $2; |
| 523 |
if (full_name($Aft1)) { |
| 524 |
$aText = $` .", $Aft1"; |
| 525 |
} else { |
| 526 |
$aText = $` .", $Aft1, $Aft2" |
| 527 |
} |
| 528 |
}; |
| 529 |
|
| 530 |
# |
| 531 |
# tidy up |
| 532 |
# |
| 533 |
# remove non-alphabets |
| 534 |
$aText =~ s/^[^a-z]+//i; |
| 535 |
$aText =~ s/^by //i; |
| 536 |
$aText =~ s/[,; ]+and /,/i; |
| 537 |
$aText =~ s/[,; ]+et\.?\s+al\.?([,; ]+|$)/,et al,/i; |
| 538 |
#$aText =~ s/[,;:.]+\s*$//; |
| 539 |
$aText =~ s/[,;:]+\s*$//; |
| 540 |
|
| 541 |
return $aText |
| 542 |
}; |
| 543 |
|
| 544 |
# This subroutine needs re-written; not in use now. |
| 545 |
sub locate_book { |
| 546 |
my $cite = shift; |
| 547 |
my $Text = $cite->{'rest_text'}; |
| 548 |
|
| 549 |
if ($Text =~ /\W+in\s+(.+?)\W+(ed|eds|edited)\.?(\W|$)/) { |
| 550 |
$$cite{book} = $1; |
| 551 |
return 1 |
| 552 |
}; |
| 553 |
return 0 |
| 554 |
|
| 555 |
} |
| 556 |
|
| 557 |
sub find_vol_no { |
| 558 |
my $cite = shift; |
| 559 |
my $Text = $cite->{'rest_text'}; |
| 560 |
|
| 561 |
if ($Text =~ s/[,;. ]\s*(?:volume|vol|v)?\.?\s*(\d+)\s*[ ,;]\s*(?:n|no|issue|\#)\.?\s*(\d+)\b/$1/is) { |
| 562 |
|
| 563 |
$cite->{'volume'} = $2; |
| 564 |
$cite->{'issue'} = $3; |
| 565 |
$cite->{'jnl_epos'} = length($`); |
| 566 |
$cite->{'rest_text'} = $Text; |
| 567 |
return 1 |
| 568 |
} |
| 569 |
else { return 0} |
| 570 |
} |
| 571 |
|
| 572 |
sub find_vol_supl { |
| 573 |
my $cite = shift; |
| 574 |
my $Text = $cite->{'rest_text'}; |
| 575 |
|
| 576 |
if ($Text =~ s/(\s|,|;|\.)\s*(?:volume|vol|v)?\.?\s*(\d+)\s*[\s,;]\s*(?:supl|supplement)\.?\s*(\d+)\b/$1/is) { |
| 577 |
|
| 578 |
$cite->{'volume'} = $2; |
| 579 |
$cite->{'supl'} = $3; |
| 580 |
$cite->{'jnl_epos'} = length($`); |
| 581 |
$cite->{'rest_text'} = $Text; |
| 582 |
} |
| 583 |
} |
| 584 |
|
| 585 |
|
| 586 |
sub find_vol { |
| 587 |
my $cite = shift; |
| 588 |
my $Text = $cite->{'rest_text'}; |
| 589 |
|
| 590 |
if ($Text =~ s/[,;:. ]\s*(?:volume|vol)[. ]\s*([a-z]*\d+[a-z]*)\b//i) { |
| 591 |
$cite->{'volume'} = $1; |
| 592 |
$cite->{'rest_text'} = $Text; |
| 593 |
return |
| 594 |
}; |
| 595 |
|
| 596 |
# "..., Vol9 ..." |
| 597 |
if ($Text =~ s/[,;:. ]\s*(?:volume|vol)(\d+[a-z]*)\b//i) { |
| 598 |
$cite->{'volume'} = $1; |
| 599 |
$cite->{'rest_text'} = $Text; |
| 600 |
return |
| 601 |
}; |
| 602 |
|
| 603 |
if ($Text =~ s/[,;:. ]\s*(?:volume|vol)(\d+[a-z]*)\b//i) { |
| 604 |
$cite->{'volume'} = $1; |
| 605 |
$cite->{'rest_text'} = $Text; |
| 606 |
return |
| 607 |
}; |
| 608 |
|
| 609 |
# beware: "Smith, V. 1990, Phys. Rev. A. v. 10 ..." |
| 610 |
while ($Text =~ /[,;. ]\s*V\s*[. ]\s*([a-z]*\d+[a-z]*)\b/ig){ |
| 611 |
my $Guess_vol = $1; |
| 612 |
next if ($Guess_vol =~ /(19|20)\d\d/); |
| 613 |
|
| 614 |
$cite->{'volume'} = $Guess_vol; |
| 615 |
$Text =~ s/[,;. ]\s*V\s*[. ]\s*[a-z]*\d+[a-z]\b//i; |
| 616 |
$cite->{'rest_text'} = $Text; |
| 617 |
return |
| 618 |
}; |
| 619 |
|
| 620 |
# "... v10, ..." |
| 621 |
if ($Text =~ s/[,;:. ]\s*V(\d+[a-z]*)\b//i) { |
| 622 |
$cite->{'volume'} = $1; |
| 623 |
$cite->{'rest_text'} = $Text; |
| 624 |
return |
| 625 |
}; |
| 626 |
} |
| 627 |
|
| 628 |
sub find_issue { |
| 629 |
my $cite = shift; |
| 630 |
my $Text = $cite->{'rest_text'}; |
| 631 |
|
| 632 |
if ($Text =~ s/[,;:. ]\s*(?:number|issue|num|no|Nr|\#)[. ]\s*([a-z]*\d+[a-z]*)\b//i) { |
| 633 |
$cite->{'issue'} = $1; |
| 634 |
$cite->{'rest_text'} = $Text; |
| 635 |
return |
| 636 |
}; |
| 637 |
|
| 638 |
# e.g. " ...No10, ..." |
| 639 |
if ($Text =~ s/[,;:. ]\s*(?:number|issue|num|no|Nr)(\d+[a-z]*)\b//i) { |
| 640 |
$cite->{'issue'} = $1; |
| 641 |
$cite->{'rest_text'} = $Text; |
| 642 |
return |
| 643 |
}; |
| 644 |
|
| 645 |
while ($Text =~ /[,;:. ]\s*N\s*[. ]\s*([a-z]*\d+[a-z]*)\b/ig){ |
| 646 |
my $Guess_issue = $1; |
| 647 |
next if ($Guess_issue =~ /(19|20)\d\d/); |
| 648 |
|
| 649 |
$cite->{'issue'} = $Guess_issue; |
| 650 |
$Text =~ s/[,;. ]\s*N\s*[. ]\s*[a-z]*\d+[a-z]*\b//i; |
| 651 |
return |
| 652 |
}; |
| 653 |
|
| 654 |
if ($Text =~ s/[,;:. ]\s*(?:n|\#|\#\s+)(\d+[a-z]*)\b//i) { |
| 655 |
$cite->{'issue'} = $1; |
| 656 |
$cite->{'rest_text'} = $Text; |
| 657 |
return |
| 658 |
}; |
| 659 |
|
| 660 |
|
| 661 |
} |
| 662 |
|
| 663 |
sub find_supplement { |
| 664 |
my $cite = shift; |
| 665 |
my $Text = $cite->{'rest_text'}; |
| 666 |
|
| 667 |
if ($Text =~ s/[,;:. ]\s*(?:suppl|supplement)\.?\s*(\d+)\b//i) { |
| 668 |
$cite->{'supl'} = $1; |
| 669 |
$cite->{'num_of_fig'} = $cite->{'num_of_fig'} - 1; |
| 670 |
$cite->{'rest_text'} = $Text |
| 671 |
} |
| 672 |
} |
| 673 |
|
| 674 |
|
| 675 |
sub find_url { |
| 676 |
my $cite = shift; |
| 677 |
my $Text = $cite->{'rest_text'}; |
| 678 |
|
| 679 |
if ($Text =~ s/\b(http:\/\/[^\s]+)/ /i){ |
| 680 |
my $url = $1; |
| 681 |
$url =~ s/\W*$//; |
| 682 |
$cite->{'targetURL'} = $url; |
| 683 |
$cite->{'rest_text'} = $Text; |
| 684 |
return 1 |
| 685 |
}; |
| 686 |
|
| 687 |
if ($Text =~ s/\b(http:\/\/[^\s>]+)(?:\s|$)/ /i){ |
| 688 |
$cite->{'targetURL'} = $1; |
| 689 |
$cite->{'targetURL'} =~ s/[.,;]$//; |
| 690 |
$cite->{'rest_text'} = $Text; |
| 691 |
return 1 |
| 692 |
}; |
| 693 |
|
| 694 |
return 0 |
| 695 |
} |
| 696 |
|
| 697 |
|
| 698 |
sub find_page { |
| 699 |
my $cite = shift; |
| 700 |
my $Text = $cite->{'rest_text'}; |
| 701 |
|
| 702 |
# keep the order of the pattern matching. |
| 703 |
|
| 704 |
# '... p.20, p 20, ...' |
| 705 |
if ($Text =~ s/[,;:. ]\s*(?:pages|page|pp)\s*[.# ]\s*([a-z]*\d+[a-z]*)\b//i) { |
| 706 |
$cite->{'spage'} = $1; |
| 707 |
$cite->{'rest_text'} = $Text; |
| 708 |
return |
| 709 |
}; |
| 710 |
|
| 711 |
# " ... pp20, ..." |
| 712 |
if ($Text =~ s/[,;:. ]\s*(?:pages|page|pp)(\d+[a-z]*)\b//i) { |
| 713 |
$cite->{'spage'} = $1; |
| 714 |
$cite->{'rest_text'} = $Text; |
| 715 |
return |
| 716 |
}; |
| 717 |
|
| 718 |
# ... p. 1990-1993 |
| 719 |
if ($Text =~ s/[,;. ]\s*(?:p)\s*[. ]\s* |
| 720 |
([a-z]*\d+[a-z]*)\s*\-\s*[a-z]*d+[a-z]*\b//xi) { |
| 721 |
|
| 722 |
$cite->{'spage'} = $1; |
| 723 |
$cite->{'rest_text'} = $Text; |
| 724 |
return |
| 725 |
}; |
| 726 |
|
| 727 |
# Beaware "Smith P. 1990, ..., p. 100" |
| 728 |
while ($Text =~ /[,;. ]\s*p\s*[. ]\s*([a-z]*\d+[a-z]*)\s*(?!\-)/ig){ |
| 729 |
my $Guess_page = $1; |
| 730 |
next if ($Guess_page =~ /(19|20)\d\d/); |
| 731 |
|
| 732 |
$cite->{'spage'} = $Guess_page; |
| 733 |
$Text =~ s/[,;. ]\s*p\s*[. ]\s*[a-z]*\d+[a-z]*\s*(?!\-)//i; |
| 734 |
$cite->{'rest_text'} = $Text; |
| 735 |
return |
| 736 |
}; |
| 737 |
|
| 738 |
# " ... p20, ..." |
| 739 |
if ($Text =~ s/[,;:. ]\s*p(\d+[a-z]*)\b//i) { |
| 740 |
$cite->{'spage'} = $1; |
| 741 |
$cite->{'rest_text'} = $Text; |
| 742 |
return |
| 743 |
}; |
| 744 |
} |
| 745 |
|
| 746 |
|
| 747 |
sub find_year { |
| 748 |
my $cite = shift; |
| 749 |
|
| 750 |
return 1 if ($cite->{'year'}); |
| 751 |
|
| 752 |
my $Text = $cite->{'rest_text'}; |
| 753 |
|
| 754 |
# priority is given to (1989) type. |
| 755 |
if ($Text =~ s/\(((19|20)\d\d)\w?\)//) { |
| 756 |
$cite->{'year'} = $1; |
| 757 |
$cite->{'rest_text'} = $Text; |
| 758 |
return 1 |
| 759 |
}; |
| 760 |
|
| 761 |
# year like numbers not before/after a '-' |
| 762 |
# e.g. 1966-1988 may indicate a page range. |
| 763 |
if ($Text =~ /[^\w\-"]((19|20)\d\d)\w?([^\w\-"]|$)/i) { |
| 764 |
|
| 765 |
$cite->{'year'} = $1; |
| 766 |
$Text =~ "\Q$` $'\E"; |
| 767 |
$cite->{'rest_text'} = $Text; |
| 768 |
return 1 |
| 769 |
}; |
| 770 |
|
| 771 |
return 0; |
| 772 |
} |
| 773 |
|
| 774 |
# Apt'e, C., et al. ACM Transactions on Information Systems 12, 3, 233-251 |
| 775 |
sub guess_vol_no_pg { |
| 776 |
my $cite = shift; |
| 777 |
return 1 if ($cite->{'volume'} and $cite->{'issue'} and |
| 778 |
$cite->{'spage'}); |
| 779 |
return 0 if ($cite->{'num_of_fig'} < 3); |
| 780 |
|
| 781 |
my $Text = $cite->{'rest_text'}; |
| 782 |
|
| 783 |
# change (1,1) alike to (). |
| 784 |
$Text =~ s/\(\d+\s*,\s*\d+\s*\)/\(\)/g; |
| 785 |
$Text =~ s/\(\d+\s*;\s*\d+\s*\)/\(\)/g; |
| 786 |
|
| 787 |
if ($Text =~ |
| 788 |
/[^\w\/.-](?:volume|vol\.?|v\.?)?\s*([a-z]*?\d+[a-z]*?) # volume |
| 789 |
[^\w\/.-]+(?:n|no|number|issue|\#)?\.?\s*([a-z]*?\d+[a-z]*?) # issue |
| 790 |
[^\w\/.-]+(?:pages|page|pp|p)?\.? |
| 791 |
\s*([a-z]*?\d+[a-z]*?)(?:\s*-\s*[a-z]*?\d+[a-z]*?)? |
| 792 |
(\W*|$)/xi) { |
| 793 |
|
| 794 |
$cite->{'volume'} = $1; |
| 795 |
$cite->{'issue'} = $2; |
| 796 |
$cite->{'spage'} = $3; |
| 797 |
$cite->{'jnl_epos'} = length($`) + 1; |
| 798 |
|
| 799 |
return 1 |
| 800 |
}; |
| 801 |
|
| 802 |
return 0 |
| 803 |
|
| 804 |
} |
| 805 |
|
| 806 |
|
| 807 |
# '15:190' (15A:190-195, 14-15:190-180, or "Astrophys. J. 8, 103"); |
| 808 |
# Called this after '{find_vol_{no}_pg_year}' failed. |
| 809 |
sub guess_vol_pg { |
| 810 |
my $cite = shift; |
| 811 |
return 1 if ($cite->{'volume'} and $cite->{'spage'}); |
| 812 |
return 0 if ($cite->{'num_of_fig'} < 2); |
| 813 |
|
| 814 |
my $Text = $cite->{'rest_text'}; |
| 815 |
|
| 816 |
# change (1,1) alike to (). |
| 817 |
$Text =~ s/\(\d+\s*,\s*\d+\s*\)/\(\)/g; |
| 818 |
$Text =~ s/\(\d+\s*;\s*\d+\s*\)/\(\)/g; |
| 819 |
|
| 820 |
# 15A:190-195 type |
| 821 |
if ($Text =~ s/[^\w\/.-]([a-z]*?\d+[a-z]*?)\s*:\s*([a-z]*?\d+[a-z]*?)\s* |
| 822 |
(-\s*[a-z]*?\d+[a-z]*?)?(\W|$)/$4/xi) { |
| 823 |
$cite->{'volume'} = $1; |
| 824 |
$cite->{'spage'} = $2; |
| 825 |
$cite->{'jnl_epos'} = length($`) + 1; |
| 826 |
|
| 827 |
$cite->{'rest_text'} = $Text; |
| 828 |
return 1 |
| 829 |
}; |
| 830 |
|
| 831 |
# Astrophys. J. Lett., 452, p.L91-L93 |
| 832 |
# AIP, vol 307, p.117, New York (1994). |
| 833 |
# Pub. Astron. Soc. Japan, 2000, p.52 |
| 834 |
if ($Text =~ |
| 835 |
/[^\w\/.-](?:volume|vol\.?|v\.?)?\s*([a-z]*?\d+[a-z]*?) # volume |
| 836 |
[^\w\/.-]*,\s*(?:p|pp|page|pages)[. ]\s*([a-z]*?\d+[a-z]*?)\s* |
| 837 |
(-\s*[a-z]*?\d+[a-z]*?)?(?:\W|$)/xi) { |
| 838 |
|
| 839 |
my $Guess_vol = $1; |
| 840 |
$cite->{'spage'} = $2; |
| 841 |
my $Guess_jnl_epos = length($`) + 1; # prematch |
| 842 |
|
| 843 |
if ($Guess_vol =~ /^(19|20)\d\d[a-z]?$/i) { |
| 844 |
$cite->{'year'} = $Guess_vol; |
| 845 |
$cite->{'rest_text'} =~ |
| 846 |
s/([^\w\/.-])(?:volume|vol\.?|v\.?)?\s*[a-z]*?\d+[a-z]*?\s*,\s*(?:p|pp|page|pages)\s*\.?[a-z]*?\d+[a-z]*?\s*(-\s*[a-z]*?\d+[a-z]*?)?(\W|$)/$1/i; |
| 847 |
return 0 |
| 848 |
}; |
| 849 |
$cite->{'volume'} = $Guess_vol; |
| 850 |
$cite->{'jnl_epos'} = $Guess_jnl_epos; |
| 851 |
$cite->{'rest_text'} =~ |
| 852 |
s/([^\w\/.-])[a-z]*?\d+[a-z]*?\s*,\s*(?:p|pp|page|pages)\s*\.?[a-z]*?\d+[a-z]*?\s*(-\s*[a-z]*?\d+[a-z]*?)?(\W|$)/$1/i; |
| 853 |
return 1 |
| 854 |
}; |
| 855 |
|
| 856 |
# Elias, J. 1994, NOAO Newsletter, No. 37, 1 |
| 857 |
if ($Text =~ |
| 858 |
/[^\w\/.-](?:n|no|num|issue)[. ]\s*([a-z]*?\d+[a-z]*?) # volume |
| 859 |
[^\w\/.-]*,\s*(?:p|pp|page|pages)?\.?\s*([a-z]*?\d+[a-z]*?)\s* |
| 860 |
(-\s*[a-z]*?\d+[a-z]*?)?(?:\W|$)/xi) { |
| 861 |
|
| 862 |
$cite->{'issue'} = $1; |
| 863 |
$cite->{'spage'} = $2; |
| 864 |
$cite->{'jnl_epos'} = length($`) + 1; # prematch |
| 865 |
$cite->{'rest_text'} =~ |
| 866 |
s/([^\w\/.-])(?:n|no|num|issue)[. ]\s*[a-z]*?\d+[a-z]*?[^\w\/.-]*,\s*(?:p|pp|page|pages)?\.?\s*([a-z]*?\d+[a-z]*?)\s*(-\s*[a-z]*?\d+[a-z]*?)?(?:\W|$)/$1/i; |
| 867 |
return 1 |
| 868 |
}; |
| 869 |
|
| 870 |
# match page range. |
| 871 |
# Phys. Rev. A 4, 52-60 |
| 872 |
# Pub. Astron. Soc. Japan, 1998, 52-60 |
| 873 |
if ($Text =~ /[^\w\/.-]([a-z]*?\d+[a-z]*?) # volume or year |
| 874 |
[^\w\/.-]*[, ]\s*([a-z]*?\d+[a-z]*?)\s* # pages |
| 875 |
-\s*[a-z]*?\d+[a-z]*?(?:[^\w-]|$)/xi) { |
| 876 |
|
| 877 |
my $Guess_vol = $1; |
| 878 |
$cite->{'spage'} = $2; |
| 879 |
my $Guess_jnl_epos = length($`) + 1; # prematch |
| 880 |
|
| 881 |
if ($Guess_vol =~ /^(19|20)\d\d[a-z]?$/i) { |
| 882 |
$cite->{'year'} = $Guess_vol; |
| 883 |
$cite->{'rest_text'} =~ |
| 884 |
s/([^\w\/.-])[a-z]*?\d+[a-z]*?\s*[, ]\s*([a-z]*?\d+[a-z]*?)\s*-\s*[a-z]*?\d+[a-z]*?(?:[^\w\/.-]|$)/$1/i; |
| 885 |
return 0 |
| 886 |
}; |
| 887 |
$cite->{'volume'} = $Guess_vol; |
| 888 |
$cite->{'jnl_epos'} = $Guess_jnl_epos; |
| 889 |
$cite->{'rest_text'} =~ s/([^\w\/.-])[a-z]*?\d+[a-z]*?\s*,\s*([a-z]*?\d+[a-z]*?)\s*-\s*[a-z]*?\d+[a-z]*?(?:[^\w\/.-]|$)/$1/i; |
| 890 |
|
| 891 |
return 1 |
| 892 |
}; |
| 893 |
|
| 894 |
# Phys. Rev. B 38, 2297. (Phys. Rev. B 38 2297) |
| 895 |
# Pub. Astron. Soc. Japan, 2000, 52. |
| 896 |
if ($Text =~ /[^\w\/.-]([a-uw-z]*?\d+[a-z]*?) |
| 897 |
[^\w\/.-]*[, ]\s*([a-z]?\d+[a-z]?)(?:[^\w\/.-]|$)/xi) { |
| 898 |
|
| 899 |
my $Guess_vol = $1; |
| 900 |
my $Guess_page = $2; |
| 901 |
$cite->{'jnl_epos'} = length($`) + 1; |
| 902 |
|
| 903 |
if ($Guess_vol =~ /^(19|20)\d\d[a-z]?$/i) { |
| 904 |
$cite->{'year'} = $Guess_vol; |
| 905 |
} else { |
| 906 |
$cite->{'volume'} = $Guess_vol; |
| 907 |
}; |
| 908 |
|
| 909 |
if ($Guess_page =~ /^(19|20)\d\d[a-z]?$/i) { |
| 910 |
$cite->{'year'} = $Guess_page; |
| 911 |
} else { |
| 912 |
$cite->{'spage'} = $Guess_page; |
| 913 |
}; |
| 914 |
|
| 915 |
$cite->{'rest_text'} =~ |
| 916 |
s/([^\w\/.-])[a-z]*?\d+[a-z]*?[^\w\/.-]*[, ]\s*[a-z]*?\d+[a-z]*?(?:[^\w\/.-]|$)/$1/i; |
| 917 |
return 1 if ($cite->{'volume'} and $cite->{'spage'}); |
| 918 |
return 0 |
| 919 |
}; |
| 920 |
|
| 921 |
return 0 |
| 922 |
}; |
| 923 |
|
| 924 |
# |
| 925 |
# G. Smith and H. Gray; Pub. Astron. Soc. Japan, 2000, vol. 52 |
| 926 |
# To find $cite->{'jnl_epos'} currectly. Note that '2000' may be |
| 927 |
# regarded as the journal name (by subroutine find_vol). |
| 928 |
sub guess_vol_year { |
| 929 |
my $cite = shift; |
| 930 |
return 0 if ($cite->{'num_of_fig'} < 2); |
| 931 |
|
| 932 |
my $Text = $cite->{'rest_text'}; |
| 933 |
|
| 934 |
# change (1,1) alike to (). |
| 935 |
$Text =~ s/\(\d+\s*,\s*\d+\s*\)/\(\)/g; |
| 936 |
$Text =~ s/\(\d+\s*;\s*\d+\s*\)/\(\)/g; |
| 937 |
|
| 938 |
if ($Text =~ |
| 939 |
/[^\w\/.-]\(?((19|20)\d\d)\w?\)?[^\w\/.-]* |
| 940 |
(?:volume|vol|v)\W*([a-oq-z]*?\d+[a-z]*?)(\W|$)/xis) { |
| 941 |
|
| 942 |
$cite->{'year'} = $1; |
| 943 |
$cite->{'volume'} = $3; |
| 944 |
$cite->{'jnl_epos'} = length($`); |
| 945 |
|
| 946 |
return 1 |
| 947 |
}; |
| 948 |
|
| 949 |
# be aware: "Workshop on ..., p30 (1999)." |
| 950 |
if ($Text =~ |
| 951 |
/[^\w\/.-](?:volume|vol|v)?\W*([a-oq-z]?\d+[a-z]?) |
| 952 |
[^\w\/.-]+\(?((19|20)\d\d)\w?\)?(\W|$)/xis) { |
| 953 |
$cite->{'volume'} = $1; |
| 954 |
$cite->{'year'} = $2; |
| 955 |
$cite->{'jnl_epos'} = length($`); |
| 956 |
|
| 957 |
return 1 |
| 958 |
}; |
| 959 |
|
| 960 |
return 0 |
| 961 |
}; |
| 962 |
|
| 963 |
sub find_vol_no_pg_year { |
| 964 |
my $cite = shift; |
| 965 |
return 1 if ($cite->{'volume'} and $cite->{'issue'} and |
| 966 |
$cite->{'spage'} and $cite->{'year'}); |
| 967 |
return 0 if ($cite->{'num_of_fig'} < 4); |
| 968 |
|
| 969 |
my $Text = $cite->{'rest_text'}; |
| 970 |
|
| 971 |
# change (1,1) alike to (). |
| 972 |
$Text =~ s/\(\d+\s*,\s*\d+\s*\)/\(\)/g; |
| 973 |
$Text =~ s/\(\d+\s*;\s*\d+\s*\)/\(\)/g; |
| 974 |
|
| 975 |
# Keep the following order of texting $Text; |
| 976 |
# Important: check 'year' at the end first. |
| 977 |
|
| 978 |
# (A.1): |
| 979 |
# 'year' is at the end, within bracket. |
| 980 |
# ..., v.517, no. 1, p.190-200, (1999) |
| 981 |
# ..., 11(2), 100-105, (1999) |
| 982 |
if ($Text =~ |
| 983 |
/[^\w\/.-](?:volume|vol\.?|v\.?)?\s*([a-z]*?\d+[a-z]*?) # volume |
| 984 |
[^\w\/.-]+(?:n|no|number|issue|\#)?\.?\s*([a-z]*?\d+[a-z]*?) # issue |
| 985 |
[^\w\/.-]+(?:pages|page|pp|p)?\.? |
| 986 |
\s*([a-z]*?\d+[a-z]*?)(?:\s*-\s*[a-z]*?\d+[a-z]*?)? |
| 987 |
\W*\(((19|20)\d\d)[a-z]*?\)(\W|$)/xi) { |
| 988 |
|
| 989 |
$cite->{'volume'} = $1; |
| 990 |
$cite->{'issue'} = $2; |
| 991 |
$cite->{'spage'} = $3; |
| 992 |
$cite->{'year'} = $4; |
| 993 |
$cite->{'jnl_epos'} = length($`) + 1; |
| 994 |
|
| 995 |
return 1 |
| 996 |
}; |
| 997 |
|
| 998 |
# (A.2) 'year' is in the middle, within bracket. |
| 999 |
# ..., 4(2), (1999), 100-105 |
| 1000 |
if ($Text =~ |
| 1001 |
/[^\w\/.-](?:volume|vol\.?|v\.?)?\s*([a-z]*?\d+[a-z]*?) # volume |
| 1002 |
[^\w\/.-]+(?:n|no|number|issue|\#)?\.?\s*([a-z]*?\d+[a-z]*?) # issue |
| 1003 |
\W*\(((19|20)\d\d)[a-z]*?\) # year |
| 1004 |
\W*(?:pages|page|pp|p)?\.?\s*([a-z]*?\d+[a-z]*?)(\W|$)/xi) { |
| 1005 |
|
| 1006 |
$cite->{'volume'} = $1; |
| 1007 |
$cite->{'issue'} = $2; |
| 1008 |
$cite->{'year'} = $3; |
| 1009 |
$cite->{'spage'} = $5; |
| 1010 |
$cite->{'jnl_epos'} = length($`) + 1; |
| 1011 |
|
| 1012 |
return 1 |
| 1013 |
}; |
| 1014 |
|
| 1015 |
# (A.3.1) 'year' is at the beginning, within bracket, after |
| 1016 |
# journal title; |
| 1017 |
# ...., (1999), 517, no. 1, p.190-200 |
| 1018 |
if ($Text =~ |
| 1019 |
/\(((19|20)\d\d)[a-z]*?\)[,.;\s:]* # year |
| 1020 |
(?:volume|vol|v)?\.?\s*([a-z]*?\d+[a-z]*?) # volume |
| 1021 |
[^\w\/.-]+(?:n|no|number|issue|\#)?\.?\s*([a-z]*?\d+[a-z]*?) # issue |
| 1022 |
[^\w\/.-]+(?:pages|page|pp|p)?\.?\s*([a-z]*?\d+[a-z]*?)(\W|$)/ix) |
| 1023 |
{ |
| 1024 |
$cite->{'year'} = $1; |
| 1025 |
$cite->{'volume'} = $3; |
| 1026 |
$cite->{'issue'} = $4; |
| 1027 |
$cite->{'spage'} = $5; |
| 1028 |
$cite->{'jnl_epos'} = length($`); |
| 1029 |
|
| 1030 |
return 1; |
| 1031 |
}; |
| 1032 |
|
| 1033 |
# (A.3.2) 'year' is at the beginning, within bracket, before |
| 1034 |
# journal title; |
| 1035 |
# ..., (1999),..., 517, no. 1, p.190-200 |
| 1036 |
if ($Text =~ |
| 1037 |
/\(((19|20)\d\d)[a-z]*?\) # year |
| 1038 |
([^(]+?) |
| 1039 |
[^\w\/.-](?:volume|vol|v)?\.?\s*([a-z]*?\d+[a-z]*?) # volume |
| 1040 |
[^\w\/.-]+(?:n|no|number|issue|\#)?\.?\s*([a-z]*?\d+[a-z]*?) # issue |
| 1041 |
[^\w\/.-]+(?:pages|page|pp|p)?\.?\s*([a-z]*?\d+[a-z]*?)(\W|$)/ix){ |
| 1042 |
$cite->{'year'} = $1; |
| 1043 |
$cite->{'volume'} = $4; |
| 1044 |
$cite->{'issue'} = $5; |
| 1045 |
$cite->{'spage'} = $6; |
| 1046 |
|
| 1047 |
# $cite->{'jnl_spos'} = length($`); |
| 1048 |
# $cite->locate_jnl_epos(); |
| 1049 |
$cite->{'jnl_epos'} = length($`) + length($1) + |
| 1050 |
length($3); |
| 1051 |
return 1; |
| 1052 |
}; |
| 1053 |
|
| 1054 |
|
| 1055 |
# (B.1): |
| 1056 |
# 'year' is at the end, but not in bracket; |
| 1057 |
# ..., v.517, no. 1, p.190-200, 1999 |
| 1058 |
# ..., 517, no. 1, p.190-200, 1999 |
| 1059 |
if ($Text =~ |
| 1060 |
/[^\w\/.-](?:volume|vol\.?|v\.?)?\s*([a-z]*?\d+[a-z]*?) # volume |
| 1061 |
[^\w\/.-]+(?:n|no|number|issue|\#)?\.?\s*([a-z]*?\d+[a-z]*?) # issue |
| 1062 |
[^\w\/.-]+(?:pages|page|pp|p)?\.? |
| 1063 |
\s*([a-z]*?\d+[a-z]*?)(?:\s*-\s*[a-z]*?\d+[a-z]*?)? |
| 1064 |
[^\w(:\/.-]+?((19|20)\d\d)[a-z]?\s*(?![)-])/xi) { |
| 1065 |
|
| 1066 |
$cite->{'volume'} = $1; |
| 1067 |
$cite->{'issue'} = $2; |
| 1068 |
$cite->{'spage'} = $3; |
| 1069 |
$cite->{'year'} = $4; |
| 1070 |
$cite->{'jnl_epos'} = length($`) + 1; |
| 1071 |
|
| 1072 |
return 1 |
| 1073 |
}; |
| 1074 |
|
| 1075 |
|
| 1076 |
# (B.2): 'year' is in the middle, but not in bracket. |
| 1077 |
# 4(2), 1999, 100-105 |
| 1078 |
if ($Text =~ |
| 1079 |
/[^\w\/.-](?:volume|vol\.?|v\.?)?\s*([a-z]*?\d+[a-z]*?) # volume |
| 1080 |
[^\w\/.-]+(?:n|no|number|issue|\#)?\.?\s*([a-z]*?\d+[a-z]*?) # issue |
| 1081 |
[^\w(:\/.-]+?\s*((19|20)\d\d)[a-z]? # year |
| 1082 |
\s*[^\w\/.)-]+?\s*(?:pages|page|pp|p)?\.?\s*([a-z]*?\d+[a-z]*?)(\W|$)/xi) { |
| 1083 |
|
| 1084 |
$cite->{'volume'} = $1; |
| 1085 |
$cite->{'issue'} = $2; |
| 1086 |
$cite->{'year'} = $3; |
| 1087 |
$cite->{'spage'} = $5; |
| 1088 |
$cite->{'jnl_epos'} = length($`) + 1; |
| 1089 |
|
| 1090 |
return 1 |
| 1091 |
}; |
| 1092 |
|
| 1093 |
# (B.3.1): 'year' is at beginning, not in bracket, after title; |
| 1094 |
# ..., 1999, v.517, no. 1, p.190-200 |
| 1095 |
# " ... 1890-1999", MNRAS, 2000, 4:1, p 1990 |
| 1096 |
if ($Text =~ |
| 1097 |
/[^"(\/.-]\s*((19|20)\d\d)[a-z]?[,;\.\s]+ # year |
| 1098 |
(?:volume|vol|v)?\.?\s*([a-z]*?\d+[a-z]*?) # volume |
| 1099 |
[^\w\/.-]+?(?:n|no|number|issue|\#)?\.?\s*([a-z]*?\d+[a-z]*?) |
| 1100 |
[^\w\/.-]+(?:pages|page|pp|p)?\.?\s*([a-z]*?\d+[a-z]*?)(\W|$)/ix) |
| 1101 |
{ |
| 1102 |
$cite->{'year'} = $1; |
| 1103 |
$cite->{'volume'} = $3; |
| 1104 |
$cite->{'issue'} = $4; |
| 1105 |
$cite->{'spage'} = $5; |
| 1106 |
$cite->{'jnl_epos'} = length($`) + 1; |
| 1107 |
return 1 |
| 1108 |
}; |
| 1109 |
|
| 1110 |
# (B.3.2): 'year' is at beginning, not in bracket, before title; |
| 1111 |
# 1999, ..., v.517, no. 1, p.190-200 |
| 1112 |
# 1999, ..., 517, no. 1, p.190-200 |
| 1113 |
# 1999, ..., 517(1), 190-200 |
| 1114 |
# NB: 1999, "... 1.5 factor ....", 517(1), 190-200 |
| 1115 |
# NB: B. Greene, editors, "Fields, Strings and Duality, TASI 1996", |
| 1116 |
# pages 421-540, World Scientific, 1997. |
| 1117 |
# " ... 1890-1999", MNRAS, 2000, 4:1, p 1990 |
| 1118 |
if ($Text =~ |
| 1119 |
/(?:^|[^"(\/.-])\s*((19|20)\d\d)[a-z]? # year |
| 1120 |
[^\w:")(\/-][^(]*? |
| 1121 |
[^\w\/.-](?:volume|vol|v)?\.?\s*([a-z]*?\d+[a-z]*?) # volume |
| 1122 |
[^\w\/.-]+?(?:n|no|number|issue|\#)?\.?\s*([a-z]?\d+[a-z]?) |
| 1123 |
[^\w\/.-]+(?:pages|page|pp|p)?\.?\s*([a-z]*?\d+[a-z]*?)(\W|$)/ix) |
| 1124 |
{ |
| 1125 |
$cite->{'year'} = $1; |
| 1126 |
$cite->{'volume'} = $3; |
| 1127 |
$cite->{'issue'} = $4; |
| 1128 |
$cite->{'spage'} = $5; |
| 1129 |
|
| 1130 |
$cite->{'jnl_spos'} = length($`); |
| 1131 |
$cite->locate_jnl_epos(); |
| 1132 |
return 1 |
| 1133 |
}; |
| 1134 |
return 0 |
| 1135 |
}; |
| 1136 |
|
| 1137 |
|
| 1138 |
# For cases where 'vol, page, year' can be identified correctly. |
| 1139 |
sub find_vol_pg_year { |
| 1140 |
my $cite = shift; |
| 1141 |
return 1 if ($cite->{'volume'} and $cite->{'spage'} and |
| 1142 |
$cite->{'year'}); |
| 1143 |
return 0 if ($cite->{'num_of_fig'} < 3); |
| 1144 |
|
| 1145 |
my $Text = $cite->{'rest_text'}; |
| 1146 |
|
| 1147 |
# change (1,1) alike to (). |
| 1148 |
$Text =~ s/\(\d+\s*,\s*\d+\s*\)/\(\)/g; |
| 1149 |
$Text =~ s/\(\d+\s*;\s*\d+\s*\)/\(\)/g; |
| 1150 |
|
| 1151 |
# (A.1) 'year' is at the end, within bracket. |
| 1152 |
# ......, vol.8:100, (1999) |
| 1153 |
# ......, 8:100, (1999) |
| 1154 |
# ~~~~ |
| 1155 |
if ($Text =~ |
| 1156 |
/(?:^|[^\w\/.-])(?:volume|vol\.?|v\.?)?\s*([a-z]*?\d+[a-z]*?) # volume |
| 1157 |
[^\w\/.-]+(?:pages|page|pp|p)?\.? |
| 1158 |
\s*([a-z]?\d+[a-z]?)(?:\s*-\s*[a-z]?\d+[a-z]?)? |
| 1159 |
\W*\(((19|20)\d\d)[a-z]?\)(\W|$)/xi) { |
| 1160 |
|
| 1161 |
$cite->{'volume'} = $1; |
| 1162 |
$cite->{'spage'} = $2; |
| 1163 |
$cite->{'year'} = $3; |
| 1164 |
$cite->{'jnl_epos'} = length($`) + 1; |
| 1165 |
|
| 1166 |
return 1 |
| 1167 |
}; |
| 1168 |
|
| 1169 |
# (A.2) 'year' is in the middle, within bracket. |
| 1170 |
# ......, 8, (1999), 100-105 |
| 1171 |
if ($Text =~ |
| 1172 |
/(?:^|[^\w\/.-])(?:volume|vol\.?|v\.?)?\s*([a-z]*?\d+[a-z]*?) # volume |
| 1173 |
\W*\(((19|20)\d\d)[a-z]?\) # year |
| 1174 |
\W*(?:pages|page|pp|p)?\.? |
| 1175 |
\s*([a-z]?\d+[a-z]?)(?:\s*-\s*[a-z]?\d+[a-z]?)?(\W|$)/xi) { |
| 1176 |
|
| 1177 |
$cite->{'volume'} = $1; |
| 1178 |
$cite->{'year'} = $2; |
| 1179 |
$cite->{'spage'} = $4; |
| 1180 |
$cite->{'jnl_epos'} = length($`) + 1; |
| 1181 |
|
| 1182 |
return 1 |
| 1183 |
}; |
| 1184 |
|
| 1185 |
# (A.3.1.) 'year' is at beginning, within bracket, after title; |
| 1186 |
# ......, (1999) 517, 190-200 |
| 1187 |
if ($Text =~ |
| 1188 |
/\(((19|20)\d\d)[a-z]?\)[,;\.\s]* # year |
| 1189 |
(?:volume|vol|v)?\.?\s*([a-z]*?\d+[a-z]*?) # volume |
| 1190 |
[^\w\/.-]+(?:pages|page|pp|p)?\.?\s*([a-z]?\d+[a-z]?)(\W|$)/ix){ |
| 1191 |
$cite->{'year'} = $1; |
| 1192 |
$cite->{'volume'} = $3; |
| 1193 |
$cite->{'spage'}= $4; |
| 1194 |
$cite->{'jnl_epos'} = length($`); |
| 1195 |
|
| 1196 |
return 1; |
| 1197 |
}; |
| 1198 |
|
| 1199 |
# (A.3.1.1) 'year' is at beginning, within bracket, after title; |
| 1200 |
# not 'vol', buy 'No.@, e.g."..., (1999) No. 517, 190-200 |
| 1201 |
if ($Text =~ |
| 1202 |
/\(((19|20)\d\d)[a-z]?\)[,;\.\s]* # year |
| 1203 |
(?:number|no|n)\.?\s*([a-z]*?\d+[a-z]*?) # volume |
| 1204 |
[^\w\/.-]+(?:pages|page|pp|p)?\.?\s*([a-z]?\d+[a-z]?)(\W|$)/ix){ |
| 1205 |
$cite->{'year'} = $1; |
| 1206 |
$cite->{'volume'} = $3; |
| 1207 |
$cite->{'spage'}= $4; |
| 1208 |
$cite->{'jnl_epos'} = length($`); |
| 1209 |
|
| 1210 |
return 1; |
| 1211 |
}; |
| 1212 |
|
| 1213 |
|
| 1214 |
# (A.3.2.) 'year' is at beginning, within bracket, before title; |
| 1215 |
# ..., (1999),..., 517, p.190-200 |
| 1216 |
if ($Text =~ |
| 1217 |
/\(((19|20)\d\d)[a-z]?\) # year |
| 1218 |
[^(]+? |
| 1219 |
[^\w\/.-](?:volume|vol|v)?\.?\s*([a-z]*?\d+[a-z]*?) # volume |
| 1220 |
[^\w\/.-]+(?:pages|page|pp|p)?\.?\s*([a-z]?\d+[a-z]?)(\W|$)/ix){ |
| 1221 |
$cite->{'year'} = $1; |
| 1222 |
$cite->{'volume'} = $3; |
| 1223 |
$cite->{'spage'} = $4; |
| 1224 |
|
| 1225 |
$cite->{'jnl_spos'} = length($`); |
| 1226 |
$cite->locate_jnl_epos(); |
| 1227 |
return 1; |
| 1228 |
}; |
| 1229 |
|
| 1230 |
# (B.1) 'year' is at the end, but not in bracket. |
| 1231 |
# ......, vol.8:100, 1999 |
| 1232 |
# ......, 8:100, 1999 |
| 1233 |
# NB: ..., 1999, 8(1900) |
| 1234 |
# ~~~~ |
| 1235 |
if ($Text =~ |
| 1236 |
/[^\w\/.-](?:volume|vol\.?|v\.?)?\s*([a-z]*?\d+[a-z]*?) # volume |
| 1237 |
[^\w\/.-]+(?:pages|page|pp|p)?\.? |
| 1238 |
\s*([a-z]?\d+[a-z]?)(?:\s*-\s*[a-z]?\d+[a-z]?)? # page |
| 1239 |
[^\w:(\/.-]+\s*((19|20)\d\d)[a-z]?\s*(?![)-])/xi) { |
| 1240 |
|
| 1241 |
$cite->{'volume'} = $1; |
| 1242 |
$cite->{'spage'} = $2; |
| 1243 |
$cite->{'year'} = $3; |
| 1244 |
$cite->{'jnl_epos'} = length($`) + 1; |
| 1245 |
|
| 1246 |
return 1 |
| 1247 |
}; |
| 1248 |
|
| 1249 |
# (B.2) 'year' is in the middle, but not in brackets; |
| 1250 |
# ... 8, 1999, p.100 |
| 1251 |
# ... 8, 1999, 100-105 |
| 1252 |
if ($Text =~ |
| 1253 |
/[^\w\/.-](?:volume|vol\.?|v\.?)?\s*([a-z]*?\d+[a-z]*?) # volume |
| 1254 |
[^\w:(\/.-]+?\s*((19|20)\d\d)[a-z]? # year |
| 1255 |
[^\w\/.)-]+(?:pages|page|pp|p)?\.?\s*([a-z]?\d+[a-z]?)(\W|$)/xi) |
| 1256 |
{ |
| 1257 |
$cite->{'volume'} = $1; |
| 1258 |
$cite->{'year'} = $2; |
| 1259 |
$cite->{'spage'} = $4; |
| 1260 |
$cite->{'jnl_epos'} = length($`) + 1; |
| 1261 |
|
| 1262 |
return 1 |
| 1263 |
}; |
| 1264 |
|
| 1265 |
# (B.3.1) 'year' is at the beginning,not in bracket, after title; |
| 1266 |
# ..., 1999, 8, p1990 |
| 1267 |
if ($Text =~ |
| 1268 |
/[^\w\/.(-]\s*((19|20)\d\d)[a-z]?[,;\.\s]+ |
| 1269 |
(?:volume|vol|v)?\.?\s*([a-z]*?\d+[a-z]*?) # volume |
| 1270 |
[^\w\/.-]+(?:pages|page|pp|p)?\.?\s*([a-z]?\d+[a-z]?)(\W|$)/ix){ |
| 1271 |
$cite->{'year'} = $1; |
| 1272 |
$cite->{'volume'} = $3; |
| 1273 |
$cite->{'spage'} = $4; |
| 1274 |
$cite->{'jnl_epos'} = length($`)+1; |
| 1275 |
return 1 |
| 1276 |
}; |
| 1277 |
|
| 1278 |
# (B.3.1.1) 'year' is at the beginning,not in bracket, after title; |
| 1279 |
# no 'vol', but 'no.' e.g. ..., 1999, No. 8, p1990 |
| 1280 |
if ($Text =~ |
| 1281 |
/[^\w\/.(-]\s*((19|20)\d\d)[a-z]?[,;\.\s]+ |
| 1282 |
(?:number|no|n)\.?\s*([a-z]*?\d+[a-z]*?) # no volume, but issues |
| 1283 |
[^\w\/.-]+(?:pages|page|pp|p)?\.?\s*([a-z]?\d+[a-z]?)(\W|$)/ix){ |
| 1284 |
$cite->{'year'} = $1; |
| 1285 |
$cite->{'issue'} = $3; |
| 1286 |
$cite->{'spage'} = $4; |
| 1287 |
$cite->{'jnl_epos'} = length($`)+1; |
| 1288 |
return 1 |
| 1289 |
}; |
| 1290 |
|
| 1291 |
|
| 1292 |
# (B.3.2) 'year' is at beginning, not in bracket, before title; |
| 1293 |
# 1999, ..., 8(100) |
| 1294 |
if ($Text =~ |
| 1295 |
/((^|[^"\/.(-])\s*)(((19|20)\d\d)[a-z]?) # year |
| 1296 |
([^\w:")(\/][^(]*?) |
| 1297 |
[^\w\/.-](?:volume|vol|v)?\.?\s*([a-z]*?\d+[a-z]*?) # volume |
| 1298 |
[^\w\/.-]+(?:pages|page|pp|p)?\.?\s*([a-z]?\d+[a-z]?)(\W|$)/ix){ |
| 1299 |
$cite->{'year'} = $4; |
| 1300 |
$cite->{'volume'} = $7; |
| 1301 |
$cite->{'spage'} = $8; |
| 1302 |
|
| 1303 |
# $cite->{'jnl_spos'} = length($`); |
| 1304 |
# $cite->locate_jnl_epos(); |
| 1305 |
$cite->{'jnl_epos'} = length($`) + length($1) + |
| 1306 |
length($3) + length($6); |
| 1307 |
return 1 |
| 1308 |
}; |
| 1309 |
|
| 1310 |
return 0 |
| 1311 |
} |
| 1312 |
|
| 1313 |
|
| 1314 |
# This subroutine is only called when the journal title is between |
| 1315 |
# 'year' and 'vol/page', e.g. (a lot in astro-ph/) |
| 1316 |
# Barnes, J., Efstathiou, G., 1987, ApJ, 319, 575 |
| 1317 |
# For other cases, the cite{'jnl_epos'} is determined while trying to |
| 1318 |
# find out the vol, page, year, i.e. in 'find_vol_no_pg_year' kind |
| 1319 |
# of subroutines. |
| 1320 |
# |
| 1321 |
sub locate_jnl_epos { |
| 1322 |
|
| 1323 |
my $cite = shift; |
| 1324 |
my $sPos = $cite->{'jnl_spos'}; |
| 1325 |
my $Text = substr($cite->{'rest_text'}, $sPos); |
| 1326 |
|
| 1327 |
# $Text =~ s/(\W+)(?:pages|page|pp|p)\W*(\d+)/$1$2/; |
| 1328 |
# $Text =~ s/-\d+[a-z]*?//; # pp100-105 |
| 1329 |
|
| 1330 |
# Before 'volume' |
| 1331 |
if ($Text =~ /\b(?:volume|vol\.?|v\.?)\s*[a-z]*?\d+[a-z]*?(?![.0-9])/i) { |
| 1332 |
$cite->{'jnl_epos'} = length($`) + $sPos; |
| 1333 |
return 1 |
| 1334 |
}; |
| 1335 |
|
| 1336 |
# (1997) Phys. Rev. E56, No.3, 2875 |
| 1337 |
# (1997) Phys. Rev. A50, p.160 |
| 1338 |
if ($Text =~ / |
| 1339 |
[^\w\/.-](?:volume|vol\.?|v\.?)?\s*[a-z]*?\d+[a-z]*? # volume |
| 1340 |
[^\w\/.-]+(?:n |n.|no |no.|number |issue |\#|p |p.|pp.|page )\s*[a-z]*?\d+[a-z]*? |
| 1341 |
(?:\W|$)/xi) { |
| 1342 |
$cite->{'jnl_epos'} = length($`) + $sPos + 1 ; |
| 1343 |
return 1 |
| 1344 |
}; |
| 1345 |
|
| 1346 |
# Before any two consecutive numbers, but not '123-127' style page. |
| 1347 |
# Bertelli, G., 1999, ApJ, 517(1), .... |
| 1348 |
# ApJ, 517:1, ... |
| 1349 |
# ApJ, 517:367-380. |
| 1350 |
#Beaware: J.K. Lanyi. 1999. Structure of bacteriorhodopsin at 1.55 |
| 1351 |
# angstrom resolution J. Mol. Bio. 291:899-911 ~~~~! |
| 1352 |
if ($Text =~ /[^\w\/.-][a-z]*?\d+[a-z]*?\s*[,:(\s]\s* |
| 1353 |
[a-z]?\d+[a-z]?(\W|$)/xi) { |
| 1354 |
$cite->{'jnl_epos'} = length($`) + $sPos + 1; |
| 1355 |
return 1 |
| 1356 |
}; |
| 1357 |
|
| 1358 |
return 0 |
| 1359 |
}; |
| 1360 |
|
| 1361 |
|
| 1362 |
sub find_jnl_name { |
| 1363 |
my $cite = shift; |
| 1364 |
|
| 1365 |
return 1 if ($cite->{'title'}); |
| 1366 |
return 0 if (! $cite->{'jnl_epos'}); |
| 1367 |
|
| 1368 |
# Assumption: journal name usually starts after a ',;' |
| 1369 |
# or " which is used to enclose the article title, |
| 1370 |
# and does not contain those symbols (i.e. ,;") |
| 1371 |
# |
| 1372 |
my $Text = substr($cite->{'rest_text'}, 0, $cite->{'jnl_epos'}); |
| 1373 |
my $Guess_jnl; |
| 1374 |
|
| 1375 |
# Linden, N., et al. quantph/9711016 and Fortsch. Phys. 46, 567 (1998) |
| 1376 |
#if ($Text =~ m{[^/]+/\w+\s*(.+)$}) { |
| 1377 |
# $Text = $1 |
| 1378 |
# }; |
| 1379 |
|
| 1380 |
LOOP: |
| 1381 |
# remove trailing symbols |
| 1382 |
$Text =~ s/\s*[,;":\/\[\(]*\s*$//s; |
| 1383 |
|
| 1384 |
# ignore anything in brackets (head/tail position) |
| 1385 |
$Text =~ s/\W*\([^\)]+\)?\W*$//; |
| 1386 |
$Text =~ s/^\s*\([^\)]+\)\W+//; |
| 1387 |
|
| 1388 |
return 0 if ($Text eq ''); |
| 1389 |
|
| 1390 |
# quite many citations are like this: |
| 1391 |
# "P. Reiter, et al:Phys. Rev. Lett. 82 (1999) 509" |
| 1392 |
# hard to separate name from journal title. Other cases |
| 1393 |
# are: '..., J.PHY.G:NUCL.PART.PHY.'. Have to compramise. |
| 1394 |
if ($Text =~ /([^,;":?\/\[]+)$/) { |
| 1395 |
$Guess_jnl = $1; |
| 1396 |
$Guess_jnl =~ s/^['`]?\s*//; |
| 1397 |
$Guess_jnl =~ s/\s+$//; |
| 1398 |
|
| 1399 |
# ignore things in brackets |
| 1400 |
$Guess_jnl =~ s/\W*\([^\)]+\)?\W*$//; |
| 1401 |
$Guess_jnl =~ s/^\([^\)]+\)\W*//; |
| 1402 |
|
| 1403 |
# journal name should begin and contain alphabet, |
| 1404 |
# not only numbers; and should be longer than one |
| 1405 |
# character. First remove 'year' |
| 1406 |
$Guess_jnl =~ s/^.*?\(?(19|20)\d\d\w*\)?\W*//; |
| 1407 |
if ($Guess_jnl =~ /^[a-z]\W*$/i) { |
| 1408 |
$Text =~ s/[^,;":?\/\[]+$//; |
| 1409 |
goto LOOP |
| 1410 |
}; |
| 1411 |
|
| 1412 |
# No captital letters |
| 1413 |
if ($Guess_jnl !~ /[A-Z]/) { |
| 1414 |
$Text =~ s/[^,;":?\/\[]+$//; |
| 1415 |
goto LOOP |
| 1416 |
}; |
| 1417 |
|
| 1418 |
# "Report of ... Conf.:1. Introduction. Canadian Medical Association Journal" |
| 1419 |
if ($Guess_jnl !~ /^[a-z]+/i) { |
| 1420 |
my @gWords = split(/\s+/, $Guess_jnl); |
| 1421 |
|
| 1422 |
if (scalar(@gWords) <= 3) { |
| 1423 |
$Text =~ s/[^,;":?\/]+$//; |
| 1424 |
goto LOOP |
| 1425 |
} |
| 1426 |
}; |
| 1427 |
|
| 1428 |
$Text = $Guess_jnl; |
| 1429 |
} |
| 1430 |
else { |
| 1431 |
$Text =~ s/^[`']?\s*//; |
| 1432 |
$Text =~ s/\s*$//; |
| 1433 |
|
| 1434 |
# 'title' is after 'year' (other cases are dealt by |
| 1435 |
# $cite->{'jnl_epos'} in 'find_vol_{no}_pg_year()'.. |
| 1436 |
if ($Text =~ /[,\s\(]+(19|20)\d\d[,\s\)]+\s*/) { |
| 1437 |
$Text = $' |
| 1438 |
}; |
| 1439 |
}; |
| 1440 |
|
| 1441 |
my $end_dot = 0; |
| 1442 |
$end_dot = 1 if ($Text =~ /\.$/); |
| 1443 |
my @Title_words = (); |
| 1444 |
my @Words = (); |
| 1445 |
my $i = 0; |
| 1446 |
|
| 1447 |
# process from the end of the $Text to see if |
| 1448 |
# a $Parts[$i] is (still) a part of a journal name. |
| 1449 |
my @Parts = split(/\s*\.\s*/, $Text); |
| 1450 |
for ($i = $#Parts; $i>=0; $i--) { |
| 1451 |
next if ($Parts[$i] !~ /[a-z]/i); |
| 1452 |
|
| 1453 |
# author name may be mixed into the journal title |
| 1454 |
# e.g. "Popescu S. and G. A. Sudbery. J. of Phy ..." |
| 1455 |
if ($i > 0 and $Parts[$i-1] =~ /^([A-Z][a-z]* )*and\s+[A-Z]$/) { |
| 1456 |
last |
| 1457 |
}; |
| 1458 |
if ($i > 1 and $Parts[$i-2] =~ /^([A-Z][a-z]* )*and\s+[A-Z]$/) { |
| 1459 |
last if ($Parts[$i-1] =~ /^[A-Z]$/); |
| 1460 |
}; |
| 1461 |
|
| 1462 |
# author name may be mixed into the journal title |
| 1463 |
# e.g. "and Sudbery A. Multi-particle ..." |
| 1464 |
if ($i > 0 and $Parts[$i] =~ /^[A-Z]$/) { |
| 1465 |
# less than 4 words. |
| 1466 |
if ($Parts[$i-1] =~ /^\S+\s+\S+(\s+\S+){0,2}$/ and |
| 1467 |
$Parts[$i-1] =~ /^(and )?[A-Z].+?[A-Z]$/){ |
| 1468 |
last |
| 1469 |
} |
| 1470 |
}; |
| 1471 |
|
| 1472 |
push(@Title_words, $Parts[$i]); |
| 1473 |
last if $i == 0; # necessary test |
| 1474 |
|
| 1475 |
last if ($Parts[$i-1] =~ /et\s+al$/i); |
| 1476 |
last if ($Parts[$i-1] =~ /^\s*\d+$/); |
| 1477 |
|
| 1478 |
@Words = split(/\s+/, $Parts[$i-1]); |
| 1479 |
# stop if more than 4 words in $Parts[$i-1], |
| 1480 |
# i.e. $Parts[$i-1] seems to contain article title, |
| 1481 |
# not the journal name. However, be aware of: |
| 1482 |
# "... method for propagating interfaces J. Comput. Phys." |
| 1483 |
# next if (scalar(@Words) <= 2 and |
| 1484 |
next if (scalar(@Words) <= 2 and $Parts[$i-1] !~ /^\d/); |
| 1485 |
|
| 1486 |
if (scalar(@Words) <= 4 and |
| 1487 |
$Parts[$i-1] =~ /^([A-Z][a-z]*\s+){0,3}[A-Z][a-z]*$/){ |
| 1488 |
next |
| 1489 |
}; |
| 1490 |
|
| 1491 |
my $w = pop(@Words); |
| 1492 |
# if ($w =~ /^[A-Z]$/ or $w =~ /^[A-Z][a-z]+$/) { |
| 1493 |
# if ($w =~ /^J$/ or $w =~ /^[A-Z][a-z]+$/) { |
| 1494 |
if ($w =~ /^J$/){ |
| 1495 |
push(@Title_words, $w) |
| 1496 |
}; |
| 1497 |
|
| 1498 |
last |
| 1499 |
}; |
| 1500 |
if (scalar(@Title_words) == 1) { |
| 1501 |
$cite->{'title'} = $Title_words[0] |
| 1502 |
} |
| 1503 |
else { |
| 1504 |
my @Title_words_real = reverse(@Title_words); |
| 1505 |
$cite->{'title'} = join('.', @Title_words_real); |
| 1506 |
}; |
| 1507 |
|
| 1508 |
$cite->{'title'} = "$cite->{'title'}\." if ($end_dot == 1); |
| 1509 |
|
| 1510 |
# normalise it |
| 1511 |
$cite->{'title'} = normalise_journal($cite->{'title'}); |
| 1512 |
return 1 |
| 1513 |
}; |
| 1514 |
|
| 1515 |
|
| 1516 |
|
| 1517 |
sub full_name { |
| 1518 |
my $Text = shift; |
| 1519 |
|
| 1520 |
$Text =~ s/(^|s*)Jr[. ]//i; |
| 1521 |
|
| 1522 |
return 1 if ($Text =~ /^\s*et al\s*$/i); |
| 1523 |
|
| 1524 |
return 0 if ($Text =~/^in /i); |
| 1525 |
return 0 if ($Text !~ /[A-Z]/); # no upper case letter |
| 1526 |
return 0 if ($Text =~ /\d+/); # $Text contains title. |
| 1527 |
return 0 if ($Text =~ / (e-print|archive)s? /i); |
| 1528 |
return 0 if ($Text =~ /\b(Collaboration|Review)\b/i); |
| 1529 |
|
| 1530 |
my $wCount = word_count($Text); |
| 1531 |
return 0 if $wCount > 4; |
| 1532 |
|
| 1533 |
# "van Albada" or "van den Bergh" (surname only) |
| 1534 |
return 0 if ($Text =~ /^((v\.|von|van|de|den|der)\s+)+\S\S+\s*$/i); |
| 1535 |
# "van Buren D" |
| 1536 |
return 1 if ($Text =~ /^(von|van|de|den|der)\s+\S\S+\s+([a-z]+\s*)+$/i); |
| 1537 |
# (journal name) |
| 1538 |
return 0 if ($Text =~ /\b(Phy\.|Physics|Journal|The)\b/i); |
| 1539 |
# "J. Mod. Phys. D"; "Prog.Theor.Phys." |
| 1540 |
return 0 if ($Text =~ /^([a-z]+\.\s*)+[a-z]?\s*$/i); |
| 1541 |
# "Phys Rev A" |
| 1542 |
# return 0 if ($Text =~ /^([a-z][a-z]+(\.| )){2,}[a-z]\.?\s*$/i); |
| 1543 |
my @Abbr = (); |
| 1544 |
# "Class. Quantum Grav." |
| 1545 |
return 0 if (@Abbr = ($Text =~ /\S\S+?\./g) and |
| 1546 |
scalar(@Abbr) >1); |
| 1547 |
# "Nuovo Cim. B 44, 1 (1966)." |
| 1548 |
return 0 if ($Text =~ /\w\w\w+\./); |
| 1549 |
|
| 1550 |
# 'W. B. Burton', 'Burton W. B.', 'W B Burton', etc. |
| 1551 |
if (has_surname($Text) and |
| 1552 |
has_initials($Text) and |
| 1553 |
$wCount >= 1 and |
| 1554 |
$wCount < 5 ) { |
| 1555 |
return 1 |
| 1556 |
}; |
| 1557 |
|
| 1558 |
# 'Vivek Agrawal', 'Liu Xin' types; hard to distinguish |
| 1559 |
# surname/firstname. |
| 1560 |
if ($wCount >= 2 and |
| 1561 |
$wCount <= 3 and |
| 1562 |
no_initials($Text)) { |
| 1563 |
return 1 |
| 1564 |
}; |
| 1565 |
|
| 1566 |
return 0 |
| 1567 |
}; |
| 1568 |
|
| 1569 |
sub no_initials { |
| 1570 |
my $Text = shift; |
| 1571 |
|
| 1572 |
# do not count 'Jr.' |
| 1573 |
$Text =~ s/(\W)Jr\.?\s*$/$1/i; |
| 1574 |
return 0 if ($Text =~ /(^| )[a-z]\./i); |
| 1575 |
return 0 if ($Text =~ /(^| )[a-z]( |$)/i); |
| 1576 |
|
| 1577 |
return 1; |
| 1578 |
}; |
| 1579 |
|
| 1580 |
sub only_initials { |
| 1581 |
my $Text = shift; |
| 1582 |
|
| 1583 |
return 0 if ($Text =~ /^[a-z]{2,} /i); |
| 1584 |
return 0 if ($Text =~ /\.?\s*[a-z][a-z]+$/i); |
| 1585 |
|
| 1586 |
my @Words = split(/[\.\s]/, $Text); |
| 1587 |
my $Word; |
| 1588 |
foreach $Word (@Words) { return 0 if (length($Word) >= 2)}; |
| 1589 |
|
| 1590 |
return 1 |
| 1591 |
}; |
| 1592 |
|
| 1593 |
sub is_surname { |
| 1594 |
my ($Text) = @_; |
| 1595 |
$Text =~ s/ Jr\W+$//i; |
| 1596 |
|
| 1597 |
return 0 if ($Text =~ / (e-print|archive)s? /i); |
| 1598 |
return 0 if ($Text =~ /\bCollaboration\b/i); |
| 1599 |
|
| 1600 |
return 1 if ($Text =~ /^(\s*[a-z][\-'a-z]+){1,3}$/i); |
| 1601 |
# return 1 if ($Text =~ /^\s*[a-z]+[\-'a-z]+\s*$/i); |
| 1602 |
|
| 1603 |
return 0 |
| 1604 |
} |
| 1605 |
|
| 1606 |
sub has_surname { |
| 1607 |
my $Text = shift; |
| 1608 |
|
| 1609 |
return 0 if ($Text =~ /\d+/); |
| 1610 |
return 1 if ($Text =~ /^[a-z]{2,}[\s\-']/i); |
| 1611 |
# return 1 if ($Text =~ /[a-z]{2,}$/i); |
| 1612 |
return 1 if ($Text =~ /[\-'\s.][a-z][a-z]+(\s+Jr\.?)?\s*$/i); |
| 1613 |
return 0 |
| 1614 |
} |
| 1615 |
|
| 1616 |
sub has_initials { |
| 1617 |
my $Text = shift; |
| 1618 |
|
| 1619 |
return 0 if ($Text =~ /\d+/); |
| 1620 |
return 1 if ($Text =~ /^\s*[']?\s*[A-Z](\s|\.|$)/); |
| 1621 |
return 1 if ($Text =~ /(^|\s|\.)[a-z](\s|\.|$)/i); |
| 1622 |
|
| 1623 |
return 0 |
| 1624 |
} |
| 1625 |
|
| 1626 |
# mainly used to count 'words' in author names |
| 1627 |
sub word_count { |
| 1628 |
my ($Text) = @_; |
| 1629 |
|
| 1630 |
#$Text =~ s/^[\s.]+//; |
| 1631 |
#my @Words = split(/[\s.]+/, $Text); |
| 1632 |
# return scalar(@Words); |
| 1633 |
|
| 1634 |
$Text =~ s/ (von|van|de|den|der) //g; |
| 1635 |
$Text =~ s/^\s+//; |
| 1636 |
$Text =~ s/\s+$//; |
| 1637 |
my @Words_all = split(/\s+/, $Text); |
| 1638 |
# ignore initials in names. |
| 1639 |
# e.g. "C.A.R. Sa de Melo" is a name |
| 1640 |
my @Words; |
| 1641 |
my $W; |
| 1642 |
while (@Words_all) { |
| 1643 |
$W = shift @Words_all; |
| 1644 |
push(@Words, $W) if ($W !~ /^[a-z]\.?$/i); |
| 1645 |
}; |
| 1646 |
return scalar(@Words); |
| 1647 |
}; |
| 1648 |
|
| 1649 |
1; |
| 1650 |
|
| 1651 |
__END__ |
| 1652 |
|
| 1653 |
|
| 1654 |
=pod |
| 1655 |
|
| 1656 |
=back |
| 1657 |
|
| 1658 |
=head1 AUTHOR |
| 1659 |
|
| 1660 |
Original Author: |
| 1661 |
Zhuoan Jiao <[email protected]> |
| 1662 |
|
| 1663 |
Ported to Biblio interface by: |
| 1664 |
Mike Jewell <[email protected]> |
| 1665 |
|
| 1666 |
=cut |