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

Handle openaccess with field other than doi/url/eprint #28

Closed
bastien-roucaries opened this issue Jul 2, 2021 · 2 comments
Closed

Handle openaccess with field other than doi/url/eprint #28

bastien-roucaries opened this issue Jul 2, 2021 · 2 comments
Labels
enhancement New feature or request wontfix This will not be worked on

Comments

@bastien-roucaries
Copy link

Hi,

This is a bug report but I think a documentation one. Some patent are openacess depending of country and if publied.

So I need to add openaccess icon only if type match open access country and if published date exist. And in this case I can generate a url.

I can I think absuse of the eprint and eprinttype field and use a sourcemap to fill eprint and eprinttype=patent if it match.

What do you think ?

Bastien

@bastien-roucaries bastien-roucaries added the bug Something isn't working label Jul 2, 2021
@bastien-roucaries
Copy link
Author

bastien-roucaries commented Jul 2, 2021

Something like this work

\DeclareSourcemap{
   \maps[datatype=bibtex]{
     \map[overwrite]{
       \step[typesource=patent,typetarget=patent,final]
       \step[notfield=eprint,final]
       \step[notfield=eprinttype,final]
       \step[notfield=eprintclass,final]
       \step[fieldsource=type,fieldset=type,origfieldval,final]
       \step[fieldsource=number,fieldset=number,origfieldval,final]
       \step[fieldsource=type,match=\regexp{patent(?:req)?(?:us|uk|fr)?},final]
       \step[fieldsource=number,fieldset=eprint,append,origfieldval,final=false]
       \step[fieldsource=type,fieldset=eprinttype,fieldvalue={patent},final=false]
       \step[fieldsource=type,fieldset=eprintclass,origfieldval,final=false]
     }
     \map[overwrite]{
       \step[typesource=patent,typetarget=patent,final]
       \step[notfield=pubstate,final]
       \step[notfield=year,final]
       \step[notfield=date,final]
       \step[notfield=publishedyear,final]
       \step[notfield=publisheddate,final]
       \step[fieldsource=fileddate,fieldset=pubstate,fieldvalue=embargoted]
     }
     \map[overwrite]{
       \step[typesource=patent,typetarget=patent,final]
       \step[notfield=pubstate,final]
       \step[notfield=year,final]
       \step[notfield=date,final]
       \step[notfield=publishedyear,final]
       \step[notfield=publisheddate,final]
       \step[fieldsource=filedyear,fieldset=pubstate,fieldvalue=embargoted]
     }
   }
 }

\ExplSyntaxOn
\def\patentcanonical#1#2{
  \str_case_e:nnTF {#1}
  {
    {patentfr} {FR}
    {patentuk} {GB}
    {patentus} {US}
  }{#2}{#1}
}
\def\patenturl#1#2{
  worldwide.espacenet.com/patent/search?q=pn\%3D\patentcanonical{#1}{#2}
}
\ExplSyntaxOff
%\DeclareFieldFormat{eprint:patent}{%
%    EspaceNet\addcolon\space%
%    \hrefeprint{https://\patenturl{\thefield{eprintclass}}{\thefield{eprint}}}{\patentcanonical{\thefield{eprintclass}}{\thefield{eprint}}}
%  }%
\DeclareFieldFormat{eprint:patent}{}
\DeclareOpenAccessEprintUrl[always]{patent}{https://\patenturl{\thefield{eprintclass}}{\thefield{eprint}}}

@moewew
Copy link
Owner

moewew commented May 7, 2022

This looks like very advanced stuff for which I cannot imagine a useful general interface or a place in the documentation.

If you think this could be useful for other people as well, you can always share your code via question and self-answer on TeX.SX or other TeX forums. With the right keywords this makes it likely that those who look for a similar thing will find it.

@moewew moewew closed this as completed May 7, 2022
@moewew moewew added enhancement New feature or request wontfix This will not be worked on and removed bug Something isn't working labels May 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

2 participants