@Thesis などの biblatex エントリを含む .bib ファイルからフィールドを自動的に削除します。

@Thesis などの biblatex エントリを含む .bib ファイルからフィールドを自動的に削除します。

bibtexエントリだけでなく、などの(新しい)biblatexエントリも含む.bibファイルから、特定のフィールド(例: abstract、、、など)を自動的に削除する必要があります。これは、質問と回答と同じです。reviewgroupfile@Thesisこの質問ではただし、biblatex エントリを含むファイルの場合のみです。

@Thesis.bib ファイル内のa のエントリの例は次のようになります。

 @Thesis{Author_18_TheThesis,
  author      = {Mr Author},
  title       = {The Thesis},
  type        = {Doctoral Dissertation},
  institution = {Department of Documents, University of Stackexchange},
  year        = {2018},
  abstract    = {This is the abstract.},
  file        = {:author/Author_18_TheThesis.pdf:PDF},
  review      = {This is the review.},
  groups      = {publications},
}

ビブツール参照された質問に対する受け入れられた回答である は、そのようなエントリをまだサポートしていないようで、警告とともにスキップします。

@Thesis{Author_18_TheThesis,
_^
*** BibTool ERROR:  (line 123 in ./yourbibliography.bib): Unknown entry type

*** BibTool WARNING: Skipping to next '@'

biblatex エントリを含む .bib ファイルからこのようなフィールドを自動的に削除するにはどうすればよいでしょうか? (Linux マシンで実行されるソリューションが望ましいです)。

答え1

アンドリュー・スワンの回答OP で元々リンクされていた bibtool は、リソースがbiblatex指定されていれば機能します (ht to moewe)。

つまり、ファイルの場合remove-fields.rsc:

preserve.keys = On
preserve.key.case = On
resource{biblatex}
delete.field = { abstract }
delete.field = { review }
delete.field = { groups }
delete.field = { file }

コマンド:

bibtool -r remove-fields ./references.bib -o new.bib

結果は次のようになります:

@Thesis{      Author_18_TheThesis,
  Author    = {Mr Author},
  Title     = {The Thesis},
  Type      = {Doctoral Dissertation},
  Institution   = {Department of Documents, University of Stackexchange},
  Year      = {2018},
  ispreprintpublic={test}
}

答え2

知らせ: デフォルトでは、biberデータモデルに不明なフィールドは暗黙的に削除されます。したがって、非標準フィールドを使用する場合は、以下の更新を参照してください。

biber適切なソースマップを使用して のツール モードを使用できます。

biber のツール モードではデータ ソース上で動作するため、次のようにコマンド ラインで実行する必要があります。

biber --tool --configfile=biber-tool.conf <mybibfile>.bib

(もちろん、<>適切なファイル名に置き換えるだけです)。

biber-tool.confbiber にファイルに対して何をさせたいかを指定します。あなたの場合、エントリから特定のフィールドを削除したいので、ソースマップはそれに適したツールです。 の内容は次のbiber-tool.confようになります (出力の外観を制御するための他のオプションもいくつかあります)。

<?xml version="1.0" encoding="UTF-8"?>
<config>
  <output_fieldcase>lower</output_fieldcase>
  <output_indent>2</output_indent>
  <output_align>true</output_align>
  <sourcemap>
    <maps datatype="bibtex" map_overwrite="1">
      <map map_overwrite="1">
        <map_step map_field_set="abstract" map_null="1"/>
        <map_step map_field_set="review" map_null="1"/>
        <map_step map_field_set="groups" map_null="1"/>
        <map_step map_field_set="file" map_null="1"/>
      </map>
    </maps>
  </sourcemap>
</config>

この設定では、上記の biber コマンドは<mybibfile>_bibertool.bib指定されたフィールドを削除した新しいファイルを出力します。

エントリーの結果は次のようになります:

@thesis{Author_18_TheThesis,
  author      = {Author, Mr},
  institution = {Department of Documents, University of Stackexchange},
  date        = {2018},
  title       = {The Thesis},
  type        = {Doctoral Dissertation},
}

アップデート: デフォルトでは、biberデータモデルに不明なフィールドは黙って削除されます。したがって、データソースにそれらのフィールドが含まれている場合、または不明なフィールドがあり、無視されたフィールドについて警告を受け取りたい場合は、オプションを使用します--validate-datamodel

biber --tool --validate-datamodel <mybibfile>.bib

あなたのエントリーに対して、次の警告が表示されます:

WARN - Datamodel: Entry 'Author_18_TheThesis' (references.bib): Field 'groups' invalid in data model - ignoring
WARN - Datamodel: Entry 'Author_18_TheThesis' (references.bib): Field 'ispreprintpublic' invalid in data model - ignoring

ここで、これらのフィールドを削除せずに保持する必要がある場合は、カスタム のデータ モデルを拡張してそれらを含める必要があります。これは、グループ内に非標準フィールドを追加することでbiber実行できます。この場合 (ここでは、これらが「リテラル」タイプのフィールドであると想定)、次のようになります。biber-tool.conf<fields>...</fields>

<field fieldtype="field" datatype="literal">ispreprintpublic</field>
<field fieldtype="field" datatype="literal">groups</field>

そして、グループ内に<entryfields><entrytype>thesis</entrytype>...<\entryfields>以下を追加します:

<field>ispreprintpublic</field>
<field>groups</field>

結果として得られるカスタムはbiber-tool.conf次のようになります。

<?xml version="1.0" encoding="UTF-8"?>
<config>
  <output_fieldcase>lower</output_fieldcase>
  <output_indent>2</output_indent>
  <output_align>true</output_align>
  <sourcemap>
    <maps datatype="bibtex" map_overwrite="1">
      <map map_overwrite="1">
        <map_step map_field_set="abstract" map_null="1"/>
        <map_step map_field_set="review" map_null="1"/>
        <map_step map_field_set="groups" map_null="1"/>
        <map_step map_field_set="file" map_null="1"/>
      </map>
    </maps>
  </sourcemap>
  <datamodel>
    <fields>
      <field fieldtype="field" datatype="literal">ispreprintpublic</field>
      <field fieldtype="field" datatype="literal">groups</field>
    </fields>
    <entryfields>
      <entrytype>thesis</entrytype>
      <field>ispreprintpublic</field>
      <field>groups</field>
    </entryfields>
  </datamodel>
</config>

これを使用して、次の入力を行います。

@Thesis{Author_18_TheThesis,
  author      = {Mr Author},
  title       = {The Thesis},
  type        = {Doctoral Dissertation},
  institution = {Department of Documents, University of Stackexchange},
  year        = {2018},
  abstract    = {This is the abstract.},
  file        = {:author/Author_18_TheThesis.pdf:PDF},
  review      = {This is the review.},
  groups      = {publications},
  ispreprintpublic = {test},
}

出力は次のようになります。

@thesis{Author_18_TheThesis,
  author           = {Author, Mr},
  institution      = {Department of Documents, University of Stackexchange},
  date             = {2018},
  ispreprintpublic = {test},
  title            = {The Thesis},
  type             = {Doctoral Dissertation},
}

これは特に簡単なことではありません。しかし、コメントこの件に関して PLK は次のように述べています。「データモデルをツール モードにすることによるメリットは、この種の問題よりも大きいです。」

答え3

もう一つの選択肢は、bib2bibツールです。これは、BibTexエントリをフィルタリング/抽出/拡張するための非常に柔軟で信頼性の高い方法を提供します。この(あまり知られていない)ユーティリティは、ビブテックス2HTMLツールスイート。(注:PDFドキュメントでは、HTML ドキュメントでは については説明されていませんbib2bib

たとえば、biblatex.bibファイルから特定のフィールドを削除し、出力を次のように保存しますbibtex.bib

bib2bib --remove abstract --remove file --remove review -ob bibtex.bib biblatex.bib   

フィルターや並べ替えのオプションを指定したり、フィールドの名前を変更したりすることも可能です ( --rename <old> <new>)。

答え4

Sublime などのテキスト エディターを使用して手動で実行することもできます。正規表現機能 (Mac の場合は option+command+R) を有効にして、次を探します。

abstract = {.*},

そして何も置き換えない。

これによりabstract = {、との間が削除されます。},

これを他の分野にも応用できます。

関連情報