내 .bib 파일에서 중복된 기사 제목 찾기

내 .bib 파일에서 중복된 기사 제목 찾기

논문을 작성 중인데 이전 .bib 파일의 일부 내용을 복사하여 붙여넣었습니다. 하지만 동일한 기사 제목에 대해 다른 레이블을 사용했을 수도 있고 내 논문에서 이러한 다른 레이블을 인용했을 수도 있으므로 내 참조에 동일한 기사가 두 번 포함될 수도 있습니다. 거의 190개에 달하는 참고자료가 있는데, 반복되는 기사를 시각적으로 찾기는 어려울 것이라고 생각합니다.

내 턱받이 파일에서 동일한 제목의 항목을 찾을 수 있습니까? 나는 bibtex가 반복되는 라벨을 찾는다는 것을 알고 있습니다. 내 .bib 파일에서 반복되는 제목을 찾을 수 있습니까?

답변1

perlbib 파일을 살펴보고 모든 제목을 해당 행을 해시 값으로 사용하여 해시 키로 저장한 다음 이를 반복하고 해당 값에 여러 항목이 있는 경우 제목을 인쇄하는 데 사용할 수 있습니다 . 이렇게 하려면 "finddupls.pl"과 같은 내용으로 파일을 생성하고 bib 파일 이름을 변경한 다음 perl finddupls.pl터미널에서 실행하십시오.

#!perl
my %seen = ();

my $line = 0;
open my $B, 'file.bib';
while (<$B>) {
    $line++;
    # remove all non-alphanumeric characters, because bibtex could have " or { to encapsulate strings etc
    s/[^a-zA-Z0-9 _-]//ig; 
    # lower-case everything to be case-insensitive
    # pattern matches lines which start with title
    $seen{lc($1)} .= "$line," if /^\s*title\s*(.+)$/i;
}
close $B;

# loop through the title and count the number of lines found
foreach my $title (keys %seen) {
    # count number of elements seperated by comma
    my $num = $seen{$title} =~ tr/,//;
    print "title '$title' found $num times, lines: ".$seen{$title},"\n" if $num > 1;
}

# write sorted list into file
open my $S, '>sorted_titles.txt';
print $S join("\n", sort keys %seen);
close $S;

다음과 같이 터미널에 직접 반환됩니다.

title 'observation on soil moisture of irrigation cropland by cosmic-ray probe' found 2 times, lines: 99,1350,
title 'multiscale and multivariate evaluation of water fluxes and states over european river basins' found 2 times, lines: 199,1820,
title 'calibration of a non-invasive cosmic-ray probe for wide area snow water equivalent measurement' found 2 times, lines: 5,32,

sorted_titles.txt또한 모든 제목을 알파벳순으로 나열한 파일을 추가로 작성하여 수동으로 중복 항목을 검색할 수 있습니다.

답변2

필드가 동일하다고 믿을 수 있다면 title매우 간단합니다.

grep -n 'title =' bibliography.bib | uniq -cdf 1

이렇게 하면 파일에 대해 고유하지 않은 줄( -d)과 해당 줄이 나타나는 횟수( ) 및 참고문헌 파일에 나타나는 줄 번호( )만 인쇄됩니다. 이 줄 번호가 될 첫 번째 필드를 무시하라고 지시 합니다 .-cbibliography.bib-n-f 1uniq

따라서 다음과 같은 줄이 나타나면:

     2 733:  title =    {Ethica Nicomachea},

title = {Ethica Nicomachea},당신은 두 가지 모양이 있고 그 중 첫 번째 모양이 파일의 733행에 나타나는 것을 알고 있습니다 .bib.

관련 정보