openaddresses / machine

Scripts for running OpenAddresses on a complete data set and publishing the results.
http://results.openaddresses.io/
ISC License
97 stars 36 forks source link

New attribute function for extracting single value for multivalued fields #766

Open macieg opened 4 years ago

macieg commented 4 years ago

Currently available attribute functions don't allow to get a single value if a field has many of them. Good example might be Poland:

      <prg-ad:jednostkaAdmnistracyjna>Polska</prg-ad:jednostkaAdmnistracyjna>
      <prg-ad:jednostkaAdmnistracyjna>kujawsko-pomorskie</prg-ad:jednostkaAdmnistracyjna>
      <prg-ad:jednostkaAdmnistracyjna>brodnicki</prg-ad:jednostkaAdmnistracyjna>
      <prg-ad:jednostkaAdmnistracyjna>Bartniczka</prg-ad:jednostkaAdmnistracyjna>

This is a part of a single address record. It contains many values for a key "prg-ad:jednostkaAdmnistracyjna". Region is always the second value here (kujawsko-pomorskie in this case).

I propose adding a new attribute function called i.e just get to extract single value.

            "conform": {
                "region": {
                    "function": "get",
                    "field": "jednostkaAdministracyjna",
                    "index": 1
                }
            }
macieg commented 4 years ago

The PR is here - https://github.com/openaddresses/machine/pull/767

macieg commented 4 years ago

There was a wrong import https://github.com/openaddresses/machine/pull/769 @iandees please approve

macieg commented 4 years ago

@iandees Another one... Could you guide me how to run CI before merge? https://github.com/openaddresses/machine/pull/770

iandees commented 4 years ago

I think it should be running itself. @migurski am I remembering right that machine had CI tests?

iandees commented 4 years ago

Not sure why the CI wasn't running on your branch, but you can follow these instructions to get tests running locally: https://github.com/openaddresses/machine/blob/master/docs/install.md#local-development

iandees commented 4 years ago

Thanks for working through this!