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

Overwrite existing data model in tool mode #301

Closed
moewew opened this issue Dec 30, 2019 · 7 comments
Closed

Overwrite existing data model in tool mode #301

moewew opened this issue Dec 30, 2019 · 7 comments

Comments

@moewew
Copy link
Contributor

moewew commented Dec 30, 2019

It was pointed out to me today that my answer to https://tex.stackexchange.com/q/265895/35864 on TeX.SX ceased to work properly, so I tried to make it work with newer Biber versions.

Consider the following .bib file augustus.bib

@article{kattan_timeseries_2015,
  title = {Time-series event-based prediction: An unsupervised learning framework based on genetic programming},  
  journaltitle = {Information Sciences},
  author = {Kattan, Ahmed and Fatima, Shaheen and Arif, Muhammad},
  date = {2015-04}
}
@book{lorem,
  TITLE = {Lorem},  
  Author = {Anne Uthor},
  DaTe = {2015}
}
@book{ipsum,
  title = {Ipsum},  
  author = {Anne Uthor},
  date = {2015-08-07},
}

With biber-datea.conf

<?xml version="1.0" encoding="UTF-8"?>
<config>
  <output_fieldcase>lower</output_fieldcase>
  <datamodel>
    <fields>
      <field fieldtype="field" datatype="literal">yeara</field>
      <field fieldtype="field" datatype="literal">montha</field>
    </fields>
    <entryfields>
      <field>yeara</field>
      <field>montha</field>
    </entryfields>
  </datamodel>
  <sourcemap>
    <maps datatype="bibtex">
      <map map_overwrite="1">
        <map_step map_field_source="date" map_match="[0-9]{4}-([0-9]{2})" map_final="1"/>
        <map_step map_field_set="montha" map_field_value="$1"/>
      </map>
      <map map_overwrite="1">
        <map_step map_field_source="date" map_match="([0-9]{4})" map_final="1"/>
        <map_step map_field_set="yeara" map_field_value="$1"/>
      </map>
    </maps>
  </sourcemap>
</config>
biber --tool --configfile=biber-datea.conf augustus.bib  

produces

@article{kattan_timeseries_2015,
  author = {Kattan, Ahmed and Fatima, Shaheen and Arif, Muhammad},
  date = {2015-04},
  journaltitle = {Information Sciences},
  montha = {04},
  title = {Time-series event-based prediction: An unsupervised learning framework based on genetic programming},
  yeara = {2015},
}

@book{lorem,
  author = {Uthor, Anne},
  date = {2015},
  title = {Lorem},
  yeara = {2015},
}

@book{ipsum,
  author = {Uthor, Anne},
  date = {2015-08-07},
  montha = {08},
  title = {Ipsum},
  yeara = {2015},
}

as expected.

But if I now try to overwrite year and month in biber-date.conf

<?xml version="1.0" encoding="UTF-8"?>
<config>
  <output_fieldcase>lower</output_fieldcase>
  <datamodel>
    <fields>
      <field fieldtype="field" datatype="literal">year</field>
      <field fieldtype="field" datatype="literal">month</field>
    </fields>
    <entryfields>
      <field>year</field>
      <field>month</field>
    </entryfields>
  </datamodel>
  <sourcemap>
    <maps datatype="bibtex">
      <map map_overwrite="1">
        <map_step map_field_source="date" map_match="[0-9]{4}-([0-9]{2})" map_final="1"/>
        <map_step map_field_set="montha" map_field_value="$1"/>
      </map>
      <map map_overwrite="1">
        <map_step map_field_source="date" map_match="([0-9]{4})" map_final="1"/>
        <map_step map_field_set="yeara" map_field_value="$1"/>
      </map>
    </maps>
  </sourcemap>
</config>

the output of

biber --tool --configfile=biber-date.conf augustus.bib  

is

@article{kattan_timeseries_2015,
  author = {Kattan, Ahmed and Fatima, Shaheen and Arif, Muhammad},
  date = {2015-04},
  journaltitle = {Information Sciences},
  title = {Time-series event-based prediction: An unsupervised learning framework based on genetic programming},
}

@book{lorem,
  author = {Uthor, Anne},
  date = {2015},
  title = {Lorem},
}

@book{ipsum,
  author = {Uthor, Anne},
  date = {2015-08-07},
  title = {Ipsum},
}

not quite as hoped.

Would it be possible to get the expected output here as well.

I realise that year and month are tricky beasts, but especially in the light of #275 I expected my .conf to override the existing data model and make year and month normal fields that can and will be output as usual.

@plk
Copy link
Owner

plk commented Dec 30, 2019

I am about to overhaul the datamodel merging code and I will check this too.

plk added a commit that referenced this issue Dec 31, 2019
@plk
Copy link
Owner

plk commented Dec 31, 2019

Should be fixed in 2.15 DEV - see what you think. Bibtex ouput now checks to see if year and month are datepart fields and if not, it will try to output them as-is, unless there is also a day field as this is not a valid stand-alone field and therefore must be rolled into date.

@schoeps
Copy link

schoeps commented Jan 1, 2020

@moewew @plk I was the one complaining at https://tex.stackexchange.com/q/265895/35864, so thanks! I use the holidays to clean up my huge bib-file :)

@moewew
Copy link
Contributor Author

moewew commented Jan 1, 2020

Works very well in the tests I came up with. Thanks you very much.

@schoeps
Copy link

schoeps commented Jan 2, 2020

Indeed, works also for me. I am using this to make biber spit out a (legacy) bibtex-compatible bib-file. Thanks!

@LukasCBossert
Copy link

Great - but when will the version with this fix be released?

@plk
Copy link
Owner

plk commented May 23, 2020

I think we will be releasing a new version fairly soon.

@plk plk closed this as completed May 23, 2020
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

4 participants