Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

encoding error #1

Open
ballII opened this issue Mar 2, 2022 · 6 comments
Open

encoding error #1

ballII opened this issue Mar 2, 2022 · 6 comments

Comments

@ballII
Copy link

ballII commented Mar 2, 2022

I got SyntaxError:
Non-ASCII character '\xe9' in file /biblatex-map-master/hanzicollationpinyin.py on line 3, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details

How can I deal with this problem? Thanks.

@hushidong
Copy link
Owner

hushidong commented Mar 3, 2022

which system are you using?linux or windows?
which python version are you using? python2 or python3? and what package kit, ananconda?

the files : hanzicollationpinyin.py hanzicollationstroke.py hanzipinyindatabase.py is just a dict or list for Chinese characters, so they are intrinsic Non-ASCII character, these files are UTF-8 encoded.

to solove the Error? you can try:

  1. use python3 like:
    python3 bibmap.py jobname

  2. comment the following code in bibmap.py if you are not Chinese user, because these code are used to add Pinyin or Stroke info for bibentries in the bib

import hanzicollationpinyin
import hanzicollationstroke
import hanzipinyindatabase

sqpinyindata=hanzicollationpinyin.sqpinyindata
sqstrokedata=hanzicollationstroke.sqstrokedata
hzpinyindata=hanzipinyindatabase.pinyindatabase

@ballII
Copy link
Author

ballII commented Mar 3, 2022

Thanks. I used python3 instead and no longer encountered the problem of Non-ASCII characters. But bibmap still does not work for me. My command was:
bibmap.py example.bib -m bibmaptitlecase.py
But the newexample.bib I got still have titles in sentence case, not in title case.

There was an error message during the procedure: KeyError: 'useprefix'

My example.bib:
@article{Mattern2022, abstract = {We study the ultrafast electronic transport of energy in a photoexcited nanoscale Au/Fe hetero-structure by modeling the spatiotemporal profile of energy densities that drives transient strain, which we quantify by femtosecond x-ray diffraction. This flow of energy is relevant for intrinsic demagnetization and ultrafast spin transport. We measured lattice strain for different Fe layer thicknesses ranging from few atomic layers to several nanometers and modeled the spatiotemporal flow of energy densities. The combination of a high electron-phonon coupling coefficient and a large Sommerfeld constant in Fe is found to yield electronic transfer of nearly all energy from Au to Fe within the first hundreds of femtoseconds.}, author = {Mattern, M. and von Reppert, A. and Zeuschner, S. P. and Pudell, J.-E. and K{\"{u}}hne, F. and Diesing, D. and Herzog, M. and Bargheer, M.}, doi = {10.1063/5.0080378}, issn = {0003-6951}, journal = {Appl. Phys. Lett.}, month = {feb}, number = {9}, pages = {092401}, title = {{Electronic energy transport in nanoscale Au/Fe hetero-structures in the perspective of ultrafast lattice dynamics}}, url = {https://aip.scitation.org/doi/10.1063/5.0080378}, volume = {120}, year = {2022} } @article{Uwada2012, author = {Uwada, Takayuki and Fujii, Sho and Sugiyama, Teruki and Usman, Anwar and Miura, Atsushi and Masuhara, Hiroshi and Kanaizuka, Katsuhiko and Haga, Masa-aki}, doi = {10.1021/am201799b}, issn = {1944-8244}, journal = {ACS Appl. Mater. Interfaces}, month = {mar}, number = {3}, pages = {1158--1163}, title = {{Glycine Crystallization in Solution by CW Laser-Induced Microbubble on Gold Thin Film Surface}}, url = {https://pubs.acs.org/doi/10.1021/am201799b}, volume = {4}, year = {2012} }

@ballII
Copy link
Author

ballII commented Mar 4, 2022

After I replaced the double braces ( {{...}} ) around the titles with single braces in example.bib, the script worked, but it changed all the titles into sentence case instead of title case (including wrongly replacing "CW" in "CW Laser-Induced Microbubble" with "cw". How do I make the titles to appear in title case?

@hushidong
Copy link
Owner

hushidong commented Mar 4, 2022

  1. the {} in a field is used to protect the case of the text, so if you have some text case to protect, you need put them in a {}.
    like:
 title = {Glycine Crystallization in Solution by {CW Laser-Induced} Microbubble on Gold Thin Film Surface}, 

here the case of {CW Laser-Induced} will not be changed.

and field like

title ={ {Glycine Crystallization in Solution by CW Laser-Induced Microbubble on Gold Thin Film Surface}}, 

the whole filed will not be changed.

  1. and set title case setting in bibmaptitlecase.py, like:
sourcemaps=[
	[#map1:将设置title为sentencecase
		{"fieldsource":"title","final":True},#
		{"fieldset":"title","origfieldval":True,"fieldfunction":'settitlecase',"overwrite":True}#step1
	],
	[#map2:将设置booktitle为titlecase
		{"fieldsource":"booktitle","final":True},#
		{"fieldset":"booktitle","origfieldval":True,"fieldfunction":'settitlecase',"overwrite":True}#step1
	],
	[#map3:将设置journal为titlecase
		{"fieldsource":"journal","final":True},#
		{"fieldset":"journal","origfieldval":True,"fieldfunction":'settitlecase',"overwrite":True}#step1
	],
	[#map3:将设置journaltitle为titlecase
		{"fieldsource":"journaltitle","final":True},#
		{"fieldset":"journaltitle","origfieldval":True,"fieldfunction":'settitlecase',"overwrite":True}#step1
	]
]

in the original setting file, title is set to be sentencecase, so you need to change

"fieldfunction":'setsentencecase'

to

"fieldfunction":'settitlecase'
  1. and if you don't need to generate a bbl file, you can add option --nofmt to aviod the key error,like
python3 bibmap.py test.bib -m bibmaptitlecase.py --nofmt

@hushidong
Copy link
Owner

About the key error 'prefix', code will be checked soon , it may be a bug.

@hushidong
Copy link
Owner

hushidong commented Mar 4, 2022

it is caused by missing a set "useprefix":False,#使用前缀名 in the formatoptions in file bibstylenumeric.py, the correct set is like:

formatoptiondatabase={
"style":['numeric','authoryear'],#这个选项目前暂无功能
"nameformat":['uppercase','lowercase','givenahead','familyahead','pinyin','reverseorder'],#姓名处理选项:uppercase,lowercase,given-family,family-given,pinyin
"citenameformat":['titlecase','uppercase'],#标注中的姓名处理选项:uppercase,titlecase
"giveninits":['space','dotspace','dot','terse','false'],#使用名的缩写,space表示名见用空格分隔,dotspace用点加空格,dot用点,terse无分隔,false不使用缩写
"useprefix":[True,False],#使用前缀名
"usesuffix":[True,False],#使用后缀名
"maxbibnames":3,#
...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants