Skip to content

Update place names 978 #1013

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

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

hippietrail
Copy link
Collaborator

Issues

#978

Description

Many place names have changed over the years. This lint looks for uses of known deprecated names and offers the new name.

It doesn't attempt to include all place names. My rule of thumb was to include ones where I recognized at least the old name or the new name, and isn't too "ancient".

It can:

  • If known, it includes the year the new name was accepted in the message.
  • It can handle multiple old names.

It cannot yet:

  • Handle old place names with hyphens.
  • Offer multiple new names, such as with and without accents.
  • Recognize old names that don't use the correct case.
  • Recognize old names with variations in accents.
  • Replicate the exact whitespace between words if both the old and new names are multi-word.

How Has This Been Tested?

  • I included unit tests for all the straightforward cases and edge cases I could think of.
  • cargo test passes with no problems.

Checklist

  • I have performed a self-review of my own code
  • I have added tests to cover my changes

Many place names have changed over the years. This lint looks for uses of known deprecated names and offers the new name.

It doesn't attempt to include all place names. My rule of thumb was to include ones where I recognized at least the old name or the new name, and isn't too "ancient".

It can:

- If known, it includes the year the new name was accepted in the message.
- It can handle multiple old names.

It cannot yet:

- Handle old place names with hyphens.
- Offer multiple new names, such as with and without accents.
- Recognize old names that don't use the correct case.
- Recognize old names with variations in accents.
- Replicate the exact whitespace between words if both the old and new names are multi-word.

// (year, new name), [old names]
const RAW_PLACE_NAME_UPDATES: &[PlaceNameEntryStr] = &[
// Africa
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks very expensive to iterate through. Could you refactor it into a PatternLinter to take advantage of caching?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks very expensive to iterate through. Could you refactor it into a PatternLinter to take advantage of caching?

Really? I did my best to make it all use char slices and lazy static to convert the structure just once at startup... But I am very much a Rust noob so probably missed some important things... And yes this doesn't do caching.

I did think when I was nearly done that PatternLinter would also work. I'll look into it!

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doing it once at startup doesn't negate the fact that you're iterating through each element for every word in the document. Run cargo bench and see what happens.

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

Successfully merging this pull request may close these issues.

2 participants