kmpoppe / fhrsPlugin

JOSM Plugin: Search establishments in FHRS API and merge data into OSM
https://wiki.openstreetmap.org/wiki/User:Kmpoppe/Plugins#fhrsPlugin
GNU General Public License v3.0
4 stars 0 forks source link

Capitalise Returned Values #9

Closed pqhf5kd closed 4 years ago

pqhf5kd commented 4 years ago

FHRS returns address values all in uppercase. Is it possible to transform the text to capitalise only the first letter of each word?

kmpoppe commented 4 years ago

That's a problem with the source data. The FHRS recordset is all caps, see this response from the API for your example:

{
    "FHRSID": 588957,
    "LocalAuthorityBusinessID": "2583",
    "BusinessName": "THE KEBAB HOUSE",
    "BusinessType": "Takeaway/sandwich shop",
    "BusinessTypeID": 7844,
    "AddressLine1": "5 WESTCROFT PARADE",
    "AddressLine2": "STATION ROAD",
    "AddressLine3": "NEW MILTON",
    "AddressLine4": "",
    "PostCode": "BH25 6JG",
    "Phone": "",
    "RatingValue": "3",
    "RatingKey": "fhrs_3_en-gb",
    "RatingDate": "2019-11-27T00:00:00",
    "LocalAuthorityCode": "138",
    "LocalAuthorityName": "New Forest",
    "LocalAuthorityWebSite": "http://www.newforest.gov.uk",
    "LocalAuthorityEmailAddress": "hygiene.rating@nfdc.gov.uk",
    "scores": {
        "Hygiene": 5,
        "Structural": 10,
        "ConfidenceInManagement": 10
    },
    "SchemeType": "FHRS",
    "geocode": {
        "longitude": "-1.654109",
        "latitude": "50.751928"
    },
    "RightToReply": "",
    "Distance": null,
    "NewRatingPending": false,
    "meta": {
        "dataSource": "Lucene",
        "extractDate": "0001-01-01T00:00:00",
        "itemCount": 0,
        "returncode": "OK",
        "totalCount": 1,
        "totalPages": 1,
        "pageSize": 1,
        "pageNumber": 1
    },
    "links": [
        {
            "rel": "self",
            "href": "http://api.ratings.food.gov.uk/establishments/588957"
        }
    ]
}

I could very well write a function that checks for the casing of the values, I'll think about this - because I'll need to throw a warning along with it so that the user doesn't change casing to something that's wrong just because the source data is bogus.

pqhf5kd commented 4 years ago

That's a problem with the source data.

Of course

I could very well write a function that checks for the casing of the values, I'll think about this - because I'll need to throw a warning along with it so that the user doesn't change casing to something that's wrong just because the source data is bogus.

For the Name value, this could be a problem but for addr:street and addr:city, any word that uses a lowercase for the first letter would surely be an edge case.

pqhf5kd commented 4 years ago

https://en.wikipedia.org/wiki/Street_names_of_the_City_of_London

I just skimmed this list of street names in the city of London and didn't see any lowercase examples.

https://en.wikipedia.org/wiki/List_of_towns_in_England

But looking at the list of towns in England, in/upon/on/under/over/with are lowercase. There are maybe 60 examples.

kmpoppe commented 4 years ago

I just skimmed this list of street names in the city of London and didn't see any lowercase examples.

I wonder whether this is true for every town in the UK, Germany has it's fair share of lowercase names as well.

But looking at the list of towns in England, in/upon/on/under/over/with are lowercase. There are maybe 60 examples.

To be precise everything in hyphens (-in-, -upon-, ...) is ALWAYS lower case, if there are spaces in between parts, it seems only "and" and "with" are lowercase. Is this a good pattern for the other parts of the UK as well?