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

DRAFT: Full translation implementation #155

Draft
wants to merge 15 commits into
base: main
Choose a base branch
from

Conversation

kylerchin
Copy link
Contributor

This is a collaborative effort between the Rust-Transit Maintainers and the Catenary Transit Initiatives https://catenarymaps.org team, a nonprofit designing open-source public transport software. We seek comments from the community and maintainers.

Team members responsible:
@CallMeJai @AndrewHC36 @kylerchin
Thank you to @Robbe7730 for the original idea of RawTranslations

THIS IS A WORK IN PROGRESS DRAFT AND WILL BE UNMARKED ONCE READY

This discussion originated at https://github.com/orgs/catenarytransit/discussions/2

Key points of discussion:

  • How to cleanup code converting field_name to enum
  • Trait implementation from @Tristramg
  • Utility summary tables included

Final notes:
Note that as GTFS is an evolving specification, the contents of the translatable field will change over time.

@kylerchin
Copy link
Contributor Author

Documentation will be added once everything is set!

Thank you to Andrew especially for spending hours with me to whiteboard out data structures and coming up with an implementation.

Attached is our whiteboard understanding and possible data structure examples of implementation:

20240113_223507

@kylerchin
Copy link
Contributor Author

Should we keep the HashMap like this? Or should we use the trait system? or both? What direction should the lookup mechanism take?

I personally would be alright with the current structure and a trait lookup mechanism, providing options would make the library more friendly for developers.

@andrew-shc
Copy link

I was thinking for the TranslationsLookup, embed the record id and record sub id type into the field names enum directly to reduce invalid usage, and so the user knows whether this field just needs a record id or also with a record sub id.

Refer to the record_sub_id’s requirement in description, though they point out agencies can add additional fields that might invalidate the specified requirements.

src/gtfs.rs Outdated Show resolved Hide resolved
Copy link
Collaborator

@antoine-de antoine-de left a comment

Choose a reason for hiding this comment

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

Thanks for the contribution!

Sorry for the time taken to review this, I don't have much time for the moment, and this is quite a big chunk to review 😁

by curiosity, why didn't you use the associated types used in @Tristramg POC? There are not convenient to use?

I'll try to properly review this a bit later, this is my notes after the first read.

let mut possible_translations:HashSet<(TranslatableField, LanguageTag)> = HashSet::new();

for row in raw_translations {
if let Ok(language_tag) = LanguageTag::parse(row.language.as_str()) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I know it's a POC, but I'll just add a comment to not forget that this should either stop on error or log something

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Got it, will do!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This isn't a big issue to implement for us, because every agency I've seen so far does use valid language strings

raw_translations: Vec<RawTranslation>,
) -> (
HashMap<TranslationLookup, String>,
Vec<(TranslatableField, LanguageTag)>
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think I might be missing something, but I'm not really sure I understand why this TranslatableField is used?
Can't we just have the HashMap<TranslationLookup, String>

Maybe it's because there isn't the translation mechanism yet (which is fine, but it makes it more difficult to understand this code)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This creates the summary together because it's cleaner to do it in the same iter instead of writing a second iter in the primary gtfs. I can add some comments to explain what's going on if you'd like.

@kylerchin
Copy link
Contributor Author

We plan on implementing traits properly in a bit


//oh no... i need trip_id... but that's contained in the parent...

// should I add trip_id to stop_times?
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I need assistance here, can I add Arc to stop_times to allow headsign translation to work?

Los Angeles Metro and other agencies use dynamic headsigns that change along a route, thus translation of stop_times is important here.

CC: @antoine-de @Tristramg @CallMeJai @AndrewHC36

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.

3 participants