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

fix: Glossary sort order: Change src length sort condition and use Language Dependent sorter #1154

Merged

Conversation

miurahr
Copy link
Member

@miurahr miurahr commented Oct 3, 2024

Pull request type

  • Bug fix
  • Refactor

Which ticket is resolved?

What does this PR change?

  • use Collator to sort glossary terms with Locale dependent order
  • refactor GlossarySearcher ctor to accept target language for collator
  • refactor and update test GlossarySearcherTest and FindGlossaryThreadTest

Other information

t-cordonnier and others added 2 commits September 27, 2024 15:56
- Add sort test cases with locales
- GlossarySearcher ctor accept src and target language
- use startsWith instead of contains for src length sort detection
- fix target term length sort argument.

Signed-off-by: Hiroshi Miura <[email protected]>
@miurahr miurahr requested a review from t-cordonnier October 3, 2024 04:32
@miurahr miurahr added the bug label Oct 3, 2024
- Use GlossarySearcher#search
- Drop duplicated search in GlossarySearcher

Signed-off-by: Hiroshi Miura <[email protected]>
- Move test cases to GlossarySearcherTest.java

Signed-off-by: Hiroshi Miura <[email protected]>
Copy link

github-actions bot commented Oct 3, 2024

❌ Unit Tests, Quality checks, and Acceptance Tests failed.

Please look a Gradle Scan page for details:
https://gradle.com/s/cng55n6oqxx44

Signed-off-by: Hiroshi Miura <[email protected]>
Comment on lines 275 to 277
if (c == 0 && Preferences.isPreferenceDefault(Preferences.GLOSSARY_SORT_BY_SRC_LENGTH, true)
&& (o2.getSrcText().contains(o1.getSrcText())
|| o1.getSrcText().contains(o2.getSrcText()))) {
&& (o2.getSrcText().startsWith(o1.getSrcText())
|| o1.getSrcText().startsWith(o2.getSrcText()))) {
Copy link
Member Author

@miurahr miurahr Oct 25, 2024

Choose a reason for hiding this comment

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

In org.omegat.gui.preferences.view.GlossaryPreferencesController#initFromPrefs, the default value of Preferences.GLOSSARY_SORT_BY_SRC_LENGTH is false but here is true.

        panel.sortBySrcTextLengthCheckBox.setSelected(Preferences.isPreferenceDefault(
                Preferences.GLOSSARY_SORT_BY_SRC_LENGTH, false));

It should be false for consistency.

and update preference explanation
@miurahr miurahr marked this pull request as ready for review October 25, 2024 04:33
I think this is a clearer description.
@@ -2768,7 +2768,7 @@ PREFS_GLOSSARY_STEMMING=Use &stemming
PREFS_GLOSSARY_REPLACE_ON_INSERT=Replace matches when inserting source text
PREFS_GLOSSARY_REQUIRE_SIMILAR_CASE=&Ignore matches with very different case (e.g. FOO vs foo)
PREFS_GLOSSARY_MERGE_ALTERNATE_DEFINITIONS=Merge alternate definitions of the same term
PREFS_GLOSSARY_SORT_BY_SRC_LENGTH=Sort by Source Term Length
PREFS_GLOSSARY_SORT_BY_SRC_LENGTH=Sort by Source Term Length when two or more terms start with the same characters
Copy link
Contributor

Choose a reason for hiding this comment

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

I tried to reword the description a little.

@miurahr miurahr merged commit 50a92be into master Nov 12, 2024
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants