hushidong / biblatex-map

bibmap 宏包和bibmap 后端程序用于生成参考文献和bib数据库修改。|| a backend like bibtex and a tool to modify the bib file, this tool is a partly python equivalent of the source map feature of biber
16 stars 2 forks source link

titlecase可以自动加上花括号吗 #4

Open xinyu-site opened 1 month ago

xinyu-site commented 1 month ago

我把bib改成了首字母,但是还是需要用花括号做大小写保持,请问可以自动加上吗

hushidong commented 1 month ago

可以的,

比如对title做保护,可以设置一个文件bibmapaddbrace.PY,其内容为:

sourcemaps=[
    [#map1:将给title添加一个{}保护
        {"fieldsource":"title","final":True,"match":r'^(.*)$',"replace":r'{\1}',"overwrite":True}
    ],
]

sourcemaps=[
    [#map1::将给title添加一个{}保护
        {"fieldsource":"title","final":True,"match":r'(.+)',"replace":r'{\1}',"overwrite":True}
    ],
]

然后利用命令:

python bibmap.py testaddbra.bib -m bibmapaddbrace.py --nofmt

则原始的文件:testaddbra.bib


@INPROCEEDINGS{chen2021visual,
  author={Chen, Boyuan and Hu, Yuhang and Kwiatkowski, Robert and Song, Shuran and Lipson, Hod},
  booktitle={2021 IEEE International Conference on Robotics and Automation (ICRA)}, 
  title={Visual perspective taking for opponent behavior modeling}, 
  year={2021},
  pages={13678-13685},
  keywords={Training;Visualization;Automation;Conferences;Games;Predictive models;Robots},
  doi={10.1109/ICRA48506.2021.9562028}}

@Inproceedings{Alford2015,
title={Active Behavior Recognition in Beyond Visual Range Air Combat},
author={Ron Alford and Hayley Borck and Justin Karneeb},
booktitle={The Third Annual Conference on Advances in Cognitive Systems 2015},
address={Atlanta, Georgia},
date={2015-05},
pages={1-14}
}

@inproceedings{ganzfried2018bayesian,
    title="Bayesian opponent exploitation in Imperfect-Information Games",
    author="Sam Ganzfried and Qingyun Sun",
    booktitle="2018 IEEE Conference on Computational Intelligence and Games (CIG)",
    pages="1--8",
    year={2018}
}

就会变为:testaddbranew.bib

%% 
%% bib file modified by bibmap.py
%% 2024-05-30T20:39:58
%% 

@inproceedings{chen2021visual,
    author = {Chen, Boyuan and Hu, Yuhang and Kwiatkowski, Robert and Song, Shuran and Lipson, Hod},
    booktitle = {2021 IEEE International Conference on Robotics and Automation (ICRA)},
    title = {{Visual perspective taking for opponent behavior modeling}},
    year = {2021},
    pages = {13678-13685},
    keywords = {Training;Visualization;Automation;Conferences;Games;Predictive models;Robots},
    doi = {10.1109/ICRA48506.2021.9562028},
}

@inproceedings{Alford2015,
    title = {{Active Behavior Recognition in Beyond Visual Range Air Combat}},
    author = {Ron Alford and Hayley Borck and Justin Karneeb},
    booktitle = {The Third Annual Conference on Advances in Cognitive Systems 2015},
    address = {Atlanta, Georgia},
    date = {2015-05},
    pages = {1-14},
}

@inproceedings{ganzfried2018bayesian,
    title = {{Bayesian opponent exploitation in Imperfect-Information Games}},
    author = {Sam Ganzfried and Qingyun Sun},
    booktitle = {2018 IEEE Conference on Computational Intelligence and Games (CIG)},
    pages = {1--8},
    year = {2018},
}