Humans-of-Julia / Bibliography.jl

General bibliography manager in pure Julia
MIT License
65 stars 13 forks source link

Cannot find title field for this BibTeX article #7

Closed ali-ramadhan closed 4 years ago

ali-ramadhan commented 4 years ago

Not sure if the BibTeX entry is bad but it seems that import_bibtex could not pull the title field out for some reason.

julia> using Bibliography

shell> cat bad_article.bib
@article{Hholami16,
        title = {{FFT}, {FMM}, or {Multigrid}? {A} comparative {Study} of {State}-{Of}-the-{Art} {Poisson} {Solvers} for {Uniform} and {Nonuniform} {Grids} in the {Unit} {Cube}},
        volume = {38},
        doi = {10.1137/15M1010798},
        number = {3},
        journal = {SIAM Journal on Scientific Computing},
        author = {Gholami, Amir and Malhotra, Dhairya and Sundar, Hari and Biros, George},
        year = {2016},
        pages = {C280--C306}
}

julia> import_bibtex("bad_article.bib")
ERROR: Missing the title field(s).
Stacktrace:
 [1] error(::String) at ./error.jl:33
 [2] BibInternal.BibTeX.Article(::String, ::String, ::String, ::String, ::String, ::String, ::String, ::String, ::String, ::String, ::String, ::String, ::Dict{String,String}) at /home/alir/.julia/packages/BibInternal/mZf28/src/bibtex.jl:102
 [3] BibInternal.BibTeX.Article(::String, ::Dict{String,String}) at /home/alir/.julia/packages/BibInternal/mZf28/src/bibtex.jl:137
 [4] make_bibtex_entry(::String, ::String, ::Dict{String,String}) at /home/alir/.julia/packages/BibInternal/mZf28/src/bibtex.jl:14
 [5] macro expansion at /home/alir/.julia/packages/Automa/fyalL/src/codegen.jl:137 [inlined]
 [6] parse(::String) at /home/alir/.julia/packages/BibParser/Qhq5E/src/bibtex.jl:137
 [7] parse_file at /home/alir/.julia/packages/BibParser/Qhq5E/src/bibtex.jl:144 [inlined]
 [8] import_bibtex(::String) at /home/alir/.julia/packages/Bibliography/MZcl2/src/bibtex.jl:2
 [9] top-level scope at REPL[2]:1
ali-ramadhan commented 4 years ago

Same with this entry:

@article{Qiu02,
    title = {On the {Construction}, {Comparison}, and {Local} {Characteristic} {Decomposition} for {High}-{Order} {Central} {WENO} {Schemes}},
    volume = {183},
    doi = {10.1006/jcph.2002.7191},
    journal = {Journal of Computational Physics},
    author = {Qiu, Jianxian and Shu, Chi-Wang},
    year = {2002},
    pages = {187--209}
}
Azzaare commented 4 years ago

Nested braces are not yet supported, unless you're value is inside a quoted "" value. For instance, the following would work.

@article{Qiu02,
    title = "On the {Construction}, {Comparison}, and {Local} {Characteristic} {Decomposition} for {High}-{Order} {Central} {WENO} {Schemes}",
    volume = {183},
    doi = {10.1006/jcph.2002.7191},
    journal = {Journal of Computational Physics},
    author = {Qiu, Jianxian and Shu, Chi-Wang},
    year = {2002},
    pages = {187--209}
}

Automa.jl, with which this BibTeX parser is written, provides conditional state exit (for instance when the numbers of opening and closing braces are equal), but I don't get how to use it correctly. Unfortunately, I could not get help from the package maintainer so far. (maybe I should ask on the discourse)

I can add artificially one or two level of nested braces, but it will increase the precompilation time by a lot I think. I'm going to try, just in case.

On the long term, if the automa is too big, I would like to try to provide binaries of it (I don't mind if I need one day to compile it ...). If it is not viable, write a full parser by myself but ...

Also, nested braces need to be handled to have an output without it. The original bib entry (reformatted) is kept within the BibInternal format.

ali-ramadhan commented 4 years ago

Ah nice, didn't realize the limitation with the nested braces. I'm happy to just change my titles to use the double quotes.

Azzaare commented 4 years ago

I will mark the issue as closed. However, we do not replace the content of braces for the moment.