Debian Codegraph @

texmf-dist/doc/latex/biblatex-gb7714-2015/gb7714texttobib.pl

raw
1 ##%
2 ##% ---------------------------------------------------------------
3 ##% gb7714texttobib--- A transformation tool for GB/T 7714-2015 style
4 ##% bibliography text to bib source file
5 ##%
6 ##% Maintained by huzhenzhen
7 ##% Homepage: <https://github.com/hushidong/biblatex-gb7714-2015>
8 ##% history:
9 ##% 2017/02/26 v1.0g
10 ##% 2021/09/04 add compatablity for text with no space after punctuations.
11 ##% 2023/09/13 change CJK punctuations to EN punct and add final dot.
12 ##% E-mail:
13 ##% [email protected]
14 ##% Released under the LaTeX Project Public License v1.3c or later
15 ##% usage:
16 ##% perl gb7714texttobib.pl in=textfilename out=bibfilename
17 ##% options(need to do):
18 ##% style=ay or default
19 ##% key=ay or default
20 ##%
21 ##% ---------------------------------------------------------------
22 #%Target:: 将pdf文档中拷出的参考文献文本转换成bib文件,文本文件中的一条参考文献为一行
23 #%Method:: 利用perl进行文本处理,处理和判断的两个重要方面是:
24 # 分析分割后的文本的位置和内容,使用的是正则表达式匹配,主要两种方式
25 # 1.根据标点和本文特征一部分一部分的解析,比如book条目处理
26 # 2.直接列出所有可能的正则表达式一个个匹配,比如article条目处理
27 #%Date :: 2017-02-22
28 #%Note :: 1.网址之类如果解析出错,应确认其前导词http://之前没有空格
29 # 2.有些以.连接有从属关系的机构作者,可以把.后的空格去掉便于正确解析
30 # 3.有些尽管解析到的域不是真实的域,但不影响著录格式(显示效果),相应条目的域
31 # 可以在bib文件中完善,尽管从实用角度并不需要这么做。
32 #
33 ##% ---------------------------------------------------------------
34 ##% note:
35 ##% 1. 对于英文的姓名若非标准的国标写法,通常当做机构作者处理,所以生成的bib文件需要自己手动处理
36 ##% obsolete intro:
37 ##% 1.源文件文档如果个别地方不符合规范,可以修改一下
38 ##% (a):inbook/standard类中,当出现//后面第二项是booktitle且其中存在:时,先把父标题的冒号改成colon,比如
39 ##% [M]//李承森. 宋史: 第 1 册. 北京: 中华书局. 应把宋史后的冒号改掉
40 ##% [S]//全国文献工作标准化技术委员会. 文献工作国家标准汇编: 3. 北京: 中国标准出版社, 1988: 59–92.
41 ##% ---------------------------------------------------------------
42
43
44 foreach $file(@ARGV){
45 print 'file:',$file,"\n";
46 if($file=~m/in=/){
47 ($infile)=($file=~m/in=(.*)/)
48 }
49 if($file=~m/out=/){
50 ($outfile)=($file=~m/out=(.*)/)
51 }
52 }
53
54 open (FHR,"<$infile");
55 open (FHW,">$outfile");
56 print FHW '% Encoding: UTF-8',"\n";
57
58 @references=<FHR>;#将所有的文献存为@references数组,各文献以<行>为单位进行区分
59
60
61 #20230913,hzz,将条目中的中文全角标点转换为英文的
62 foreach $stra (@references) {
63 print "orig: $stra\n";
64 $stra=~s/,/\,/g;
65 $stra=~s/:/\:/g;
66 $stra=~s/;/\,/g;
67 print "modf: $stra\n";
68 }
69
70
71 #20230913,hzz,若条目最后没有点先加上点
72 foreach $stra (@references) {
73 print "orig: $stra\n";
74 if ($stra=~m/\.$/ || $stra=~m/\.\s*$/)
75 {
76 print "str ened with dot\n";
77 }
78 else
79 {
80 #$stra=$stra+'.'; #不能这么直接加
81 $stra=~s/(.*)/$1\./;
82 print "add dot for str end without dot\n";
83 print "modf: $stra\n";
84 }
85 }
86
87
88 #有些文本标点后面没有空格,所以先对这个问题进行处理
89 #在所有的关键标点后面加上空格
90 #20210904,HZZ
91 foreach $stra (@references) {
92 print "orig: $stra\n";
93 $stra=~s/\.(\S)/\. $1/g;
94 $stra=~s/\,(\S)/\, $1/g;
95 $stra=~s/\:(\S)/\: $1/g;
96 print "modf: $stra\n";
97 }
98 print "@references\n";
99
100
101
102
103
104
105 $ns=1;
106 $ne=@references;
107 $nline=0;
108 foreach $reference(@references){
109
110 $nline=$nline+1;
111 if($nline<$ns){next;} #先跳过几行进行,配合后面的last进行当行测试
112
113 while($reference=~m/–/){
114 $reference=~s/–/-/;#直接利用正则表达式更正页码/日期/网址中的连字符
115 }
116 print "ref: $reference ";#打印各文献的内容
117
118 $lenstr=length($reference);
119 print "lenstr=$lenstr\n";
120 $lenstr=rindex $reference."\$","\$";
121 print "lenstr=$lenstr\n";
122
123 if ($lenstr>1){
124 undef $entrytype;
125 undef $author;
126 undef $title;
127 undef $journal;
128 undef $translator;
129 undef $bookauthor;
130 undef $booktitle;
131 undef $version;
132 undef $address;
133 undef $publisher;
134 undef $institution;
135 undef $year;
136 undef $type;
137 undef $date;
138 undef $volume;
139 undef $number;
140 undef $pages;
141 undef $eventdate;
142 undef $urldate;
143 undef $url;
144 undef $doi;
145 undef $note;
146 undef $eventyvn;
147 undef $endeventyvn;
148 undef $eventdate;
149 undef $eventvol;
150 undef $eventnum;
151 undef $endeventdate;
152 undef $endeventvol;
153 undef $endeventnum;
154
155 #---------------------------------------------------------------
156 #条目类型:期刊和期刊中析出的文献/periodical、article
157 #---------------------------------------------------------------
158 if(1){
159 if($reference=~m/\[J\]/){
160 #避免在标题中存在在冒号的问题,所以从[J]开始匹配,通常也不需要从[J/OL]开始因为periodical通常不会出现online
161 #2021.09.04,hzz,修改
162 if($reference=~m/:\s/ and $reference=~m/\[J\].*:\s\D/){#根据存在出版社前的冒号加空格区分
163 print 'this entry is periodical',"\n";
164 $entrytype='periodical';
165 }else{
166 print 'this entry is article',"\n";
167 $entrytype='article';
168 }
169 }
170
171 if($entrytype eq 'periodical'){#字符串比较用eq而数字比较用==,如果用==那么两边都是1,则是真
172 $regexformach='\[J\]\.';
173 &bfidentifier;
174
175 ($preadderess, $pospublisher)=($reference=~m/\[J\]\.(.*):\s(.*)/);
176 print 'preadderess =',$preadderess,"\n";
177 print 'pospublisher=',$pospublisher,"\n";
178 ($eventyear, $address)=($preadderess=~m/(.*)\.\s(.*)/);
179 print 'eventyear =',$eventyear,"\n";
180 print 'address =',$address,"\n";
181 ($eventyvn, $endeventyvn)=($eventyear=~m/(.*)\-(.*)/);#yvn表示year,volume,number
182 print 'eventyvn =',$eventyvn,"\n";
183 print 'endeventyvn =',$endeventyvn,"\n";
184 if($eventyvn=~m/.*,.*/){#存在逗号表明有卷信息
185 ($eventdate, $eventvol, $eventnum)=($eventyvn=~m/\s*(.*),\s(.*)\((.*)\)/);#yvn表示year,volume,number
186 print 'eventdate =',$eventdate,"\n";
187 print 'eventvol =',$eventvol,"\n";
188 print 'eventnum =',$eventnum,"\n";
189 if($endeventyvn){
190 ($endeventdate, $endeventvol, $endeventnum)=($endeventyvn=~m/\s*(.*),\s(.*)\((.*)\)/);#yvn表示year,volume,number
191 print 'endeventdate =',$endeventdate,"\n";
192 print 'endeventvol =',$endeventvol,"\n";
193 print 'endeventnum =',$endeventnum,"\n";
194 }
195 }else{
196 ($eventdate, $eventnum)=($eventyvn=~m/\s*(.*)\((.*)\)/);#yvn表示year,volume,number
197 print 'eventdate =',$eventdate,"\n";
198 print 'eventvol =',$eventvol,"\n";
199 print 'eventnum =',$eventnum,"\n";
200 if($endeventyvn){
201 ($endeventdate, $endeventnum)=($endeventyvn=~m/\s*(.*)\((.*)\)/);#yvn表示year,volume,number
202 print 'endeventdate =',$endeventdate,"\n";
203 print 'endeventvol =',$endeventvol,"\n";
204 print 'endeventnum =',$endeventnum,"\n";
205 }
206 }
207 if($endeventdate){
208 $date=$eventdate.'-'.$endeventdate;
209 }else{
210 $date=$eventdate
211 }
212 if($endeventvol){
213 $volume=$eventvol.'-'.$endeventvol;
214 }else{
215 $volume=$eventvol
216 }
217 if($endeventnum){
218 $number=$eventnum.'-'.$endeventnum;
219 }else{
220 $number=$eventnum
221 }
222 print 'date =',$date,"\n";
223 print 'volume =',$volume,"\n";
224 print 'number =',$number,"\n";
225 ($publisher)=($pospublisher=~m/(.*),/);
226 print 'publisher =',$publisher,"\n";
227 }
228
229 if($entrytype eq 'article'){
230 $regexformach='\[J\]\.';
231 &bfidentifier;
232
233 $flagmatched=0;
234 $regexbfjournal='\]\.\s(.*),\s(.*),\s(.*)\((.*)\):\s(.*)\.';#包括全部信息
235 if($reference=~m/$regexbfjournal/){
236 ($journal,$date,$volume,$number,$pages)=($reference=~m/$regexbfjournal/);
237 $flagmatched=1;
238 print '包括全部信息',"\n";
239 }
240 $regexbfjournal='\]\.\s(.*),\s(.*),\s(.*)\((.*)\)\.';#没有页码
241 if($reference=~m/$regexbfjournal/ and $flagmatched==0){
242 ($journal,$date,$volume,$number)=($reference=~m/$regexbfjournal/);
243 $flagmatched=1;
244 print '没有页码',"\n";
245 }
246 $regexbfjournal='\]\.\s(.*),\s(.*),\s(.*):\s(.*)\.';#没有期
247 if($reference=~m/$regexbfjournal/ and $flagmatched==0){
248 ($journal,$date,$volume,$pages)=($reference=~m/$regexbfjournal/);
249 $flagmatched=1;
250 print '没有期',"\n";
251 }
252 $regexbfjournal='\]\.\s(.*),\s(.*)\((.*)\):\s(.*)\.';#没有卷/年
253 if($reference=~m/$regexbfjournal/ and $flagmatched==0){
254 ($journal,$date,$number,$pages)=($reference=~m/$regexbfjournal/);
255 $flagmatched=1;
256 if($date!~m/\d{4}/){
257 $volume=$date;
258 $date='';
259 }
260 print '没有卷/年',"\n";
261 }
262 $regexbfjournal='\]\.\s(.*),\s(.*),\s(.*)\.';#没有页码,期
263 if($reference=~m/$regexbfjournal/ and $flagmatched==0){
264 ($journal,$date,$volume)=($reference=~m/$regexbfjournal/);
265 $flagmatched=1;
266 print '没有页码,期',"\n";
267 }
268 $regexbfjournal='\]\.\s(.*),\s(.*)\((.*)\)\.';#没有页码,卷/年
269 if($reference=~m/$regexbfjournal/ and $flagmatched==0){
270 ($journal,$date,$number)=($reference=~m/$regexbfjournal/);
271 $flagmatched=1;
272 if($date!~m/\d{4}/){
273 $volume=$date;
274 $date='';
275 }
276 print '没有页码,卷/年',"\n";
277 }
278 $regexbfjournal='\]\.\s(.*),\s(.*):\s(.*)\.';#没有卷/年,期
279 if($reference=~m/$regexbfjournal/ and $flagmatched==0){
280 ($journal,$date,$pages)=($reference=~m/$regexbfjournal/);
281 $flagmatched=1;
282 if($date!~m/\d{4}/){
283 $volume=$date;
284 $date='';
285 }
286 print '没有卷/年,期',"\n";
287 }
288
289 if($flagmatched==0){
290 print 'the text after title was not matched, please add a regex for the current entry in the perl source code!',"\n";
291 print '当前条目标题之后的内容没有匹配的正则表达式,请在perl代码中增加适合该条目正则表达式!',"\n";
292 }
293
294 print 'journal =',$journal,"\n";
295 print 'date =',$date,"\n";
296 print 'volume =',$volume,"\n";
297 print 'number =',$number,"\n";
298 print 'pages =',$pages,"\n";
299
300 }
301
302 #判断期刊中析出的文献,带url
303 if($reference=~m/\[J\/OL\]/){
304 print 'this entry is article with url',"\n";
305 $entrytype='article';
306
307 $regexformach='\[J\/OL\]\.';
308 &bfidentifier;
309
310 ($postitle)=($reference=~m/\[J\/OL\]\.\s(.*)/);
311 if($postitle=~m/\[.*\]/){#存在urldate
312 ($preurldate,$urldate,$posurl)=($postitle=~m/(.*)\[(.*)\]\.\s(.*)/);
313 }else{#不存在urldate
314 ($preurldate,$posurl)=($postitle=~m/(.*)(http:.*)/);
315 }
316 unless($preurldate=~m/\.$/){$preurldate=$preurldate.'.';}#加个点统一上面两种方式
317
318 #处理url和doi
319 $regexposurl='(.*)doi:\s(.*)';#处理url和doi
320 if($posurl=~m/$regexposurl/i){
321 ($url,$doi)=($posurl=~m/$regexposurl/i);
322 }else{
323 $url=$posurl;
324 }
325
326 #处理urldate前的内容,基本article不带url的情况相同
327 $flagmatched=0;
328 $regexbfjournal='(.*),\s(.*),\s(.*)\((.*)\):\s(.*)\.';#包括全部信息
329 if($preurldate=~m/$regexbfjournal/ and $flagmatched==0){
330 ($journal,$date,$volume,$number,$pages)=($preurldate=~m/$regexbfjournal/);
331 $flagmatched=1;
332 }
333 $regexbfjournal='(.*),\s(.*),\s(.*)\((.*)\)\.';#没有页码
334 if($preurldate=~m/$regexbfjournal/ and $flagmatched==0){
335 ($journal,$date,$volume,$number)=($preurldate=~m/$regexbfjournal/);
336 $flagmatched=1;
337 }
338 $regexbfjournal='(.*),\s(.*),\s(.*):\s(.*)\.';#没有期
339 if($preurldate=~m/$regexbfjournal/ and $flagmatched==0){
340 ($journal,$date,$volume,$pages)=($preurldate=~m/$regexbfjournal/);
341 $flagmatched=1;
342 }
343 $regexbfjournal='(.*),\s(.*)\((.*)\):\s(.*)\.';#没有卷/年
344 if($preurldate=~m/$regexbfjournal/ and $flagmatched==0){
345 ($journal,$date,$number,$pages)=($preurldate=~m/$regexbfjournal/);
346 $flagmatched=1;
347 if($date!~m/\d{4}/){
348 $volume=$date;
349 $date='';
350 }
351 }
352 $regexbfjournal='(.*),\s(.*),\s(.*)\.';#没有页码,期
353 if($preurldate=~m/$regexbfjournal/ and $flagmatched==0){
354 ($journal,$date,$volume)=($preurldate=~m/$regexbfjournal/);
355 $flagmatched=1;
356 }
357 $regexbfjournal='(.*),\s(.*)\((.*)\)\.';#没有页码,卷/年
358 if($preurldate=~m/$regexbfjournal/ and $flagmatched==0){
359 ($journal,$date,$number)=($preurldate=~m/$regexbfjournal/);
360 $flagmatched=1;
361 if($date!~m/\d{4}/){
362 $volume=$date;
363 $date='';
364 }
365 }
366 $regexbfjournal='(.*),\s(.*):\s(.*)\.';#没有卷/年,期
367 if($preurldate=~m/$regexbfjournal/ and $flagmatched==0){
368 ($journal,$date,$pages)=($preurldate=~m/$regexbfjournal/);
369 $flagmatched=1;
370 if($date!~m/\d{4}/){
371 $volume=$date;
372 $date='';
373 }
374 }
375
376 if($flagmatched==0){
377 print 'the text after title was not matched, please add a regex for the current entry in the perl source code!',"\n";
378 print '当前条目标题之后的内容没有匹配的正则表达式,请在perl代码中增加适合该条目正则表达式!',"\n";
379 }
380
381 print 'journal =',$journal,"\n";
382 print 'date =',$date,"\n";
383 print 'volume =',$volume,"\n";
384 print 'number =',$number,"\n";
385 print 'pages =',$pages,"\n";
386 print 'urldate =',$urldate,"\n";
387 print 'url =',$url,"\n";
388 print 'doi =',$doi,"\n";
389
390
391 }
392 }
393
394 #---------------------------------------------------------------
395 #条目类型:判断报纸中析出的文献/newspaper
396 #---------------------------------------------------------------
397 if(1){
398 if($reference=~m/\[N\]/){
399 print 'this entry is newspaper',"\n";
400 $entrytype='newspaper';
401 $note='news';
402 $regexnewsflag='\[N\]';
403 $onlineflag=0;
404 }
405 if($reference=~m/\[N\/OL\]/){
406 print 'this entry is newspaper with url',"\n";
407 $entrytype='newspaper';
408 $note='news';
409 $regexnewsflag='\[N\/OL\]';
410 $onlineflag=1;
411 }
412 if($entrytype eq 'newspaper'){
413 if($onlineflag==1){
414 $regexformach='\[N\/OL\]';
415 &bfidentifier;
416
417 print 'has url',"\n";
418 $flagmatched=0;
419 $regexnewspostitle='\.\s(.*),\s(.*)\((.*)\)\s*\[(.*)\]\.\s(.*)';
420 if($reference=~m/$regexnewsflag$regexnewspostitle/ and $flagmatched==0){
421 $flagmatched=1;
422 ($journal,$date,$number,$urldate,$posurl)=($reference=~m/$regexnewsflag$regexnewspostitle/);}
423 $regexnewspostitle='\.\s(.*),\s(.*)\s*\[(.*)\]\.\s(.*)';
424 if($reference=~m/$regexnewsflag$regexnewspostitle/ and $flagmatched==0){
425 $flagmatched=1;
426 ($journal,$date,$urldate,$posurl)=($reference=~m/$regexnewsflag$regexnewspostitle/);}
427 if($flagmatched==0){
428 print 'the text after title was not matched, please add a regex for the current entry in the perl source code!',"\n";
429 print '当前条目标题之后的内容没有匹配的正则表达式,请在perl代码中增加适合该条目正则表达式!',"\n";
430 }
431 }else{
432 $regexformach='\[N\]';
433 &bfidentifier;
434
435 print 'no url',"\n";
436 $regexnewspostitle='\.\s(.*),\s(.*)\((.*)\)';
437 ($journal,$date,$number)=($reference=~m/$regexnewsflag$regexnewspostitle/);
438 }
439 #处理url和doi
440 $regexposurl='(.*)doi:\s(.*)';#处理url和doi
441 if($posurl=~m/$regexposurl/i){
442 ($url,$doi)=($posurl=~m/$regexposurl/i);
443 }else{
444 $url=$posurl;
445 }
446
447 # print 'journal =',$journal,"\n";
448 # print 'date =',$date,"\n";
449 # print 'volume =',$volume,"\n";
450 # print 'number =',$number,"\n";
451 # print 'pages =',$pages,"\n";
452 # print 'urldate =',$urldate,"\n";
453 # print 'url =',$url,"\n";
454 # print 'doi =',$doi,"\n";
455 }
456 }
457
458
459 #---------------------------------------------------------------
460 #条目类型:论文集中析出的文献/inproceedings
461 #---------------------------------------------------------------
462 if(1){#\/\/
463 if ($reference=~m/\[C\/OL\]\/\//){
464 $entrytype='inproceedings';
465 print "this entry's type is: $entrytype with url\n";
466 $regexformach='\[C\/OL\]\/\/';
467 &bfidentifier;
468
469 $regexformach='C\/OL\]\/\/';
470 &bfaddressinbook;
471
472 &afpublisherbookurl;
473 }elsif($reference=~m/\[C\]\/\//){
474 $entrytype='inproceedings';
475 print "this entry's type is: $entrytype \n";
476 $regexformach='\[C\]\/\/';
477 &bfidentifier;
478
479 $regexformach='C\]\/\/';
480 &bfaddressinbook;
481
482 &afpublisherbook;
483 }
484
485 if ($entrytype eq 'inproceedings'){
486 if ($address=~m/\[S\.l\.\]/ or $address=~m/出版地不详/) {#当存在英文的[s.n.]
487 $address="";
488 }
489 if ($publisher=~m/\[s\.n\.\]/ or $publisher=~m/出版者不详/) {#当存在英文的[s.n.]
490 $publisher="";
491 }
492 $date=$year;
493 }
494
495 }
496
497
498 #---------------------------------------------------------------
499 #条目类型:论文集/proceedings
500 #---------------------------------------------------------------
501 if(1){
502 if ($reference=~m/\[C\/OL\]\./){
503 $entrytype='proceedings';
504 print "this entry's type is: $entrytype with url\n";
505 $regexformach='\[C\/OL\]\.';
506 &bfidentifier;
507
508 $regexformach='C\/OL\]\.';
509 &bfaddressbook;
510
511 &afpublisherbookurl;
512 }elsif($reference=~m/\[C\]\./){
513 $entrytype='proceedings';
514 print "this entry's type is: $entrytype \n";
515 $regexformach='\[C\]\.';
516 &bfidentifier;
517
518 $regexformach='C\]\.';
519 &bfaddressbook;
520
521 &afpublisherbook;
522 }
523
524 if ($entrytype eq 'proceedings'){
525 if ($address=~m/\[S\.l\.\]/ or $address=~m/出版地不详/) {#当存在英文的[s.n.]
526 $address="";
527 }
528 if ($publisher=~m/\[s\.n\.\]/ or $publisher=~m/出版者不详/) {#当存在英文的[s.n.]
529 $publisher="";
530 }
531 $date=$year;
532 print 'date=',"$date";
533 }
534 }
535
536
537
538
539 #---------------------------------------------------------------
540 #条目类型:未出版物/unpublished
541 #---------------------------------------------------------------
542 if(1){
543 if ($reference=~m/\[Z\/OL\]\./){
544 $entrytype='unpublished';
545 print "this entry's type is: $entrytype with url\n";
546 $regexformach='\[Z\/OL\]\.';
547 &bfidentifier;
548
549 $regexformach='Z\/OL\]\.';
550 &bfaddressbook;
551
552 &afpublisherbookurlb;
553 }elsif($reference=~m/\[Z\]\./){
554 $entrytype='unpublished';
555 print "this entry's type is: $entrytype \n";
556 $regexformach='\[Z\]\.';
557 &bfidentifier;
558
559 $regexformach='Z\]\.';
560 &bfaddressbook;
561
562 &afpublisherbookb;
563 }
564
565 if ($entrytype eq 'unpublished'){
566 $date=$year;
567 print 'date=',"$date";
568 }
569 }
570
571
572 #---------------------------------------------------------------
573 #条目类型:手册、档案/manual
574 #---------------------------------------------------------------
575 if(1){
576 if ($reference=~m/\[A\/OL\]\./){
577 $entrytype='manual';
578 print "this entry's type is: $entrytype with url\n";
579 $regexformach='\[A\/OL\]\.';
580 &bfidentifier;
581
582 $regexformach='A\/OL\]\.';
583 &bfaddressbook;
584
585 &afpublisherbookurlb;
586 }elsif($reference=~m/\[A\]\./){
587 $entrytype='manual';
588 print "this entry's type is: $entrytype \n";
589 $regexformach='\[A\]\.';
590 &bfidentifier;
591
592 $regexformach='A\]\.';
593 &bfaddressbook;
594
595 &afpublisherbookb;
596 }
597
598 if ($entrytype eq 'manual'){
599 $date=$year;
600 print 'date=',"$date";
601 }
602 }
603
604
605
606 #---------------------------------------------------------------
607 #条目类型:报告/report
608 #---------------------------------------------------------------
609 if(1){
610 if ($reference=~m/\[R\/OL\]\./){
611 $entrytype='report';
612 print "this entry's type is: $entrytype with url\n";
613 $regexformach='\[R\/OL\]\.';
614 &bfidentifier;
615
616 $regexformach='R\/OL\]\.';
617 &bfaddressbook;
618
619 &afpublisherbookurlb;
620 }elsif($reference=~m/\[R\]\./){
621 $entrytype='report';
622 print "this entry's type is: $entrytype \n";
623 $regexformach='\[R\]\.';
624 &bfidentifier;
625
626 $regexformach='R\]\.';
627 &bfaddressbook;
628
629 &afpublisherbookb;
630 }
631
632 if ($entrytype eq 'report'){
633 $date=$year;
634 print 'date=',"$date";
635 }
636
637 }
638
639 #---------------------------------------------------------------
640 #条目类型:标准/standard
641 #---------------------------------------------------------------
642 if(1){
643 if ($reference=~m/\[S\/OL\]\./){
644 $entrytype='standard';
645 print "this entry's type is: $entrytype with url\n";
646 $regexformach='\[S\/OL\]\.';
647 &bfidentifier;
648
649 $regexformach='S\/OL\]\.';
650 &bfaddressbook;
651 &afpublisherbookurl;
652 }elsif($reference=~m/\[S\]\./){
653 $entrytype='standard';
654 print "this entry's type is: $entrytype \n";
655 $regexformach='\[S\]\.';
656 &bfidentifier;
657
658 $regexformach='S\]\.';
659 &bfaddressbook;
660
661 &afpublisherbook;
662 }elsif ($reference=~m/\[S\/OL\]\/\//){
663 $entrytype='standard';
664 print "this entry's type is: $entrytype with url\n";
665 $regexformach='\[S\/OL\]\/\/';
666 &bfidentifier;
667
668 $regexformach='S\/OL\]\/\/';
669 &bfaddressinbook;
670
671 &afpublisherbookurl;
672 }elsif($reference=~m/\[S\]\/\//){
673 $entrytype='standard';
674 print "this entry's type is: $entrytype \n";
675 $regexformach='\[S\]\/\/';
676 &bfidentifier;
677
678 $regexformach='S\]\/\/';
679 &bfaddressinbook;
680
681 &afpublisherbook;
682 }
683 if ($entrytype eq 'standard'){
684 if ($address=~m/\[S\.l\.\]/ or $address=~m/出版地不详/) {#当存在英文的[s.n.]
685 $address="";
686 }
687 if ($publisher=~m/\[s\.n\.\]/ or $publisher=~m/出版者不详/) {#当存在英文的[s.n.]
688 $publisher="";
689 }
690 $date=$year;
691 $note='standard';
692 print 'date=',"$date";
693 print 'note=',"$note";
694 }
695
696 }
697
698 #---------------------------------------------------------------
699 #条目类型:学位论文/thesis
700 #---------------------------------------------------------------
701 if(1){
702 if ($reference=~m/\[D\/OL\]\./){
703 $entrytype='thesis';
704 print "this entry's type is: $entrytype with url\n";
705 $regexformach='\[D\/OL\]\.';
706 &bfidentifier;
707
708 $regexformach='D\/OL\]\.';
709 &bfaddressbook;
710
711 &afpublisherbookurl;
712 }elsif($reference=~m/\[D\]\./){
713 $entrytype='thesis';
714 print "this entry's type is: $entrytype \n";
715 $regexformach='\[D\]\.';
716 &bfidentifier;
717
718 $regexformach='D\]\.';
719 &bfaddressbook;
720
721 &afpublisherbook;
722 }
723
724 if ($entrytype eq 'thesis'){
725 if ($address=~m/\[S\.l\.\]/ or $address=~m/出版地不详/) {#当存在英文的[s.n.]
726 $address="";
727 }
728 if ($publisher=~m/\[s\.n\.\]/ or $publisher=~m/出版者不详/) {#当存在英文的[s.n.]
729 $publisher="";
730 }
731 $date=$year;
732 print 'date=',"$date";
733 }
734
735 }
736
737
738 #---------------------------------------------------------------
739 #条目类型:汇编中析出的文献/incollection
740 #---------------------------------------------------------------
741 if(1){#\/\/
742 if ($reference=~m/\[G\/OL\]\/\//){
743 $entrytype='incollection';
744 print "this entry's type is: $entrytype with url\n";
745 $regexformach='\[G\/OL\]\/\/';
746 &bfidentifier;
747
748 $regexformach='G\/OL\]\/\/';
749 &bfaddressinbook;
750
751 &afpublisherbookurl;
752 }elsif($reference=~m/\[G\]\/\//){
753 $entrytype='incollection';
754 print "this entry's type is: $entrytype \n";
755 $regexformach='\[G\]\/\/';
756 &bfidentifier;
757
758 $regexformach='G\]\/\/';
759 &bfaddressinbook;
760
761 &afpublisherbook;
762 }
763
764 if ($entrytype eq 'incollection'){
765 if ($address=~m/\[S\.l\.\]/ or $address=~m/出版地不详/) {#当存在英文的[s.n.]
766 $address="";
767 }
768 if ($publisher=~m/\[s\.n\.\]/ or $publisher=~m/出版者不详/) {#当存在英文的[s.n.]
769 $publisher="";
770 }
771 $date=$year;
772 }
773
774 }
775
776
777 #---------------------------------------------------------------
778 #条目类型:汇编/collection
779 #---------------------------------------------------------------
780 if(1){
781 if ($reference=~m/\[G\/OL\]\./){
782 $entrytype='collection';
783 print "this entry's type is: $entrytype with url\n";
784 $regexformach='\[G\/OL\]\.';
785 &bfidentifier;
786
787 $regexformach='G\/OL\]\.';
788 &bfaddressbook;
789
790 &afpublisherbookurl;
791 }elsif($reference=~m/\[G\]\./){
792 $entrytype='collection';
793 print "this entry's type is: $entrytype \n";
794 $regexformach='\[G\]\.';
795 &bfidentifier;
796
797 $regexformach='G\]\.';
798 &bfaddressbook;
799
800 &afpublisherbook;
801 }
802
803 if ($entrytype eq 'collection'){
804 if ($address=~m/\[S\.l\.\]/ or $address=~m/出版地不详/) {#当存在英文的[s.n.]
805 $address="";
806 }
807 if ($publisher=~m/\[s\.n\.\]/ or $publisher=~m/出版者不详/) {#当存在英文的[s.n.]
808 $publisher="";
809 }
810 $date=$year;
811 print 'date=',"$date";
812 }
813 }
814
815
816 #---------------------------------------------------------------
817 #条目类型:专利/patent
818 #---------------------------------------------------------------
819 if(1){
820 if ($reference=~m/\[P\/OL\]\./){
821 $entrytype='patent';
822 print "this entry's type is: $entrytype with url\n";
823 $regexformach='\[P\/OL\]\.';
824 &bfidentifier;
825 }elsif($reference=~m/\[P\]\./){
826 $entrytype='patent';
827 print "this entry's type is: $entrytype \n";
828 $regexformach='\[P\]\.';
829 &bfidentifier;
830 }
831
832 if($entrytype eq 'patent'){
833 ($postitle)=($reference=~m/$regexformach\s*(.*)/);
834 print 'postitle=',$postitle,"\n";
835 $titlenumber=$title;
836 if($titlenumber=~m/:\s*\d.*/){
837 ($title,$number)=($titlenumber=~m/(.*):\s*(\d.*)/);
838 print 'title =',$title,"\n";
839 print 'number =',$number,"\n";
840 }
841
842 if($postitle=~m/\[.*\]/ and $reference=~m/\[P\/OL\]\./){
843 ($date,$urldate,$posurl)=($postitle=~/(.*)\s*\[(.*)\]\.\s*(.*)/);
844 print 'date=',$date,"\n";
845 print 'urldate =',$urldate,"\n";
846 print 'posurl =',$posurl,"\n";
847 if($posurl=~m/DOI/i){#匹配存在doi的话
848 ($url,$doi)=($posurl=~m/(.*)DOI:(.*)\./i);
849 print 'url=',"$url \n";
850 print 'doi=',"$doi \n";
851 }else{
852 $url=$posurl;
853 print 'url =',"$url \n";
854 }
855 }else{
856 $posurl=$postitle;
857 if($posurl=~m/DOI/i){#匹配存在doi的话
858 ($date,$doi)=($posurl=~m/(.*)DOI:(.*)\./i);
859 print 'date=',"$date \n";
860 print 'doi =',"$doi \n";
861 }else{
862 $date=$posurl;
863 print 'date =',"$date \n";
864 }
865 }
866 }
867 }
868
869
870 #---------------------------------------------------------------
871 #条目类型:电子资源/online
872 #---------------------------------------------------------------
873 if(1){
874 if ($reference=~m/\[EB\/OL\]\./){#匹配[EB/OL]判断为online类型
875 $entrytype='online';
876 print "this entry's type is: $entrytype \n";
877
878 $regexformach='\[EB\/OL\]\.';
879 &bfidentifier;
880
881 ($postitle)=($reference=~m/$regexformach\s*(.*)/);
882 print 'postitle=',$postitle,"\n";
883
884 if($postitle=~m/\(.*\)/ and $postitle=~m/\[.*\]/){#存在更新日期和引用日期
885 ($eventdate,$urldate,$posurl)=($postitle=~/\s*\((.*)\)\s*\[(.*)\]\.\s*(.*)/);
886 }elsif($postitle=~m/\(.*\)/ and $postitle!~m/\[.*\]/){#存在更新日期但无引用日期
887 ($eventdate,$posurl)=($postitle=~/\s*\((.*)\)\.\s*(.*)/);
888 }elsif($postitle!~m/\(.*\)/ and $postitle=~m/\[.*\]/){#存在引用日期但无更新日期
889 ($urldate,$posurl)=($postitle=~/\s*\[(.*)\]\.\s*(.*)/);
890 }else{
891 ($posurl)=($postitle=~/\s*(.*)/);
892 }
893 print 'eventdate=',$eventdate,"\n";
894 print 'urldate =',$urldate,"\n";
895 print 'posurl =',$posurl,"\n";
896
897 if($posurl=~m/DOI/i){#匹配存在doi的话
898 ($url,$doi)=($posurl=~m/(.*)DOI:(.*)\./i);
899 print 'url=',"$url \n";
900 print 'doi=',"$doi \n";
901 }else{
902 $url=$posurl;
903 print 'url =',"$url \n";
904 }
905 }
906 }
907
908 #---------------------------------------------------------------
909 #条目类型:专著/book
910 #---------------------------------------------------------------
911 if(1){
912 if ($reference=~m/\[M\]\./){#匹配[M]判断为book类型
913 print "this entry's type is: book \n";
914 $entrytype='book';
915
916 $regexformach='\[M\]\.';
917 &bfidentifier;
918
919 $regexformach='M\]\.';
920 &bfaddressbook;
921
922 &afpublisherbook;
923
924 if ($address=~m/\[S\.l\.\]/ or $address=~m/出版地不详/) {#当存在英文的[s.n.]
925 $address="";
926 }
927 if ($publisher=~m/\[s\.n\.\]/ or $publisher=~m/出版者不详/) {#当存在英文的[s.n.]
928 $publisher="";
929 }
930 $date=$year;
931 }
932 }
933
934 #---------------------------------------------------------------
935 #条目类型:专著但存在网址/book with url
936 #---------------------------------------------------------------
937 if(1){
938 if ($reference=~m/\[M\/OL\]\./){
939 print "this entry's type is: book with url\n";
940 $entrytype='book';
941
942 $regexformach='\[M\/OL\]\.';
943 &bfidentifier;
944
945 $regexformach='M\/OL\]\.';
946 &bfaddressbook;
947
948 &afpublisherbookurl;
949
950
951 if ($address=~m/\[S\.l\.\]/ or $address=~m/出版地不详/) {#当存在英文的[s.n.]
952 $address="";
953 }
954 if ($publisher=~m/\[s\.n\.\]/ or $publisher=~m/出版者不详/) {#当存在英文的[s.n.]
955 $publisher="";
956 }
957 $date=$year;
958 }
959 }
960
961
962 #---------------------------------------------------------------
963 #条目类型:专著中析出文献/inbook
964 #---------------------------------------------------------------
965 if(1){
966 if ($reference=~m/\[M\]\/\//){#匹配[M]//判断为inbook类型
967 print "this entry's type is: inbook \n";
968 $entrytype='inbook';
969
970 $regexformach='\[M\]\/\/';
971 &bfidentifier;
972
973 $regexformach='M\]\/\/';
974 &bfaddressinbook;
975
976 &afpublisherbook;#出版社及之后的信息inbook/book一样的
977
978
979 if ($address=~m/\[S\.l\.\]/ or $address=~m/出版地不详/) {#当存在英文的[s.n.]
980 $address="";
981 }
982 if ($publisher=~m/\[s\.n\.\]/ or $publisher=~m/出版者不详/) {#当存在英文的[s.n.]
983 $publisher="";
984 }
985 $date=$year;
986 }
987 }
988
989
990 #---------------------------------------------------------------
991 #条目类型:专著中析出文献但存在网址/inbook with url
992 #---------------------------------------------------------------
993 if(1){
994 if ($reference=~m/\[M\/OL\]\/\//){#匹配[M]//判断为inbook类型
995 print "this entry's type is: inbook \n";
996 $entrytype='inbook';
997
998
999 $regexformach='\[M\/OL\]\/\/';
1000 &bfidentifier;
1001
1002 $regexformach='M\/OL\]\/\/';
1003 &bfaddressinbook;
1004
1005 &afpublisherbookurl;#出版社及之后的信息inbook/book一样的
1006
1007
1008 if ($address=~m/\[S\.l\.\]/ or $address=~m/出版地不详/) {#当存在英文的[s.n.]
1009 $address="";
1010 }
1011 if ($publisher=~m/\[s\.n\.\]/ or $publisher=~m/出版者不详/) {#当存在英文的[s.n.]
1012 $publisher="";
1013 }
1014 $date=$year;
1015 }
1016 }
1017
1018
1019 #---------------------------------------------------------------
1020 #输出到bib文件中
1021 #---------------------------------------------------------------
1022 if(1){
1023 if($date=~m/-\d{4}/){#存在enddate的情况下,将中间的连字符转化成斜杠
1024 print 'date=',$date,"\n";
1025 ($datetempa,$datetempb)=($date=~m/(.*)-(\d{4}.*)/);
1026 $date=$datetempa.'/'.$datetempb;
1027 print 'date=',$date,"\n";
1028 }
1029
1030 if($url=~m/.*\.$/){
1031 $urlplusdot=$url;
1032 ($url)=($urlplusdot=~m/(.*)\.$/);#去掉处于条目末尾的url地址后的点
1033 }
1034 #最后输出
1035 print "\n";
1036 print 'authorlabel=',$authorlabel,"\n";
1037 #print '@',"$entrytype",'{',"ref-$nline-$sn",',',"\n";
1038 #print '@',"$entrytype",'{',"$author$date",',',"\n";
1039 print '@',"$entrytype",'{',"$authorlabel$date",',',"\n";
1040 $author&& print 'author = {',$author,'},',"\n";
1041 $title&& print 'title = {',$title,'},',"\n";
1042 $journal&& print 'journal = {',$journal,'},',"\n";
1043 $translator&& print 'translator= {',$translator,'},',"\n";
1044 $bookauthor&& print 'bookauthor= {',$bookauthor,'},',"\n";
1045 $booktitle&& print 'booktitle = {',$booktitle,'},',"\n";
1046 $version&& print 'version = {',$version,'},',"\n";
1047 $address&& print 'address = {',$address,'},',"\n";
1048 $publisher&& print 'publisher = {',$publisher,'},',"\n";
1049 $type&& print 'type = {',$type,'},',"\n";
1050 $date&& print 'date = {',$date,'},',"\n";
1051 $volume&& print 'volume = {',$volume,'},',"\n";
1052 $number&& print 'number = {',$number,'},',"\n";
1053 $pages&& print 'pages = {',$pages,'},',"\n";
1054 $eventdate&& print 'eventdate = {',$eventdate,'},',"\n";
1055 $urldate&& print 'urldate = {',$urldate,'},',"\n";
1056 $url&& print 'url = {',$url,'},',"\n";
1057 $doi&& print 'doi = {',$doi,'},',"\n";
1058 $note&& print 'note = {',$note,'},',"\n";
1059 print '}',"\n";
1060
1061
1062
1063 #print FHW "\n@","$entrytype",'{',"ref-$nline-$sn-$authorlabel",',',"\n";
1064 print FHW "\n@","$entrytype",'{',"$authorlabel$date",',',"\n";
1065 $author&& print FHW 'author = {',$author,'},',"\n";
1066 $title&& print FHW 'title = {',$title,'},',"\n";
1067 $journal&& print FHW 'journal = {',$journal,'},',"\n";
1068 $translator&& print FHW 'translator= {',$translator,'},',"\n";
1069 $bookauthor&& print FHW 'bookauthor= {',$bookauthor,'},',"\n";
1070 $booktitle&& print FHW 'booktitle = {',$booktitle,'},',"\n";
1071 $version&& print FHW 'version = {',$version,'},',"\n";
1072 $address&& print FHW 'address = {',$address,'},',"\n";
1073 $publisher&& print FHW 'publisher = {',$publisher,'},',"\n";
1074 $type&& print FHW 'type = {',$type,'},',"\n";
1075 $date&& print FHW 'date = {',$date,'},',"\n";
1076 $volume&& print FHW 'volume = {',$volume,'},',"\n";
1077 $number&& print FHW 'number = {',$number,'},',"\n";
1078 $pages&& print FHW 'pages = {',$pages,'},',"\n";
1079 $eventdate&& print FHW 'eventdate = {',$eventdate,'},',"\n";
1080 $urldate&& print FHW 'urldate = {',$urldate,'},',"\n";
1081 $url&& print FHW 'url = {',$url,'},',"\n";
1082 $doi&& print FHW 'doi = {',$doi,'},',"\n";
1083 $note&& print FHW 'note = {',$note,'},',"\n";
1084 print FHW '}',"\n";
1085 }
1086 }
1087
1088
1089 print "\n";
1090 if($nline>=$ne){last;} #先跳过几行进行,配合后面的last进行当行测试
1091 }
1092
1093 sub bfidentifier{#bf表示before,标识符前所有的类型都一样
1094 #$regexpformach=@_;
1095 #print '@_=',@_,"\n";
1096 #print 'regexpformach=',"$regexpformach \n";
1097 #标识符之前很容易匹配三个内容,序号,作者和标题
1098 if($reference=~m/.*\D\.\s\D.*$regexformach/){#匹配存在作者后的点的话,同时点号周围不是数字,有时标题中可能出现1.1这样的信息
1099 ($sn , $author , $title)=($reference=~m/\[(\d+)\]\s*(.*)\.\s(.*)$regexformach/);
1100 print 'sn =',"$sn \n";
1101 print 'author=',"$author \n";#作者多个姓名还需要处理,还要注意有前后缀的情况
1102 print 'title =',"$title \n";
1103 if($author=~m/等/){
1104 $author=~s/等/others/;#将等换成others
1105 }else{
1106 $author=~s/,\s*$//;#将最后一个逗号去掉
1107 }
1108 if($author=~m/et\sal/){
1109 $author=~s/et\sal/others/;#将et al.换成others
1110 }else{
1111 $author=~s/,\s*$//;#将最后一个逗号去掉
1112 }
1113 while($author=~m/,/){
1114 $author=~s/,/ and /;#将逗号换成and
1115 }
1116 #当“等”直接与作者相连时,需要在others前面增加一个and
1117 if($author=~m/others/){#若存在other是且其前面没有and时
1118 if ($author=~m/and\s*others/){}
1119 else{
1120 $author=~s/others/ and others/;
1121 }
1122 }
1123 print 'author=',"$author \n";
1124 }else{#不存在作者的话\[M\]\/\/
1125 ($sn , $title)=($reference=~m/\[(\d+)\]\s*(.*)$regexformach/);#标识符之前很容易匹配三个内容,序号,作者和标题
1126 print 'sn =',"$sn \n";
1127 print 'title =',"$title \n";
1128 }
1129 $title=~s/(^\s+|\s+$)//g; #将title前后的空格去掉
1130
1131 #进一步处理责任者的姓名,主要针对英文名需要有一些符号进行区分姓,名,前缀和后缀。
1132 @names=split('and',$author);
1133 print 'names=',@names,"\n";
1134 $author="";
1135 $j=0;
1136 foreach $name(@names){#一个姓名一个姓名处理
1137
1138 $j=$j+1;
1139 #print $name,"\n";
1140 @nameparts=split(' ',$name);
1141 #print 'nameparts=',@nameparts,"\n";
1142
1143 $org=0;
1144 for($k=0;$k<@nameparts;$k++){
1145 if(@nameparts[$k]=~m/.{2,}/ and @nameparts[$k]!~m/\s*von\s*/i and @nameparts[$k]!~m/\s*jr\s*/i){
1146 #当分解的单作者的各个部分,存在两个以上为2个字符以上的情况,说明不是一般的姓名而是机构作者
1147 #这个判断是对的,因为国标规定要求缩写的,否则就是不是国标了,对于不标准的情形请输出后手动处理即去掉作者外包围的花括号。
1148 $org=$org+1;
1149 print 'org=',"$org\n";
1150 }
1151 }
1152
1153 if(@nameparts>1){
1154 if(@nameparts[0]=~m/\s*von\s*/i){#确定姓的位置
1155 $family=1;
1156 @nameparts[1]=@nameparts[1].',';
1157 }else{
1158 $family=0;
1159 @nameparts[0]=@nameparts[0].',';
1160 }
1161 if(@nameparts[-1]=~m/\s*jr\s*/i){#确定后缀的位置
1162 @nameparts[-1]=@nameparts[-1].'.,';
1163 $given=@nameparts-2;
1164 $suffix=1;
1165 }else{
1166 $suffix=0;
1167 $given=@nameparts-1;
1168 }
1169 print 'family=',$family,"\n";
1170 print 'given=',$given,"\n";
1171 print 'suffix=',$suffix,"\n";
1172 print 'familyname=',@nameparts[$family],"\n";
1173
1174 $namefmt="";
1175 for($i=0;$i<=$family;$i++){
1176 $namefmt=$namefmt.@nameparts[$i].' ';
1177 print $i,$family,$namefmt,"\n";
1178 }
1179 if($suffix){
1180 $namefmt=$namefmt.@nameparts[-1].' ';
1181 }
1182 for($i=$family+1;$i<=$given;$i++){
1183 $namefmt=$namefmt.@nameparts[$i].' ';
1184 print $i,$family,$namefmt,"\n";
1185 }
1186 }else{
1187 $namefmt=$name;
1188 }
1189 if($org > 1){#当是机构作者时
1190 $namefmt='{'.$name.'}';
1191 }
1192 print 'namefmt=',"$namefmt \n";
1193
1194 if($j==1){#把姓名用and连接起来
1195 $author=$namefmt;
1196 }else{
1197 $author=$author.' and '.$namefmt;
1198 }
1199
1200 if($j==1){#根据第一个作者构建authorlabel
1201 if($org > 1){#机构作者取各单词的首字母
1202 $authorlabel='';
1203 for($k=0;$k<@nameparts;$k++){
1204 ($strtmp)=($nameparts[$k]=~/^(.)/);
1205 $authorlabel=$authorlabel.$strtmp;
1206 }
1207 }else{#姓名则仅取作者姓
1208 ($authorlabel)=$nameparts[$family];
1209 if($authorlabel=~m/,$/){$authorlabel=~s/,$//;}#去掉最后的逗号
1210 }
1211 }
1212 }
1213 while($author=~m/\s{2,}/){
1214 $author=~s/\s{2,}/ /;#将多余的空格去掉
1215 }
1216 while($author=~m/\.{2,}/){
1217 $author=~s/\.{2,}/\./;#将多余的点去掉
1218 }
1219 print 'author=',"$author\n";
1220 }
1221
1222
1223 sub bfaddressbook{#bf表示before,出版者前book和inbook不一样
1224 #对于book类型,必然存在出版地和出版者信息,以此为根据展开
1225 print 'sub:bfaddressbook ',"\n";
1226 if($reference!~m/$regexformach\s*[^:]+:\s\D{1,}.*/){#如果不存在出版地和出版者信息
1227 ($pospublisher)=($reference=~m/$regexformach\s*(.*)/);
1228 print 'pospublisher=',"$pospublisher \n";
1229 }else{
1230 ($preaddress, $pospublisher)=($reference=~m/$regexformach\s*([^:]+):\s(\D{1,}.*)/);#标识符之后根据第一个冒号分为包括地址的信息和包括出版者的信息两部分
1231 print 'preaddress =',"$preaddress \n";
1232 print 'pospublisher=',"$pospublisher \n";
1233
1234 #处理出版地及其前面的信息
1235 if ($preaddress=~m/.*\[S\.l\.\].*/) {#当存在英文的[S.l.],英文的一般不存在译者,所以下面处理比较简单
1236 $preaddress=~s/\[S\.l\.\]/\[S-l-\]/; #先将[S.l.]换成[S-l-]然后换回来
1237 }
1238 if ($preaddress=~m/.*\d.*\.\s*.*/){#匹配存在数字版本的话
1239 ($preversion, $version, $address)=($preaddress=~m/(.*)(\d)[^\.]*\.\s*(.*)/);
1240 print 'preversion =',"$preversion \n";
1241 print 'version =',"$version \n";
1242 print 'address =',"$address \n";
1243 if($preversion=~m/.*\..*/){#如果存在译者等信息
1244 ($translator)=($preversion=~m/(.*)\..*/);
1245 print 'translator =',"$translator \n";#作者多个姓名还需要处理,还有译这个标识
1246 }
1247 }else {#不存在数字版本的话
1248 if($preaddress=~m/.*\.\s+.*/){#存在点加空格,表示存在其他作者信息,区别点在末尾但无空格
1249 ($preversion,$address)=($preaddress=~m/(.*)\.\s*(.*)/);
1250 print 'preversion =',"$preversion \n";
1251 print 'address =',"$address \n";
1252 $translator=$preversion;
1253 print 'translator =',"$translator \n";
1254 }else{
1255 $address=$preaddress;
1256 print 'address =',"$address \n";
1257 }
1258 }
1259
1260 if($translator=~m/,\s*译/){#当译者真实存在
1261 $translator=~s/,\s*译//;#将译去掉
1262 if($translator=~m/等/){
1263 $translator=~s/等/others/;#将等换成others
1264 }else{
1265 $translator=~s/,\s*$//;#将最后一个逗号去掉
1266 }
1267 while($translator=~m/,/){
1268 $translator=~s/,/ and /;#将逗号换成and
1269 }
1270 print 'translator =',"$translator \n";
1271 }
1272 elsif($translator=~m/译$/)#若最后一个字是译
1273 {
1274 $translator=~s/译//;#将译去掉
1275 if($translator=~m/等/){
1276 $translator=~s/等/others/;#将等换成others
1277 }else{
1278 $translator=~s/,\s*$//;#将最后一个逗号去掉
1279 }
1280 while($translator=~m/,/){
1281 $translator=~s/,/ and /;#将逗号换成and
1282 }
1283 print 'translator =',"$translator \n";
1284 }
1285 else {#当译者不存在,那么translator中信息可能是非数字的版本信息
1286 unless($version) {#除非version没有信息
1287 $version=$translator;
1288 $translator="";
1289 }else{
1290 print "version is already exisit!\n";
1291 print 'version=',$version,"\n";
1292 print 'translator=',$translator,"\n";
1293 }
1294 }
1295
1296 if ($address=~m/.*\[S-l-\].*/) {#当存在英文的[S-l-][S.l.]
1297 $address=~s/\[S-l-\]/\[S\.l\.\]/; #将[S-l-]换回[S.l.]
1298 }
1299 }
1300 }
1301
1302
1303 sub bfaddressinbook{#bf表示before,出版者前book和inbook不一样
1304 ($postitle)=($reference=~m/$regexformach\s*(.*)/);
1305 print 'postitle=',$postitle,"\n";
1306 if($postitle=~m/^[^:\.]+:[^:\.]+\./){#当存在析出源第一项中出现:时
1307 $postitle=~s/:/colon/;#先将该冒号换成colon
1308 print 'postitle=',$postitle,"\n";
1309 }
1310 #对于inbook类型,必然存在出版地和出版者信息,以此为根据展开
1311 ($preaddress, $pospublisher)=($postitle=~m/\s*(.*):\s(\D.*)/);
1312 #($preaddress, $pospublisher)=($postitle=~m/\s*([^:]+):\s(\D.*)/);
1313 #标识符之后根据第一个冒号分为包括地址的信息和包括出版者的信息两部分
1314 print 'preaddress =',"$preaddress \n";
1315 print 'pospublisher=',"$pospublisher \n";
1316
1317 #处理出版地及其前面的信息
1318 if ($preaddress=~m/.*\[S\.l\.\].*/) {#当存在英文的[S.l.],英文的一般不存在译者,所以下面处理比较简单
1319 $preaddress=~s/\[S\.l\.\]/\[S-l-\]/; #先将[S.l.]换成[S-l-]然后换回来
1320 }
1321 if ($preaddress=~m/.*\d.*\.\s+.*/ and ($preaddress=~m/.*th\sed.*/ or $preaddress=~m/.*版.*/)){#匹配存在数字版本的话
1322 ($preversion, $version, $address)=($preaddress=~m/(.*)(\d)[^\.]*\.\s+(.*)/);
1323 print 'preversion =',"$preversion \n";
1324 print 'version =',"$version \n";
1325 print 'address =',"$address \n";
1326 if($preversion=~m/.*\.\s+.*/){#如果存在译者等信息
1327 ($translator)=($preversion=~m/(.*)\.\s+.*/);
1328 print 'translator =',"$translator \n";#作者多个姓名还需要处理,还有译这个标识
1329 }
1330 }else {#不存在数字版本的话
1331 if($preaddress=~m/.*\.\s+.*/){#存在点加空格,表示存在其他作者信息,区别点在末尾但无空格
1332 ($preversion,$address)=($preaddress=~m/(.*)\.\s+(.*)/);
1333 print 'preversion =',"$preversion \n";
1334 print 'address =',"$address \n";
1335 if($preversion=~m/.*\.\s+.*/){#中间还存在点加空格
1336 ($bookauthor,$booktitle)=($preversion=~m/(.*)\.\s+(.*)/);
1337
1338 if($bookauthor=~m/等/){
1339 $bookauthor=~s/等/others/;#将等换成others
1340 }else{
1341 $bookauthor=~s/,\s*$//;#将最后一个逗号去掉
1342 }
1343 if($bookauthor=~m/et\sal/){
1344 $bookauthor=~s/et\sal/others/;#将et al.换成others
1345 }else{
1346 $bookauthor=~s/,\s*$//;#将最后一个逗号去掉
1347 }
1348 while($bookauthor=~m/,/){
1349 $bookauthor=~s/,/ and /;#将逗号换成and
1350 }
1351 print 'bookauthor=',"$bookauthor \n";
1352 }else{
1353 $booktitle=$preversion;
1354 }
1355 }else{
1356 $address=$preaddress;
1357 print 'address =',"$address \n";
1358 }
1359 }
1360
1361 if ($address=~m/.*\[S-l-\].*/) {#当存在英文的[S-l-][S.l.]
1362 $address=~s/\[S-l-\]/\[S\.l\.\]/; #将[S-l-]换回[S.l.]
1363 }
1364 if ($booktitle=~m/.*colon.*/) {#当存在colon
1365 $booktitle=~s/colon/:/; #将colon换回:
1366 }
1367
1368 #进一步处理责任者的姓名,主要针对英文名需要有一些符号进行区分姓,名,前缀和后缀。
1369 @names=split('and',$bookauthor);
1370 print 'names=',@names,"\n";
1371 $bookauthor="";
1372 $j=0;
1373 foreach $name(@names){
1374 $j=$j+1;
1375 #print $name,"\n";
1376 @nameparts=split(' ',$name);
1377 #print 'nameparts=',@nameparts,"\n";
1378
1379 $org=0;
1380 for($k=0;$k<@nameparts;$k++){
1381 if(@nameparts[$k]=~m/.{2,}/ and @nameparts[$k]!~m/\s*von\s*/i and @nameparts[$k]!~m/\s*jr\s*/i){
1382 #当分解的单作者的各个部分,存在两个以上为2个字符以上的情况,说明不是一般的姓名而是机构作者
1383 $org=$org+1;
1384 print 'org=',"$org\n";
1385 }
1386 }
1387
1388 if(@nameparts>1){
1389 if(@nameparts[0]=~m/\s*von\s*/i){#确定姓的位置
1390 $family=1;
1391 @nameparts[1]=@nameparts[1].',';
1392 }else{
1393 $family=0;
1394 @nameparts[0]=@nameparts[0].',';
1395 }
1396 if(@nameparts[-1]=~m/\s*jr\s*/i){#确定后缀的位置
1397 @nameparts[-1]=@nameparts[-1].'.,';
1398 $given=@nameparts-2;
1399 $suffix=1;
1400 }else{
1401 $suffix=0;
1402 $given=@nameparts-1;
1403 }
1404 #print 'family=',$family,"\n";
1405 #print 'given=',$given,"\n";
1406 #print 'suffix=',$suffix,"\n";
1407
1408 $namefmt="";
1409 for($i=0;$i<=$family;$i++){
1410 $namefmt=$namefmt.@nameparts[$i].' ';
1411 #print $i,$family,$namefmt,"\n";
1412 }
1413 if($suffix){
1414 $namefmt=$namefmt.@nameparts[-1].' ';
1415 }
1416 for($i=$family+1;$i<=$given;$i++){
1417 $namefmt=$namefmt.@nameparts[$i].' ';
1418 }
1419 }else{
1420 $namefmt=$name;
1421 }
1422 if($org > 1){#当是机构作者时
1423 $namefmt='{'.$name.'}';
1424 }
1425 #print 'namefmt=',"$namefmt \n";
1426
1427 if($j==1){
1428 $bookauthor=$namefmt;
1429 }else{
1430 $bookauthor=$bookauthor.' and '.$namefmt;
1431 }
1432 }
1433 while($bookauthor=~m/\s{2,}/){
1434 $bookauthor=~s/\s{2,}/ /;#将多余的空格去掉
1435 }
1436 while($bookauthor=~m/\.{2,}/){
1437 $bookauthor=~s/\.{2,}/\./;#将多余的点去掉
1438 }
1439 print 'bookauthor=',"$bookauthor\n";
1440 }
1441
1442
1443 sub afpublisherbook{#af表示after,出版者后book和inbook一样,但如果存在url则不同
1444 #处理出版者及其后面的信息
1445 if ($pospublisher=~m/.*\[s\.n\.\].*/) {#当存在英文的[s.n.]
1446 $pospublisher=~s/\[s\.n\.\]/\[s-n-\]/; #先将[s.n.]换成[s-n-]然后换回来
1447 }
1448 if ($pospublisher=~m/.*,\s*\d{4}\S*/){#匹配存在年份的话
1449 ($publisher, $year, $posyear)=($pospublisher=~m/(.*),\s*(\d{4})(.*)/);
1450 print 'publisher=',"$publisher \n";
1451 print 'year =',"$year \n";
1452 print 'posyear =',"$posyear \n";
1453 if($posyear=~m/^:/){#匹配存在页码前面的冒号的话
1454 ($pages, $pospages)=($posyear=~m/^:([^\.]+)\.(.*)/);
1455 print 'pages =',"$pages \n";
1456 print 'pospages=',"$pospages \n";
1457 if($pospages=~m/DOI/i){#匹配存在doi的话
1458 ($doi)=($pospages=~m/DOI:(.*)\./i);
1459 print 'doi=',"$doi \n";
1460 }
1461 }else{#不存在页码的话
1462 if($posyear=~m/DOI/i){#匹配存在doi的话
1463 ($doi)=($posyear=~m/DOI:(.*)\./i);
1464 print 'doi=',"$doi \n";
1465 }
1466 }
1467 }else{#不存在年份,匹配一下是否存在冒号和页码
1468 if($pospublisher=~m/.*[^DOI]:.*/i){#当存在不是doi后面的冒号时,说明有页码
1469 ($publisher, $pages, $pospages)=($pospublisher=~m/([^:]*):([^\.]*)\.(.*)/);
1470 print 'publisher=',"$publisher \n";
1471 print 'pages =',"$pages \n";
1472 print 'pospages =',"$pospages \n";
1473 if($pospages=~m/DOI/i){#匹配存在doi的话
1474 ($doi)=($pospages=~m/DOI:(.*)\./i);
1475 print 'doi=',"$doi \n";
1476 }
1477 }else{#没有页码冒号以点作为出版者后的分隔点
1478 ($publisher, $pospages)=($pospublisher=~m/([^\.]*)\.(.*)/);
1479 print 'publisher=',"$publisher \n";
1480 print 'pospages =',"$pospages \n";
1481 if($pospages=~m/DOI/i){#匹配存在doi的话
1482 ($doi)=($pospages=~m/DOI:(.*)\./i);
1483 print 'doi=',"$doi \n";
1484 }
1485 }
1486 }
1487 if ($publisher=~m/.*\[s-n-\].*/) {#当存在英文的[s-n-]
1488 $publisher=~s/\[s-n-\]/\[s\.n\.\]/; #将[s-n-]换回[s.n.]
1489 }
1490 }
1491
1492
1493 sub afpublisherbookurl{#af表示after,出版者后book和inbook一样,但如果存在url则不同
1494 #处理出版者及其后面的信息
1495 if ($pospublisher=~m/.*\[s\.n\.\].*/) {#当存在英文的[s.n.]
1496 $pospublisher=~s/\[s\.n\.\]/\[s-n-\]/; #先将[s.n.]换成[s-n-]然后换回来
1497 }
1498 if ($pospublisher=~m/.*,\s*\d{4}[^\d-]/){#匹配存在年份的话,4个数字后面跟着不能是数字和连字符-
1499 ($publisher, $year, $posyear)=($pospublisher=~m/(.*),\s*(\d{4})(.*)/);
1500 print 'publisher=',"$publisher \n";
1501 print 'year =',"$year \n";
1502 print 'posyear =',"$posyear \n";
1503 if($posyear=~m/^:/){#匹配存在页码前面的冒号的话
1504 ($pages, $pospages)=($posyear=~m/^:([^\.]+)\.(.*)/);
1505 print 'pages =',"$pages \n";
1506 print 'pospages=',"$pospages \n";
1507 if($pages=~m/\[.*\]/){
1508 ($pagesa, $urldate)=($pages=~m/(.*)\[(.*)\]/);
1509 $pages=$pagesa;
1510 print 'urldate=',"$urldate \n";
1511 print 'pages=',"$pages \n";
1512 }
1513 if($pospages=~m/DOI/i){#匹配存在doi的话
1514 ($url, $doi)=($pospages=~m/(.*)\.\s*DOI:(.*)\./i);
1515 print 'url=',"$url \n";
1516 print 'doi=',"$doi \n";
1517 }else{
1518 ($url)=($pospages=~m/(.*)\./i);
1519 print 'url=',"$url \n";
1520 }
1521 }
1522 else{#不存在页码的话
1523 if($posyear=~m/\[.*\]/){
1524 ($urldate,$pospages)=($posyear=~m/.*\[(.*)\]\.(.*)/);
1525 print 'urldate=',"$urldate \n";
1526 print 'pospages=',"$pospages \n";
1527 }
1528 else{#不存在页码,又不存在引用日期的话,那么会有一个点和空格
1529 ($pospages)=($posyear=~m/.*\s(.*)/);
1530 print 'pospages=',"$pospages \n";
1531 }
1532 if($pospages=~m/DOI/i){#匹配存在doi的话
1533 ($url, $doi)=($pospages=~m/(.*)\.\s*DOI:(.*)\./i);
1534 print 'url=',"$url \n";
1535 print 'doi=',"$doi \n";
1536 }else{
1537 ($url)=($pospages=~m/(.*)\./i);
1538 print 'url=',"$url \n";
1539 }
1540 }
1541 }else{#不存在年份,匹配一下是否存在冒号和页码
1542 if($pospublisher=~m/.*[^DOIhttp]:.*/i){#当存在不是doi或http后面的冒号时,说明有页码
1543 ($publisher, $pages, $pospages)=($pospublisher=~m/([^:]*):([^\.]*)\.(.*)/);
1544 print 'publisher=',"$publisher \n";
1545 print 'pages =',"$pages \n";
1546 print 'pospages =',"$pospages \n";
1547 if($pages=~m/\[.*\]/){
1548 ($pagesa, $urldate)=($pages=~m/(.*)\[(.*)\]/);
1549 $pages=$pagesa;
1550 print 'urldate=',"$urldate \n";
1551 print 'pages=',"$pages \n";
1552 }
1553 if($pospages=~m/DOI/i){#匹配存在doi的话
1554 ($url, $doi)=($pospages=~m/(.*)\.\s*DOI:(.*)\./i);
1555 print 'url=',"$url \n";
1556 print 'doi=',"$doi \n";
1557 }else{
1558 ($url)=($pospages=~m/(.*)\./i);
1559 print 'url=',"$url \n";
1560 }
1561 }else{#没有页码冒号以点作为出版者后的分隔点
1562 ($publisher, $pospages)=($pospublisher=~m/([^\.]*)\.(.*)/);
1563 print 'publisher=',"$publisher \n";
1564 print 'pospages =',"$pospages \n";
1565 if($publisher=~m/\[.*\]/){
1566 ($publishera, $urldate)=($publisher=~m/(.*)\[(.*)\]/);
1567 $publisher=$publishera;
1568 print 'urldate=',"$urldate \n";
1569 print 'publisher=',"$publisher \n";
1570 }
1571 if($pospages=~m/DOI/i){#匹配存在doi的话
1572 ($url, $doi)=($pospages=~m/(.*)\.\s*DOI:(.*)\./i);
1573 print 'url=',"$url \n";
1574 print 'doi=',"$doi \n";
1575 }else{
1576 ($url)=($pospages=~m/(.*)\./i);
1577 print 'url=',"$url \n";
1578 }
1579 }
1580 }
1581 if ($publisher=~m/.*\[s-n-\].*/) {#当存在英文的[s-n-]
1582 $publisher=~s/\[s-n-\]/\[s\.n\.\]/; #将[s-n-]换回[s.n.]
1583 }
1584 }
1585
1586
1587 sub afpublisherbookb{#af表示after,出版者后book和inbook一样,但如果存在url则不同
1588 #处理出版者及其后面的信息
1589 if ($pospublisher=~m/.*\[s\.n\.\].*/) {#当存在英文的[s.n.]
1590 $pospublisher=~s/\[s\.n\.\]/\[s-n-\]/; #先将[s.n.]换成[s-n-]然后换回来
1591 }
1592 if ($pospublisher=~m/.*[\.\s,]*\d{4}[\D\S]+/){#匹配存在年份的话,年份前面没有逗号+空格
1593 ($publisher, $year, $posyear)=($pospublisher=~m/(.*)[\.\s,]*(\d{4})([\D\S].*)/);
1594 print 'publisher=',"$publisher \n";
1595 if($publisher=~m/[,\s]+$/){$publisher=~s/[,\s]+$//;}#去掉最后的逗号
1596 unless($address){#当没有出版地时,也没有必要存在
1597 $version=$publisher;
1598 $publisher='';
1599 }
1600 print 'year =',"$year \n";
1601 print 'posyear =',"$posyear \n";
1602 if($posyear=~m/^:/){#匹配存在页码前面的冒号的话
1603 ($pages, $pospages)=($posyear=~m/^:([^\.]+)\.(.*)/);
1604 print 'pages =',"$pages \n";
1605 print 'pospages=',"$pospages \n";
1606 if($pospages=~m/DOI/i){#匹配存在doi的话
1607 ($doi)=($pospages=~m/DOI:(.*)\./i);
1608 print 'doi=',"$doi \n";
1609 }
1610 }else{#不存在页码的话
1611 if($posyear=~m/DOI/i){#匹配存在doi的话
1612 ($doi)=($posyear=~m/DOI:(.*)\./i);
1613 print 'doi=',"$doi \n";
1614 }
1615 }
1616 }else{#不存在年份,匹配一下是否存在冒号和页码
1617 if($pospublisher=~m/.*[^DOI]:.*/i){#当存在不是doi后面的冒号时,说明有页码
1618 ($publisher, $pages, $pospages)=($pospublisher=~m/([^:]*):([^\.]*)\.(.*)/);
1619 print 'publisher=',"$publisher \n";
1620 print 'pages =',"$pages \n";
1621 print 'pospages =',"$pospages \n";
1622 if($pospages=~m/DOI/i){#匹配存在doi的话
1623 ($doi)=($pospages=~m/DOI:(.*)\./i);
1624 print 'doi=',"$doi \n";
1625 }
1626 }else{#没有页码冒号以点作为出版者后的分隔点
1627 ($publisher, $pospages)=($pospublisher=~m/([^\.]*)\.(.*)/);
1628 print 'publisher=',"$publisher \n";
1629 print 'pospages =',"$pospages \n";
1630 if($pospages=~m/DOI/i){#匹配存在doi的话
1631 ($doi)=($pospages=~m/DOI:(.*)\./i);
1632 print 'doi=',"$doi \n";
1633 }
1634 }
1635 if($publisher=~m/,$/){$publisher=~s/,$//;}#去掉最后的逗号
1636 unless($address){#当没有出版地时,也没有必要存在
1637 $type=$publisher;
1638 $publisher='';
1639 }
1640 }
1641 if ($publisher=~m/.*\[s-n-\].*/) {#当存在英文的[s-n-]
1642 $publisher=~s/\[s-n-\]/\[s\.n\.\]/; #将[s-n-]换回[s.n.]
1643 }
1644 }
1645
1646
1647
1648 sub afpublisherbookurlb{#af表示after,出版者后book和inbook一样,但如果存在url则不同
1649 #处理出版者及其后面的信息
1650 if ($pospublisher=~m/.*\[s\.n\.\].*/) {#当存在英文的[s.n.]
1651 $pospublisher=~s/\[s\.n\.\]/\[s-n-\]/; #先将[s.n.]换成[s-n-]然后换回来
1652 }
1653 if ($pospublisher=~m/.*[\.\s,]*\d{4}[^\d-]/){#匹配存在年份的话,4个数字后面跟着不能是数字和连字符-
1654 ($publisher, $year, $posyear)=($pospublisher=~m/(.*)[\.\s,]*(\d{4})([^\d-].*)/);
1655 print 'publisher=',"$publisher \n";
1656 print 'year =',"$year \n";
1657 print 'posyear =',"$posyear \n";
1658 if($publisher=~m/,$/){$publisher=~s/,$//;}#去掉最后的逗号
1659 unless($address){#当没有出版地时,也没有必要存在
1660 $version=$publisher;
1661 $publisher='';
1662 }
1663 if($posyear=~m/^:/){#匹配存在页码前面的冒号的话
1664 ($pages, $pospages)=($posyear=~m/^:([^\.]+)\.(.*)/);
1665 print 'pages =',"$pages \n";
1666 print 'pospages=',"$pospages \n";
1667 if($pages=~m/\[.*\]/){
1668 ($pagesa, $urldate)=($pages=~m/(.*)\[(.*)\]/);
1669 $pages=$pagesa;
1670 print 'urldate=',"$urldate \n";
1671 print 'pages=',"$pages \n";
1672 }
1673 if($pospages=~m/DOI/i){#匹配存在doi的话
1674 ($url, $doi)=($pospages=~m/(.*)\.\s*DOI:(.*)\./i);
1675 print 'url=',"$url \n";
1676 print 'doi=',"$doi \n";
1677 }else{
1678 ($url)=($pospages=~m/(.*)\./i);
1679 print 'url=',"$url \n";
1680 }
1681 }
1682 else{#不存在页码的话
1683 if($posyear=~m/\[.*\]/){
1684 ($urldate,$pospages)=($posyear=~m/.*\[(.*)\]\.(.*)/);
1685 print 'urldate=',"$urldate \n";
1686 print 'pospages=',"$pospages \n";
1687 }
1688 else{#不存在页码,又不存在引用日期的话,那么会有一个点和空格
1689 ($pospages)=($posyear=~m/.*\s(.*)/);
1690 print 'pospages=',"$pospages \n";
1691 }
1692 if($pospages=~m/DOI/i){#匹配存在doi的话
1693 ($url, $doi)=($pospages=~m/(.*)\.\s*DOI:(.*)\./i);
1694 print 'url=',"$url \n";
1695 print 'doi=',"$doi \n";
1696 }else{
1697 ($url)=($pospages=~m/(.*)\./i);
1698 print 'url=',"$url \n";
1699 }
1700 }
1701 }else{#不存在年份,匹配一下是否存在冒号和页码
1702 if($pospublisher=~m/.*[^DOIhttp]:.*/i){#当存在不是doi或http后面的冒号时,说明有页码
1703 ($publisher, $pages, $pospages)=($pospublisher=~m/([^:]*):([^\.]*)\.(.*)/);
1704 print 'publisher=',"$publisher \n";
1705 print 'pages =',"$pages \n";
1706 print 'pospages =',"$pospages \n";
1707 if($pages=~m/\[.*\]/){
1708 ($pagesa, $urldate)=($pages=~m/(.*)\[(.*)\]/);
1709 $pages=$pagesa;
1710 print 'urldate=',"$urldate \n";
1711 print 'pages=',"$pages \n";
1712 }
1713 if($pospages=~m/DOI/i){#匹配存在doi的话
1714 ($url, $doi)=($pospages=~m/(.*)\.\s*DOI:(.*)\./i);
1715 print 'url=',"$url \n";
1716 print 'doi=',"$doi \n";
1717 }else{
1718 ($url)=($pospages=~m/(.*)\./i);
1719 print 'url=',"$url \n";
1720 }
1721 }else{#没有页码冒号以点作为出版者后的分隔点
1722 ($publisher, $pospages)=($pospublisher=~m/([^\.]*)\.(.*)/);
1723 print 'publisher=',"$publisher \n";
1724 print 'pospages =',"$pospages \n";
1725 if($publisher=~m/\[.*\]/){
1726 ($publishera, $urldate)=($publisher=~m/(.*)\[(.*)\]/);
1727 $publisher=$publishera;
1728 print 'urldate=',"$urldate \n";
1729 print 'publisher=',"$publisher \n";
1730 }
1731 if($pospages=~m/DOI/i){#匹配存在doi的话
1732 ($url, $doi)=($pospages=~m/(.*)\.\s*DOI:(.*)\./i);
1733 print 'url=',"$url \n";
1734 print 'doi=',"$doi \n";
1735 }else{
1736 ($url)=($pospages=~m/(.*)\./i);
1737 print 'url=',"$url \n";
1738 }
1739 }
1740 if($publisher=~m/,$/){$publisher=~s/,$//;}#去掉最后的逗号
1741 unless($address){#当没有出版地时,也没有必要存在
1742 $type=$publisher;
1743 $publisher='';
1744 }
1745 }
1746 if ($publisher=~m/.*\[s-n-\].*/) {#当存在英文的[s-n-]
1747 $publisher=~s/\[s-n-\]/\[s\.n\.\]/; #将[s-n-]换回[s.n.]
1748 }
1749 }
1750
1751
1752
1753 close (FHR);
1754 close (FHW);