Skip to content

Strings cleaner > FR > remove ligne from route long name & station from trip head-sign - #34

Merged
mmathieum merged 3 commits into
masterfrom
mm/ligne_station_fr_strings
May 6, 2026
Merged

mmathieum merged 3 commits into
masterfrom
mm/ligne_station_fr_strings

Conversation

@mmathieum

@mmathieum mmathieum commented May 6, 2026 •

Copy link
Copy Markdown
Member

@mmathieum mmathieum self-assigned this May 6, 2026
@mmathieum
mmathieum marked this pull request as ready for review May 6, 2026 17:57
@mmathieum mmathieum changed the title Strings cleaner > FR > remove "ligne" from route long name & "station" from trip head-sign Strings cleaner > FR > remove ligne from route long name & station from trip head-sign May 6, 2026

ghost left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request introduces French language cleaning rules, specifically adding logic to remove the word 'ligne' from route names and 'station' from subway headsigns. The review feedback suggests using the cleanWordsFR utility for more robust pattern matching of 'ligne', updating the replacement logic to use EMPTY, and extending the removal of 'station' to light rail and train/rail types to ensure consistency with existing English cleaning rules.

I am having trouble creating individual review comments. Click here to see my feedback.

src/main/java/org/mtransit/commons/CleanUtils.java (736-737)

medium

Instead of manually defining the regex and replacement for "ligne", you should use the cleanWordsFR utility. This is more robust as it uses word boundaries (via lookarounds) and handles Unicode characters correctly for French, which is consistent with how other patterns (like STATION or CLEAN_ET) are defined in this class. Note that when using cleanWords, the replacement should be an empty string (or EMPTY) because the lookarounds preserve surrounding whitespace.

	static final Pattern LIGNE = cleanWordsFR("ligne");

src/main/java/org/mtransit/commons/StringsCleaner.kt (25)

medium

If CleanUtils.LIGNE is updated to use cleanWordsFR, the replacement here should be changed to EMPTY. This is because cleanWords uses lookarounds to match the word without consuming the surrounding whitespace, making the $1$3 replacement unnecessary and potentially incorrect if punctuation is involved.

            routeLongName = CleanUtils.LIGNE.matcher(routeLongName).replaceAll(EMPTY)

src/main/java/org/mtransit/commons/StringsCleaner.kt (57-62)

medium

For consistency with the English implementation (lines 47-54), consider removing "station" from French trip head-signs for light rail (0) and train/rail (2) as well, not just subway (1). In many French-speaking transit systems, "Station" is commonly used for tramways and sometimes for suburban rail, and removing it helps save valuable screen space.

        if (languages?.contains(Locale.FRENCH) == true) {
            when (routeType) {
                0, // light rail
                1, // subway
                2, // train/rail
                    -> {
                    tripHeadsign = CleanUtils.STATION.matcher(tripHeadsign).replaceAll(EMPTY)
                }
            }
        }

ghost left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Updates StringsCleaner to better normalize FR/EN transit text by removing redundant words in route long names and trip headsigns (intended for FR “ligne” and FR subway “station”), supported by new/adjusted regex patterns in CleanUtils.

Changes:

  • Remove “line” (EN) and “ligne” (FR) from route long names during cleaning.
  • Remove “station” from French subway (routeType=1) trip headsigns.
  • Add new CleanUtils patterns to support the new removals and expose FR_CA_STATION for reuse.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
src/main/java/org/mtransit/commons/StringsCleaner.kt Adds EN/FR word-removal steps for route long names and FR subway trip headsigns.
src/main/java/org/mtransit/commons/CleanUtils.java Introduces new patterns for “line”/“ligne” and exposes FR_CA_STATION for use by StringsCleaner.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Co-authored-by: Copilot Autofix powered by AI <[email protected]>
@mmathieum

ghost commented May 6, 2026

Copy link
Copy Markdown
Member Author

/gemimi review

@mmathieum

ghost commented May 6, 2026

Copy link
Copy Markdown
Member Author

/gemini review

ghost left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request introduces French language cleaning logic for route names and trip headsigns, specifically targeting the words 'ligne' and 'station', while also refactoring the English 'line' cleaning process. The review feedback suggests expanding the French 'station' removal to include light rail and train route types to maintain consistency with the existing English cleaning logic.

@mmathieum
mmathieum merged commit 9fd8a06 into master May 6, 2026
@mmathieum
mmathieum deleted the mm/ligne_station_fr_strings branch May 6, 2026 23:19
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